Friday, March 21, 2008

Backup OCR under Oracle Clusterware (CRS)

The OCR (Oracle Configuration Repository) is the registry of all resources in the cluster, and resources registered in the OCR are restarted automatically when the cluster restarts.

The system will take periodic automatic backups of the OCR which are stored in $ORA_CRS_HOME/cdata or $ORA_CRS_HOME/cdata/<Cluster name> on hard disk. These backups will taken every 4 hours, every day and every week. Only the master node takes backups of the OCR and any node can become the master node (depending on node evictions).

$ echo $ORA_CRS_HOME

$ echo $CRS_HOME
/u01/crs/oracle/product/crs
$ cd $CRS_HOME/cdata
pdb2p:/u01/crs/oracle/product/crs/cdata$ls
dssclus-p-01
localhost
pdb2p:/u01/crs/oracle/product/crs/cdata$ls -al dssclus-p-01
total 111008
drwxrwxr-x 2 oracle oinstall 256 Mar 21 11:22 .
drwxrwxr-x 4 oracle oinstall 256 Sep 13 2007 ..
-rw-r--r-- 1 root system 8118272 Mar 21 11:22 backup00.ocr
-rw-r--r-- 1 root system 8118272 Mar 21 07:22 backup01.ocr
-rw-r--r-- 1 root system 8118272 Mar 21 03:22 backup02.ocr
-rw-r--r-- 1 root system 8118272 Mar 19 23:22 day.ocr
-rw-r--r-- 1 root system 8118272 Mar 20 23:22 day_.ocr
-rw-r--r-- 1 root system 8118272 Mar 12 15:22 week.ocr
-rw-r--r-- 1 root system 8118272 Mar 19 15:22 week_.ocr

or

pdb2p:/localhome/oracle$ocrconfig -showbackup
pdb2p 2008/03/21 11:22:58 /u01/crs/oracle/product/crs/cdata/dssclus-p-01
pdb2p 2008/03/21 07:22:57 /u01/crs/oracle/product/crs/cdata/dssclus-p-01
pdb2p 2008/03/21 03:22:56 /u01/crs/oracle/product/crs/cdata/dssclus-p-01
pdb2p 2008/03/19 23:22:52 /u01/crs/oracle/product/crs/cdata/dssclus-p-01
pdb2p 2008/03/12 15:22:17 /u01/crs/oracle/product/crs/cdata/dssclus-p-01

It is recommended by Oracle to take a manual backup of the OCR before trying to add a resource into the OCR. Here is how to manually back up OCR:

pdb2p:/localhome/oracle$cd $CRS_HOME
pdb2p:/u01/crs/oracle/product/crs$cd bin
pdb2p:/u01/crs/oracle/product/crs/bin$ls -al ocrdump
-rwxr-x--x 1 oracle oinstall 2267 Nov 23 10:47 ocrdump
pdb2p:/u01/crs/oracle/product/crs/bin$ocrdump
PROT-304: Failed to create dump file [OCRDUMPFILE]
pdb2p:/u01/crs/oracle/product/crs/bin$ocrdump ~/myfile
pdb2p:/u01/crs/oracle/product/crs/bin$ls -al ~/my*
-rw-r--r-- 1 oracle oinstall 52597 Mar 21 12:56 /localhome/oracle/myfile

Other ocrdump options:

$ ocrdump -stdout -keyname SYSTEM
writes the subtree of SYSTEM in the cluster registry to stdout

$ ocrdump -stdout -xml
writes cluster registry contents to stdout in xml format

$ ocrdump -stdout more
See the cluster registry contents

Restore OCR and others

1. Use ocrconfig to restore OCR from the backup file, for example:
$ ocrconfig -restore $CRS_HOME/cdata/backupfilename
See Note 371378.1 from more details.

2. You can use "ocrcheck" to see the physical location of OCR:
$ ocrcheck
Status of Oracle Cluster Registry is as follows :
Version : 2
Total space (kbytes) : 1048044
Used space (kbytes) : 6212
Available space (kbytes) : 1041832
ID : 1390610369
Device/File Name : /dev/ocr_sdisk1
Device/File integrity check succeeded
Device/File Name : /dev/ocr_sdisk2
Device/File integrity check succeeded
Cluster registry integrity check succeeded

$ ls -al /dev/ocr*
crw-r----- 1 root oinstall 42, 15 Dec 20 2007 ocr_sdisk1
crw-r----- 1 root oinstall 42, 16 Dec 20 2007 ocr_sdisk2

OCRCHECK creates a log file in the directory CRS_Home/log/hostname/client. To change amount of logging, edit the file $CRS_Home/srvm/admin/ocrlog.ini

3. You can use "cluvfy comp ocr -n all" to verify OCR integrity.

No comments: