Tuesday, March 7, 2017

How To Restore OLR

Oracle Local Registry (OLR) is introduced in 11gR2/12c Grid Infrastructure. It contains local node specific configuration required by OHASD and is not shared between nodes. In other word, every node has its own OLR. Let's start the working on OLR.

Step 1: Stop complete crs


Be sure GI stack is completely down and ohasd.bin is not up and running, use the following command to confirm:
ps -ef| grep ohasd.bin

This should return no process, if ohasd.bin is still up and running, stop it on local node:

# <GI_HOME>/bin/crsctl stop crs -f  ####for GI Cluster
OR
# <GI_HOME>/bin/crsctl stop has    ####for GI Standalone



Step 2: Start Restore with below command


# <GI_HOME>/bin/ocrconfig -local -restore <olr-backup>

If the command fails, create a dummy OLR, set correct ownership and permission and retry the restoration command:
# cd <OLR location>
# touch <hostname>.olr
# chmod 600 <hostname>.olr
# chown <grid>:<oinstall> <hostname>.olr



Step 3: Start CRS again


Once it's restored, GI can be brought up:

# <GI_HOME>/bin/crsctl start crs  #### for GI Cluster
OR
$ <GI_HOME>/bin/crsctl start has  #### for GI Standalone, this must be done as grid user


Example


Lets rename our rac1.olr

[root@rac1 cdata]# cd /u01/app/11.2.0/grid/cdata/

[root@rac1 cdata]# ls -ltr rac1.olr

-rw------- 1 root oinstall 272756736 Mar  7 06:55 rac1.olr

[root@rac1 cdata]# mv rac1.olr rac1.olr_old

[root@rac1 cdata]# ls -ltr *rac1.olr*

-rw------- 1 root oinstall 272756736 Mar  7 06:55 rac1.olr_old

[root@rac1 cdata]# /u01/app/11.2.0/grid/bin/crsctl check cluster -all
**************************************************************
rac1:
CRS-4537: Cluster Ready Services is online
CRS-4529: Cluster Synchronization Services is online
CRS-4533: Event Manager is online
**************************************************************
rac2:
CRS-4537: Cluster Ready Services is online
CRS-4529: Cluster Synchronization Services is online
CRS-4533: Event Manager is online
**************************************************************

Let's stop cluster to simulate the error

[root@rac1 cdata]# /u01/app/11.2.0/grid/bin/crsctl stop crs -f

[root@rac1 cdata]# /u01/app/11.2.0/grid/bin/crsctl check cluster -all
CRS-4639: Could not contact Oracle High Availability Services
CRS-4000: Command Check failed, or completed with errors.

#check available backups of OLR

[root@rac1 rac1]# pwd
/u01/app/11.2.0/grid/cdata/rac1

[root@rac1 rac1]# ls -ltr
total 25292
-rw------- 1 root root 6447104 Mar  7 06:02 backup_20170307_060222.olr
-rw------- 1 root root 6467584 Mar  7 06:02 backup_20170307_060225.olr
-rw------- 1 root root 6467584 Mar  7 06:02 backup_20170307_060226.olr
-rw------- 1 root root 6467584 Mar  7 06:53 backup_20170307_065323.olr

#try to restore OLR from backup

[root@rac1 rac1]# /u01/app/11.2.0/grid/bin/ocrconfig -local -restore /u01/app/11.2.0/grid/cdata/rac1/backup_20170307_065323.olr

#check for rac1.olr file

[root@rac1 rac1]# ls -ltr /u01/app/11.2.0/grid/cdata/rac1.olr
ls: /u01/app/11.2.0/grid/cdata/rac1.olr: No such file or directory

#problem with OLR restore, let's try another approach

[root@rac1 rac1]# cd /u01/app/11.2.0/grid/cdata/

[root@rac1 cdata]# touch rac1.olr

[root@rac1 cdata]# chmod 600 rac1.olr

[root@rac1 cdata]# chgrp oinstall rac1.olr

[root@rac1 cdata]# ls -ltr *olr*
total 6356
-rw------- 1 root   oinstall 272756736 Mar  7 07:08 rac1.olr_old
-rw------- 1 root   oinstall         0 Mar  7 07:15 rac1.olr

[root@rac1 cdata]# /u01/app/11.2.0/grid/bin/ocrconfig -local -restore /u01/app/11.2.0/grid/cdata/rac1/backup_20170307_065323.olr

[root@rac1 cdata]# ls -ltr
total 12692
-rw------- 1 root   oinstall 272756736 Mar  7 07:08 rac1.olr_old
-rw------- 1 root   oinstall 272756736 Mar  7 07:18 rac1.olr

[root@rac1 cdata]# /u01/app/11.2.0/grid/bin/ocrcheck -local
Status of Oracle Local Registry is as follows :
         Version                  :          3
         Total space (kbytes)     :     262120
         Used space (kbytes)      :       2168
         Available space (kbytes) :     259952
         ID                       : 2017112488
         Device/File Name         : /u01/app/11.2.0/grid/cdata/rac1.olr
         Device/File integrity check succeeded
         Local registry integrity check succeeded
         Logical corruption check succeeded

[root@rac1 cdata]# /u01/app/11.2.0/grid/bin/crsctl start crs
CRS-4123: Oracle High Availability Services has been started.

[oracle@rac1 ~]$ cluvfy comp olr
Verifying OLR integrity
Checking OLR integrity...
Checking OLR config file...
OLR config file check successful
Checking OLR file attributes...
OLR file check successful

WARNING:
This check does not verify the integrity of the OLR contents. Execute 'ocrcheck -local' as a privileged user to verify the contents of OLR.
OLR integrity check passed
Verification of OLR integrity was successful. 



No comments:

Post a Comment