今天看到大话RAC的RAC维护工具:文章参考
http://blog.csdn.net/tianlesoftware/archive/2010/03/09/5358573.aspx
http://blog.csdn.net/tianlesoftware/archive/2010/04/09/5467273.aspx
(一)备份OCR
1:停止CRS
在进行备份恢复OCR的实验的时候:如下 ,首先查看各个进程:
[oracle@raw1 bin]$ ps -ef | grep d.bin
root 6124 1 0 Feb28 ? 00:30:58 /u01/app/oracle/product/crs/bin/crsd.bin reboot
oracle 7269 6122 0 Feb28 ? 00:07:13 /u01/app/oracle/product/crs/bin/evmd.bin
oracle 7398 7372 0 Feb28 ? 02:25:56 /u01/app/oracle/product/crs/bin/ocssd.bin
oracle 28487 24179 0 14:36 pts/2 00:00:00 grep d.bin
[oracle@raw1 ~]$ cd /u01/app/oracle/product/crs/bin/
[oracle@raw1 bin]$ crsctl stop crs
Insufficient user privileges.
[oracle@raw1 ~]$ su - root
Password:
[root@raw1 ~]# crsctl stop crs
-bash: crsctl: command not found
[root@raw1 ~]# exit
发现无权限,于是切换到ROOT,还是不行,查了篇文章,才发现自己犯了低级错误
su root是不重新加载工作环境的.也就是当前目录不会改变.当前用户环境变量也不会改变.所有由一般帐号su root还是会找不到管理命令.因为用户环境变量还是当前用户的
su - root 重新加载工作环境..当前目录转至root下.当前用户环境变量更换为root的环境变量.
由于root环境变量没有设置$oracle_home和crs的环境变量,所以root下提示没有这个命令,重新用su root 后,如下:
[oracle@raw1 bin]$ crsctl check crs
CSS appears healthy
CRS appears healthy
EVM appears healthy
[oracle@raw1 bin]$ su root
Password:
2:导出OCR进行备份
[root@raw1 oracle]# ocrconfig -export /u01/ocrexp.exp
或者如下
[root@raw1 oracle]# cd /u01/app/oracle/product/crs/bin/
[root@raw1 bin]# ./ocrconfig -export /u01/ocr.exp
查看导出结果:
[root@raw1 bin]# cd /u01
[root@raw1 u01]# ls
app raw1arch1_48_744056477.dbf
ocr.exp raw1arch1_49_744056477.dbf
ocrexp.exp raw1arch1_50_744056477.dbf
3:重新启动CRS
[root@raw1 u01]# crsctl start crs
Attempting to start CRS stack
The CRS stack will be started shortly
立马查看CRS状态,不能立刻启动,要过上一会
[root@raw1 u01]# crsctl check crs
Failure 1 contacting CSS daemon
Cannot communicate with CRS
Cannot communicate with EVM
[root@raw1 u01]# crsctl check crs
CSS appears healthy
CRS appears healthy
EVM appears healthy
4:破坏OCR
[root@raw1 u01]# dd if=/dev/zero of=/dev/raw/raw1 bs=1024 count=102400
102400+0 records in
102400+0 records out
5:检查OCR一致性
[root@raw1 u01]# /u01/app/oracle/product/crs/bin/ocrcheck
PROT-601: Failed to initialize ocrcheck
6:使用cluvfy 工具检查一致性,首先进到CLUSTER的软件解压目录,如下
[root@raw1 soft]# cd /home/oracle/soft/clusterware/cluvfy/
[root@raw1 cluvfy]# runcluvfy.sh comp ocr -n all
Verifying OCR integrity
Unable to retrieve nodelist from Oracle clusterware.
Verification cannot proceed.
7:用Import恢复目录
[root@raw1 cluvfy]# $ORA_CRS_HOME/bin/ocrconfig -import /u01/ocr.exp
8:检查恢复OCR后的状态
[root@raw1 cluvfy]# $ORA_CRS_HOME/bin/ocrcheck
Status of Oracle Cluster Registry is as follows :
Version : 2
Total space (kbytes) : 244632
Used space (kbytes) : 3800
Available space (kbytes) : 240832
ID : 1212832261
Device/File Name : /dev/raw/raw1
Device/File integrity check succeeded
Device/File not configured
Cluster registry integrity check succeeded
[root@raw1 cluvfy]# runcluvfy.sh comp ocr -n all (刚开始为什么我这里的结果老是出错,错误如下)
Verifying OCR integrity
ERROR:
User equivalence unavailable on all the nodes.
Verification cannot proceed.
Verification of OCR integrity was unsuccessful on all the nodes.
仔细认真的想了想,当时做检测的时候没有出错,唯一不同的是当时是用ORACLE权限检测的,此时唯一的区别就是这个,于是退出ROOT权限,再次进行检测如下:成功,但是我认真看了下《大话RAC》里的执行权限的确是ROOT,求解!
[oracle@raw1 soft]# cd /home/oracle/soft/clusterware/cluvfy/
[oracle@raw1 cluvfy]$ runcluvfy.sh comp ocr -n all
Verifying OCR integrity
Checking OCR integrity...
Checking the absence of a non-clustered configuration...
All nodes free of non-clustered, local-only configurations.
Uniqueness check for OCR device passed.
Checking the version of OCR...
OCR of correct Version "2" exists.
Checking data integrity of OCR...
Data integrity check for OCR passed.
OCR integrity check passed.
Verification of OCR integrity was successful.
(二)移动OCR 文件位置
1:查看备份
[root@raw1 cluvfy]# $ORA_CRS_HOME/bin/ocrconfig -showbackup
raw1 2011/03/21 14:37:23 /u01/app/oracle/product/crs/cdata/crs
raw1 2011/03/21 10:37:22 /u01/app/oracle/product/crs/cdata/crs
raw1 2011/03/21 06:37:22 /u01/app/oracle/product/crs/cdata/crs
raw1 2011/03/20 02:37:18 /u01/app/oracle/product/crs/cdata/crs
raw1 2011/03/11 02:36:46 /u01/app/oracle/product/crs/cdata/crs
注意这里的日期,可以看出oracle的备份周期和规律:保留当天前4个小时,前8个小时和前16个小时的最后3个备份,以及昨天最后一个备份,以及上周最后一个备份
[root@raw1 bin]# crsctl stop crs
Stopping resources.
Successfully stopped CRS resources
Stopping CSSD.
Shutting down CSS daemon.
Shutdown request successfully issued.
[root@raw1 oracle]# crsctl check crs
Failure 1 contacting CSS daemon
Cannot communicate with CRS
Cannot communicate with EVM
PS:添加在线备份
1、方法1:手动备份ocr及其恢复方法
备份:
如果不在线备份去掉 -s online,不在线需要先停止OCR
[root@rac1 crs]# ocrconfig -export /tmp/ocr_bak.20100126 -s online |
恢复:
恢复要在crs处于关闭状态时进行
[root@rac1 crs]# ocrconfig -import /tmp/ocr_bak.20100126 |
2、方法2:从自动备份中恢复
oracle 10G r2 rac会每4小时自动备份ocr到$CRS_HOME/cdata/crs目录中
这个目录中保留每周、每天、当天每4小时的备份
检查自动备份的crs
[root@rac1 ~]# cd $ORA_CRS_HOME/cdata/crs [root@rac1 crs]# ls -l total 27936 -rw-r--r-- 1 root root 4083712 Jan 26 14:28 backup00.ocr -rw-r--r-- 1 root root 4083712 Jan 26 10:28 backup01.ocr -rw-r--r-- 1 root root 4083712 Jan 26 06:28 backup02.ocr -rw-r--r-- 1 root root 4083712 Jan 26 02:28 day_.ocr -rw-r--r-- 1 root root 4083712 Jan 25 02:28 day.ocr -rw-r--r-- 1 root root 4083712 Jan 23 02:28 week_.ocr -rw-r--r-- 1 root root 4075520 Jan 16 02:28 week.ocr |
恢复的方法是:
恢复要在crs处于关闭状态时进行
[root@rac1 crs]# ocrconfig -restore ./backup00.ocr |