Sunday, November 17, 2013

OCR Backup &Recovery Types IN 11GR2 RAC With ASM

Managing OCR

Three tools used to manage: OCRCONFIG, OCRDUMP and OCRCHECK

How to check OCR recovery required for the cluster?

[root@rac1]# /u01/app/11.2.0/grid/bin/ocrcheck

always check the cluster registry integrity to verify the recovery of ocr required or not
  
[root@rac1 bin]# ./ocrcheck
Status of Oracle Cluster Registry is as follows :
Version : 3
Total space (kbytes) : 262120
Used space (kbytes) : 3316
Available space (kbytes) : 258804
ID : 579764850
Device/File Name : /u01/ocr/ocr
Device/File integrity check succeeded
Device/File not configured 
Device/File not configured
Device/File not configured
Device/File not configured
Cluster registry integrity check succeeded
Logical corruption check succeeded

If this command does not display the message Device/File integrity check succeeded for at least one copy of the OCR, then both the primary OCR and the OCR mirrors have failed. 
You must restore the OCR from a backup. If there is at least one copy of the OCR available, you can use that copy to restore the othercopies of the OCR

Types of OCR Backup & Recovery
1.Manual backup & Recovery of OCR
2.Manual Export & Import of OCR  

Types of OCR Backup & Recovery

1.Manual backup & (Automatic/manual)Recovery of OCR
2.Manual Export & Import of OCR

 1.Manual backup & Recovery of OCR
To perform manual backup of OCR:
  • You can use the ocrconfig -manualbackup command to force Oracle Clusterware to perform a backup of the OCR at any time, rather than wait for the automatic backup that occurs at 4-hour intervals.
  • The -manualbackup option is especially useful when you to need to obtain a binary backup on demand, such as before you make changes to the OCR.
  • You need to be logged in as root user to take manual backups
To view the available OCR Manual backup
[root@rac1 bin]# ./ocrconfig -showbackup manual  

To perform manual backup

 
 [root@rac1 bin]# ./ocrconfig -manualbackup
[root@rac1 bin]# ./ocrconfig -showbackup manual
 
To perform manual recovery of OCR:
When restoring the OCR from automatically generated backups, you first have to determine which backup file you will use for the recovery. Identify the available OCR backups using the ocrconfig command while logged in as root user:
STEP 1: View the available list of OCR backup as root user and choose which OCR file needed for recovery
[root@rac2 bin]# ./ocrconfig -showbackup manual

STEP 2: review the content  available in the backup of OCR using “OCRDUMP” command
The command generates an 
 OCRDUMPFILE in ASCII file format.

[root@racl2 bin]# ./ocrdump -backupfile /u01/app/11.2.0.2/grid/cdata/rac2/backup_271012_2.ocr


[root@raclinux2 bin]# ls OCRDUMPFILE
 
OCRDUMPFILE
then view content in OCRDUMPFILE to verify the validity

(imagine that we have valid copy of the ocr available).

Now recovery OCR using following steps

Automatic (or) manual Restore of OCR:

When restoring the OCR from automatically/manually generated backups,
first we have to determine which backup file you will use for the recovery.
Identify the available OCR backups using the ocrconfig command while logged in as root user

Step1: view the list of available backup of OCR created by automatically/manually

[root@rac1 bin]#./ocrconfig -showbackup auto
(or)
[root@rac1 bin]#./ocrconfig -showbackup manual

Step 2: Point the available backup of ocr file either created automatically or manually to verify the validity and read the content in the OCRDUMPFILE created in ASCII format

[root@rac1 bin]#./ocrdump -backupfile /u01/app/11.2.0.2/grid/cdata/rac1/backup_20101219_201012.ocr

Step 3: As the root user, Restart Oracle Clusterware on all nodes  (for instance rac1, rac2) of the Oracle RAC cluster

On node:RAC1
[root@rac1 bin]#./crsctl stop crs

On node:RAC2
[root@rac2 bin]#./crsctl stop crs


The OCR is present on ASM so we need to start the ASM on the the particular node(rac1)(called "exclusive mode") where we will recover the OCR. After the startup of rac1 node verify that the diskgroup we need are mounted.

On node:RAC1
[root@rac1 bin]#./crsctl start crs -excl

SQL> select name, state from v$asm_diskgroup;

NAME STATE
—————————— ———–
DATA MOUNTED
DGDUP1 MOUNTED
DGDUP2 MOUNTED
DGDUP MOUNTED
PRIM MOUNTED
SEC MOUNTED
6 rows selected.

Step 4: check and stop crsd if  running on node rac1

[root@rac1 bin]#./crsctl stop resource ora.crsd -init
Note:(if you do not stop, it  will throw an error )

Step 5: As the root user, restore the OCR backup.
mention the file_name for which we have already verified the validity and  include the name of the OCR that you want to restore.

[root@rac1 bin]#./ocrconfig -restore
/u01/app/11.2.0.2/grid/cdata/rac1/backup_20101219_201012.ocr
PROT-19: Cannot proceed while the Cluster Ready Service is running
(it shows restore command failed due to the error the crs running so stop the crsd )

[root@rac1 bin]#./crsctl stop resource ora.crsd -init
CRS-2673: Attempting to stop ‘ora.crsd’ on ‘rac1′
CRS-2677: Stop of ‘ora.crsd’ on ‘rac1′ succeeded
(crs is sucessfully stopped)

Step 6: now crs is sucessfully stoped again run the restore command and check the integrity of OCR once again
[root@rac1 bin]#./ocrconfig -restore
/u01/app/11.2.0.2/grid/cdata/rac1/backup_20101219_201012.ocr
[root@rac1 bin]#
(above prompt shows restore process sucessfull)

Now verify the integrity of OCR in rac1 node
[root@rac1 bin]#./ocrcheck

Step 7: As root stop the Oracle clusterware as it is running exclusivly on node rac1 ( called" exclusive mode") and start clusterware on all nodes (rac1 ,rac2)
[root@rac1 bin]#./crsctl stop crs -f
.
.
CRS-2793: Shutdown of Oracle High Availability Services-managed resources on ‘rac1′ has completed
CRS-4133: Oracle High Availability Services has been stopped.

Now start the node “ rac1”
[root@rac1 bin]#./crsctl start crs
CRS-4123: Oracle High Availability Services has been started.

 Now start the node “ rac2”
[root@rac2 bin]#./crsctl start crs
CRS-4123: Oracle High Availability Services has been started.

Step 9: Using the Cluster Verification Utility(CVU) to verify the OCR integrity.
Run the following command, where the "-n all" argument retrieves a list of
all the cluster nodes that are configured as part of your cluster.

[root@rac1 bin]#./cluvfy comp ocr -n all [-verbose]

[root@rac2 bin]#./cluvfy comp ocr -n all [-verbose]

The output as show below confirms that OCR was successfully restored on rac1, rac2.
 
2.Manual Export & Import of OCR 

MANUAL EXPORT OF OCR FILE:

By using ocrconfig -export file_name command to export the OCR content to a file format.
we can also export the OCR contents to a file before and after making significant configuration changes such as adding or deleting nodes from your environment, modifying Oracle Clusterware resources, or creating a database.
Exporting the OCR contents to a file lets you restore the OCR if your configuration changes cause errors. 
 

EXAMPLE, 
if you have un-resolvable configuration problems
if you are unable to restart your cluster database after such changes like adding or deleting nodes from your environment, modifying Oracle Clusterware resources, or creating a database.
then you can restore your configuration by importing the saved OCR content from the valid configuration. 

STEP1:
[root@rac2 bin]# ./ocrconfig -export /tmp/ocr_export120812.exp
[root@rac2 bin]# ls /tmp
ocr_export120612.exp
ocr_export120712.exp
ocr_export120812.exp

MANUAL IMPORT OF OCR FILE:

We have two node cluster RAC1, RAC2. To import the exported_ocr_backup_file
follow the steps below

STEP 1: stop Oracle Clusterware on all the nodes(rac1, rac2) in Oracle RAC cluster as root user
[root@rac1 bin]#./crsctl stop crs

 
[root@rac2 bin]#./crsctl stop crs

STEP 2: start the Oracle clusterware on only one node(rac2) in "exclusive mode" so that we are able to perform the import process.
a)[root@rac2 bin]# ./crsctl start crs -excl
(or)
b)[root@rac2 bin]# ./crsctl start crs -excl -nocrs

STEP 3: All ASM disk groups that needed for OCR import process are mounted by ASM. Before 
starting the import from the "exported file". 
SQL> select name, state from v$asm_diskgroup;
NAME STATE
—————————— ———–
DATA MOUNTED
DGDUP1 MOUNTED
DGDUP2 MOUNTED
DGDUP MOUNTED
PRIM MOUNTED
SEC MOUNTED
6 rows selected.

STEP 4: Check the ocr file from the exported location and perform the import by giving full path and file name
[root@rac2 bin]# ls /tmp
ocr_export120612.exp
ocr_export120712.exp
ocr_export120812.exp

[root@rac2 bin]#ocrconfig -import /tmp/tmp/ocr_export120812.exp 
#################Note:we cannot use the ocrconfig command to import an OCR backup file created automatically, only exported OCR file can be imported

STEP 5: Now check the integrity Status of Oracle Cluster Registry as root user from rac2 node 
[root@rac2 bin]# ./ocrcheck
Status of Oracle Cluster Registry is as follows :
......
Cluster registry integrity check succeeded
Logical corruption check succeeded.

STEP 6: As root user stop the CRS from rac2 node and bring it out from exclusive mode
[root@rac2 bin]# ./crsctl stop crs -f
.
.
.
CRS-2793: Shutdown of Oracle High Availability Services-managed resources on ‘rac2′ has completed
CRS-4133: Oracle High Availability Services has been stopped.

STEP 7:Logged in as the root user, restart Oracle Clusterware on all the nodes(RAC1, RAC2) in your cluster by restarting each node, or by running the following command:
[root@rac1 bin]# ./crsctl start crs
CRS-4123: Oracle High Availability Services has been started.

[root@rac2 bin]# ./crsctl start crs
CRS-4123: Oracle High Availability Services has been started.

STEP 8: Verify the status of OCR integrity between the nodes (rac1, rac2) with option "-n all"
which helps to retrieves the information about list of all the cluster nodes that are configured as part of your cluster.

[oracle@rac1 bin]$ cluvfy comp ocr -n all -verbose
[oracle@rac2 bin]$ cluvfy comp ocr -n all -verbose

No comments:

Post a Comment