The Oracle Clusterware Repository or OCR is a file containing metadata describing the Cluster configuration, the locations of the voting disks, the resources managed by the Clusterware processes and their attributes and interrelationships.
Two of the utilities which access the OCR file and display certain details are:
1. srvctl - this will display certain attributes relating to ASM, Databases, Database and ASM instances, Services, Listeners and Nodeapps. We can see this with a simple invocation of “srvctl”:
Oracle$ srvctl
Usage: srvctl <command> <object> [<options>]
command:enable|disable|start|stop|relocate|status|add|remove|modify|
getenv|setenv|unsetenv|config
objects: database|instance|service|nodeapps|asm|listener
For detailed help on each command and object and its options use:
srvctl <command> <object> -h
I have highlighted the list of objects that may be managed with any of the commands listed above but notice that the resources in the object do not include clusterware components or metadata and there is no reference to clusterware attributes. Note that the nodeapps include the VIPs which are not part of the clusterware but rather are resources managed by the clusterware.
2. crs_stat – this utility has many flags controlling the level of detail displayed on the screen but essentially this will display clusterware resources in a formatted output. Here are the options:
Oracle$ crs_stat -h
Usage: crs_stat [resource_name [...]] [-v] [-l] [-q] [-c cluster_member]
crs_stat [resource_name [...]] -t [-v] [-q] [-c cluster_member]
crs_stat -p [resource_name [...]] [-q]
crs_stat [-a] application -g
crs_stat [-a] application -r [-c cluster_member]
crs_stat -f [resource_name [...]] [-q] [-c cluster_member]
crs_stat -ls [resource_name [...]] [-q]
If “crs_stat” is invoked with no arguments then a terse output is produced containing the name and 3 attributes of resources such as Databases, ASM, Instances of Databases and ASM, Services and their preferred instances, Listeners, and Nodeapps. Here is some example output:
Oracle$ crs_stat
NAME=ora.angel.angel1.inst
TYPE=application
TARGET=ONLINE
STATE=ONLINE on abcduc1
NAME=ora.angel.angel2.inst
TYPE=application
TARGET=ONLINE
STATE=ONLINE on abcduc2
NAME=ora.angel.db
TYPE=application
TARGET=ONLINE
STATE=ONLINE on abcduc1
….
Oracle$
A popular alternative is to use the -t flag to restrict output to one line per resource as follows:
Oracle$ crs_stat -t
Name Type Target State Host
___________________________________________________________
ora….A1.inst application ONLINE OFFLINE
ora….A2.inst application ONLINE OFFLINE
ora….l1.inst application ONLINE ONLINE abcduc1
ora….l2.inst application ONLINE ONLINE abcduc2
ora.angel.db application ONLINE ONLINE abcduc1
……
Note that the resource name is not fully printed with this formatting. Also the list of resources is still restricted to the ones I mentioned above.
One way to get the full resource name is to use a script to format the name and other attributes as follows:
#!/usr/bin/ksh
#
# Sample 10g CRS resource status query script
#
# Description:
# – Returns formatted version of crs_stat -t, in tabular
# format, with the complete rsc names and filtering keywords
# – The argument, $RSC_KEY, is optional and if passed to the script, will
# limit the output to HA resources whose names match $RSC_KEY.
# Requirements:
# – $ORA_CRS_HOME should be set in your environment
RSC_KEY=$1
QSTAT=-u
AWK=/usr/bin/awk # if not available use /usr/bin/awk
# Table header:echo “”
$AWK \
‘BEGIN {printf “%-45s %-10s %-18s\n”, “HA Resource”, “Target”, “State”;
printf “%-45s %-10s %-18s\n”, “———–”, “——”, “—–”;}’
# Table body:
$ORA_CRS_HOME/bin/crs_stat $QSTAT | $AWK \
‘BEGIN { FS=”=”; state = 0; }
$1~/NAME/ && $2~/’$RSC_KEY’/ {appname = $2; state=1};
state == 0 {next;}
$1~/TARGET/ && state == 1 {apptarget = $2; state=2;}
$1~/STATE/ && state == 2 {appstate = $2; state=3;}
state == 3 {printf “%-45s %-10s %-18s\n”, appname, apptarget, appstate; state=0;}’
This will return output containing the complete resource name:
HAResource Target State
————— ——– ——
ora.TUTOR1A.TUTOR1A1.inst ONLINE ONLINE on abcduc1
……
If however, you wish to examine all the metadata in the OCR including details of the clusterware files, network addresses, ports, processes and their attributes then use the “ocrdump” utility in the clusterware home bin directory:
To get help simply do:
Oracle$ ocrdump -h
Name:
ocrdump – Dump contents of Oracle Cluster Registry to a file.
Synopsis:
ocrdump [<filename>|-stdout] [-backupfile <backupfilename>] [-keyname <keyname>] [-xml] [-noheader]
Description:
Default filename is OCRDUMPFILE. Examples are:
prompt> ocrdump
writes cluster registry contents to OCRDUMPFILE in the current directory
prompt> ocrdump MYFILE
writes cluster registry contents to MYFILE in the current directory
prompt> ocrdump -stdout -keyname SYSTEM
writes the subtree of SYSTEM in the cluster registry to stdout
prompt> ocrdump -stdout -xml
writes cluster registry contents to stdout in xml format
Notes:
The header information will be retrieved based on best effort basis.
A log file will be created in $ORACLE_HOME/log/<hostname>/client/ocrdump_<pid>.log. Make sure you have file creation privileges in the above directory before running this tool.
So now do the following:
Oracle$ ocrdump MYOCRDUMP
This will produce a formatted dump called MYOCRDUMP of all the OCR file contents in the current directory which may them be explored using any convenient editing tool.
The Dumpfile has 3 main parts:
1. SYSTEM – Desribes attributes of the clusterware such as interfaces, cluster name, cluster parameters such as misscount, locations of voting disks, location of OCR backups, cluster node names and numbers, hostnames and much more. This metadata is used by the clusterware processes CRSD, CSSD and EVMD.
2. DATABASE – Contains metadata for all the resources managed by the clusterware. This is the information that is formatted for output by the “crs_stat” utility and by “srvctl” and lists databases, ASM, instances, services, nodeapps, atc..
3. CRS – Contains metadata for any Non-RAC resources that are managed for high availability by the clusterware. These resources will have been created by the “crs_profile” utility, and then registered in the OCR using the “crs_register” utility. Once all related resources have been registered then they will have been activated using the “crs_start” utility. If no such resources are managed by the clusterware then the CRS section will be virtually empty with a single entry for Scurity.
ocrcheck is the command to check out the OCR. Here is a sample output of ocrcheck.
oracle:aded168p::p599b:ocrcheck
Status of Oracle Cluster Registry is as follows :
Version : 2
Total space (kbytes) : 425748
Used space (kbytes) : 7008
Available space (kbytes) : 418740
ID : 885992782
Device/File Name : /eb_inf10_p/oracrs/ocr1
Device/File integrity check succeeded
Device/File Name : /eb_inf10_p/oracrs/ocr2
Device/File integrity check succeeded
Cluster registry integrity check succeeded
The file /etc/oracle/ocr.loc can also be used for this.