Wednesday, May 18, 2011

Automatic Diagnostic Repository (ADR) in Oracle 11g

A special repository, named ADR (Automatic Diagnostic Repository) is automatically maintained by Oracle 11g to hold diagnostic information about critical error events. This repository is maintained in memory which enables database components to capture diagnostic data at its first failure for critical errors.

In Oracle 11g, the init.ora parameters like user_dump_dest and background_dump_dest are deprecated. They have been replaced by the single parameter DIAGNOSTIC_DEST which identifies the location of the ADR . ADR is file based repository for diagnostic data like trace file,process dump,data structure dump etc.

The default location of  DIAGNOSTIC_DEST  is  $ORACLE_HOME/log, and if ORACLE_BASE is set in environment  then DIAGNOSTIC_DEST is set to $ORACLE_BASE.  The ADR can be managed via the 11g Enterprise Manager GUI  (Database Control and not Grid Control) or via the ADR command line interpreter adrci .

11g new initialize parameter DIAGNOSTIC_DEST decide location of ADR root.

  


Structure of ADR Directory is designed in such a way that uses consistent diagnostic data formats across products and instances, and a integrated set of tools enable customers and Oracle Support to correlate and analyze diagnostic data across multiple instances .

In 11g alert file is saved in 2 location, one is in alert directory ( in XML format) and old style alert file in trace directory . Within ADR base, there can be many ADR homes, where each ADR home is the root directory for all diagnostic data for a particular instance. The location of an ADR home for a database is shown in the above pictures . Both the files can be viewed with  EM and ADRCI Utility.

SQL> show parameter diag
NAME               TYPE            VALUE
-------------     -------       -----------------
diagnostic_dest   string           D:\ORACLE

Below table shows us the new location of Diagnostic trace files

   Data                                Old location                        ADR location
-------------------         ------------------------        ---------------------
Core Dump                       CORE_DUMP_DEST                 $ADR_HOME/cdump
Alert log data                    BACKGROUND_DUMP_DEST   $ADR_HOME/trace
Background process trace   BACKGROUND_DUMP_DEST       $ADR_HOME/trace
User process trace             USER_DUMP_DEST                 $ADR_HOME/trace

We can use V$DIAG_INFOview to list some important ADR locations such as ADR Base, ADR Home, Diagnostic Trace, Diagnostic Alert, Default Trace file, etc.

SQL> select * from v$diag_info;
INST_ID          NAME                VALUE
----------    -----------          ---------------------------
1                   Diag Enabled        TRUE
1                  ADR Base             d:\oracle
1                  ADR Home            d:\oracle\diag\rdbms\noida\noida
1                  Diag Trace           d:\oracle\diag\rdbms\noida\noida\trace
1                  Diag Alert             d:\oracle\diag\rdbms\noida\noida\alert
1                  Diag Incident        d:\oracle\diag\rdbms\noida\noida\incident
1                  Diag Cdump          d:\oracle\diag\rdbms\noida\noida\cdump
1                  Health Monitor      d:\oracle\diag\rdbms\noida\noida\hm
1                  Active Problem Count       0
1                  Active Incident Count      0
10 rows selected.

ADRCI ( Automatic Diagnostic Repository Command  Interpreter) :
The ADR Command Interpreter (ADRCI) is a command-line tool that we use to manage Oracle Database diagnostic data. ADRCI is a command-line tool that is part of the fault diagnosability infrastructure introduced in Oracle Database Release 11g. ADRCI enables:

  • Viewing diagnostic data within the Automatic Diagnostic Repository (ADR).
  • Viewing Health Monitor reports.
  • Packaging of incident and problem information into a zip file for transmission to Oracle Support.
Diagnostic data includes incident and problem descriptions, trace files, dumps, health monitor reports, alert log entries, and more .


ADRCI has a rich command set, and can be used in interactive mode or within scripts. In addition, ADRCI can execute scripts of ADRCI commands in the same way that SQL*Plus executes scripts of SQL and PL/SQL commands.

To use ADRCI in interactive mode :
Enter the following command at the operating system command prompt:
C:\>adrci
ADRCI: Release 11.1.0.6.0 - Beta on Wed May 18 12:31:40 2011
Copyright (c) 1982, 2007, Oracle.  All rights reserved.
ADR base = "d:\oracle"

To get list of adrci command type help command as below : 

adrci> help

 HELP [topic]
   Available Topics:
        CREATE REPORT
        ECHO
        EXIT
        HELP
        HOST
        IPS
        PURGE
        RUN
        SET BASE
        SET BROWSER
        SET CONTROL
        SET ECHO
        SET EDITOR
        SET HOMES | HOME | HOMEPATH
        SET TERMOUT
        SHOW ALERT
        SHOW BASE
        SHOW CONTROL
        SHOW HM_RUN
        SHOW HOMES | HOME | HOMEPATH
        SHOW INCDIR
        SHOW INCIDENT
        SHOW PROBLEM
        SHOW REPORT
        SHOW TRACEFILE
        SPOOL
 There are other commands intended to be used directly by Oracle, type  "HELP EXTENDED" to see the list

Viewing the Alert Log :  
The alert log is written as both an XML-formatted file and as a text file. we can view either format of the file with any text editor, or we can run an ADRCI command to view the XML-formatted alert log with the XML tags stripped. By default, ADRCI displays the alert log in your default editor

The following are variations on the SHOW ALERT command:

adrci > SHOW ALERT -TAIL
This displays the last portion of the alert log (the last 10 entries) in your terminal session.

adrci> SHOW ALERT -TAIL 50
This displays the last 50 entries in the alert log in your terminal session.

adrci> SHOW ALERT -TAIL -F
This displays the last 10 entries in the alert log, and then waits for more messages to arrive in the alert log. As each message arrives, it is appended to the display. This command enables you to perform "live monitoring" of the alert log. Press CTRL-C to stop waiting and return to the ADRCI prompt.Here are few Example :

adrci> show alert
Choose the alert log from the following homes to view:
1: diag\clients\user_neerajs\host_444208803_11
2: diag\clients\user_system\host_444208803_11
3: diag\clients\user_unknown\host_411310321_11
4: diag\rdbms\delhi\delhi
5: diag\rdbms\noida\noida
6: diag\tnslsnr\ramtech-199\listener
Q: to quit

Please select option:  4
Output the results to file: c:\docume~1\neeraj~1.ram\locals~1\temp\alert_932_4048_delhi_1.ado
'vi' is not recognized as an internal or external command,
operable program or batch file.
Please select option: q

Since we are on window platform so we don't have vi editor.So we have set editor for window say notepad.

adrci> set editor notepad
adrci> SHOW ALERT 
Choose the alert log from the following homes to view:
1: diag\clients\user_neerajs\host_444208803_11
2: diag\clients\user_system\host_444208803_11
3: diag\clients\user_unknown\host_411310321_11
4: diag\rdbms\delhi\delhi
5: diag\rdbms\noida\noida
6: diag\tnslsnr\ramtech-199\listener
Q: to quit

Please select option:
Output the results to file: c:\docume~1\neeraj~1.ram\locals~1\temp\alert_916_956_noida_7.ado
Here it will open the alert log file and check the file as per our need . 

If we want to filter the alert log file then we can filter as below :

adrci> show alert  -P "message_text  LIKE '%ORA-600%'"
This displays only alert log messages that contain the string 'ORA-600'.

Choose the alert log from the following homes to view:
1: diag\clients\user_neerajs\host_444208803_11
2: diag\clients\user_system\host_444208803_11
3: diag\clients\user_unknown\host_411310321_11
4: diag\rdbms\delhi\delhi
5: diag\rdbms\noida\noida
6: diag\tnslsnr\ramtech-199\listener
Q: to quit
Please select option:

Here, there is no ora-600 error in alert log file so it is blank 

Finding Trace Files  : 
ADRCI enables us to view the names of trace files that are currently in the automatic diagnostic repository (ADR). We can view the names of all trace files in the ADR, or we can apply filters to view a subset of names. For example, ADRCI has commands that enable us to:
  • Obtain a list of trace files whose file name matches a search string.
  • Obtain a list of trace files in a particular directory.
  • Obtain a list of trace files that pertain to a particular incident.
The following statement lists the name of every trace file that has the string 'mmon' in its file name. The percent sign (%) is used as a wildcard character, and the search string is case sensitive.

adrci> SHOW TRACEFILE  %pmon%
This statement lists the name of every trace file that is located in the  directory and that has the string 'mmon' in its file name:

adrci> SHOW TRACEFILE -RT
This statement lists the names of all trace files related to incident number 1681:

Viewing Incidents : 
The ADRCI SHOW INCIDENT command displays information about open incidents. For each incident, the incident ID, problem key, and incident creation time are shown. If the ADRCI homepath is set so that there are multiple current ADR homes, the report includes incidents from all of them.

adrci> SHOW INCIDENT

ADR Home = d:\oracle\diag\rdbms\noida\noida:
*******************************************************************
0 rows fetched

Purging Alert Log Content : 
The adrci command ‘purge’ can be used to purge entries from the alert log. Note that this purge will only apply to the XML based alert log and not the text file based alert log which still has to be maintained using OS commands.  The purge command takes the input in minutes and specifies the number of minutes for which records should be retained.
So to purge all alert log entries older than 7 days the following command will be used:

adrci > purge -age 10080 -type ALERT

ADR Retention can be controlled with ADRCI :
There is retention policy for ADR that allow to specify how long to keep the data ADR incidents are controlled by two different policies:

The incident metadata retention policy ( default is 1 year )
The incident files and dumps retention policy ( Default is one month)
We can change retention policy using “adrci” MMON  purge data automatically on expired ADR data.

adrci> show control
The above command will show the  shortp_policy and longp_policy and this policy can the changed as below:

adrci> set control (SHORTP_POLICY = 360 )
adrci> set control (LONGP_POLICY = 4380 )

For more detail information on ADR visit below url :


Enjoy   :-) 


1 comment:

Unknown said...

I haven noticed that the moment I put my mind to doing something I do it. It is incredible how far you can push yourself with the right motivation. I think that it has made a pretty awesome difference in my own life.

Jason|http://ifixny.com/data-recovery-ny