温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

管理OCR与VoteDisk

发布时间:2020-08-11 19:56:15 来源:ITPUB博客 阅读:104 作者:不一样的天空w 栏目:建站服务器

Oracle Clusterware由2部分组成,分别是Voting Disk和OCR。Voting Disk里面记录着节点成员的信息。如RAC数据库中有哪些节点成员,节点增加或者删除时也同样会将信息记录进来。Voting Disk必须存放在共享存储上,通常来说是存放在裸设备上。为了保证Voting Disk的安全,需要配置多个Voting Disk,Oracle建议Voting Disk的个数应该为奇数个,如 1、3、5个,每个Voting Disk的大小约为20MB。
OCR记录的是节点成员的配置信息,如数据库、ASM、实例、监听器、VIP等CRS资源的配置信息。CRS进程管理的信息来自OCR的内容。OCR存储的配置信息是以目录树的形式来记录一系列“键-值”对应信息的。OCR记录着CRS进程管理资源的所有配置信息。大小约为100MB。
对Voting Disk的更改必须用root来进行。
添加一个Voting Disk成员:crsctl add css votedisk /dev/raw/raw3'
删除一个Voting Disk成员:crsctl delete css votedisk /dev/raw/raw3'

对OCR的增加、删除和替代配置可以由root用户通过ocrconfig -replace来操作:
ocrconfig -replace /dev/raw/raw1

注意:添加、删除Voting Disk必须在线完成。

Voting Disk和OCR存放的信息是至关重要的,一旦他们丢失或者损坏的话,Clusterware将无法启动,这样整个RAC都无法启动。因此需要对Voting Disk和OCR进行完备的备份。

对Voting Disk的备份操作可以通过dd命令来操作。
查看位置:
#crsctl query css votedisk
备份操作:
#dd if=/dev/raw/raw2 f=/home/oracle/voting_disk.bak
恢复操作:
#dd if=/home/oracle/voting_disk.bak f=/dev/raw/raw2

默认情况下,RAC会在其中一个节点上每4个小时都自动备份一次OCR。并保留最近的3次备份,另外还保留最近两天以及最近两个周末的备份。这个可以通过命令ocrconfig -showbackup来查看。由于ocr信息的重要性,OCR默认会每4小时自动备份一次ocr的内存,保留最新的3个备份,还会保留最近2周周末的备份。备份默认的备份路径为$CRS_HOME/cdata/crs。可以通过ocrconfig -backuploc来更改OCR的备份路径。OCR自动备份的时间间隔无法修改。我们还可以通过ocrconfig -export 来到处OCR的内容,也可以通过通过ocrconfig -import导入OCR的内容。

可以用ocrconfig -restore 命令对OCR进行恢复。
./ocrconfig -restore /u01/oracle/product/10g/crs/cdata/crs/backup00.ocr

添加Voting Disk:
[root@rhel1 bin]# ./crsctl add css votedisk /u01/ocfs2fs/vdisk2
Cluster is not in a ready state for online disk addition
[root@rhel1 bin]# ./crsctl add css votedisk /u01/ocfs2fs/vdisk2 -force
Now formatting voting disk: /u01/ocfs2fs/vdisk2
successful addition of votedisk /u01/ocfs2fs/vdisk2.

chown oracle:oinstall /u01/ocfs2fs/vdisk2
chmod 775 /u01/ocfs2fs/vdisk2

[root@rhel1 bin]# /etc/init.crs start
[root@rhel1 bin]# ./crsctl query css votedisk
 0.     0    /u01/ocfs2fs/vdisk
 1.     0    /u01/ocfs2fs/vdisk2

注意:votedisk可以有多个成员。add voting disk必须是所有服务都关闭的情况下完成。创建的votedisk的个数应该是奇数,只有满足一半以上的votedisk是正常的crs才能正常运行。例如如果有4个votedisk,那么坏了1个可以正常运行,坏了2个就不能正常运行了。如果有5个的话,坏了3个就不能正常运行了。

添加OCR镜像:
[root@rhel1 bin]#
touch /u01/ocfs2fs/ocr2
[root@rhel1 bin]# ./ocrconfig -replace ocrmirror /u01/ocfs2fs/ocr2
[root@rhel1 bin]# ./ocrcheck
Status of Oracle Cluster Registry is as follows :
         Version                  :          2
         Total space (kbytes)     :     262120
         Used space (kbytes)      :       2756
         Available space (kbytes) :     259364
         ID                       : 2062708016
         Device/File Name         : /u01/ocfs2fs/ocr
                                    Device/File integrity check succeeded
         Device/File Name         : /u01/ocfs2fs/ocr2
                                    Device/File integrity check succeeded

         Cluster registry integrity check succeeded

注意:add ocr可以是在线完成。ocr最多只能有2个,一个primary ocr,一个mirror ocr。

删除OCR镜像:
[root@rhel1 bin]# ./ocrconfig -replace ocrmirror
[root@rhel1 bin]# ./ocrcheck
Status of Oracle Cluster Registry is as follows :
         Version                  :          2
         Total space (kbytes)     :     262120
         Used space (kbytes)      :       2756
         Available space (kbytes) :     259364
         ID                       : 2062708016
         Device/File Name         : /u01/ocfs2fs/ocr
                                    Device/File integrity check succeeded

                                    Device/File not configured

         Cluster registry integrity check succeeded

[root@rhel1 bin]# cat /etc/oracle/ocr.loc
#Device/file /u01/ocfs2fs/ocr2 being deleted
ocrconfig_loc=/u01/ocfs2fs/ocr

删除Voting Disk:
[root@rhel1 bin]# ./crsctl delete css votedisk /u01/ocfs2fs/vdisk2
Cluster is not in a ready state for online disk removal
[root@rhel1 bin]# ./crsctl stop crs
Stopping resources. This could take several minutes.
Successfully stopped CRS resources.
Stopping CSSD.
Shutting down CSS daemon.
Shutdown request successfully issued.

[root@rhel1 bin]#
./crsctl delete css votedisk /u01/ocfs2fs/vdisk2
Cluster is not in a ready state for online disk removal
[root@rhel1 bin]# ./crsctl delete css votedisk /u01/ocfs2fs/vdisk2 -force
successful deletion of votedisk /u01/ocfs2fs/vdisk2.
[root@rhel1 bin]# ./crsctl query css votedisk
 0.     0    /u01/ocfs2fs/vdisk

located 1 votedisk(s).

备份、恢复Voting Disk:
[root@rhel1 bin]# ./crsctl check crs
Failure 1 contacting CSS daemon
Cannot communicate with CRS
Cannot communicate with EVM

[root@rhel1 bin]#
dd if=/u01/ocfs2fs/vdisk f=/home/oracle/vdisk_bak     //备份,ocfs2也可直接copy
20000+0 records in
20000+0 records out
10240000 bytes (10 MB) copied, 0.301106 seconds, 34.0 MB/s

[root@rhel1 bin]# rm -rf /u01/ocfs2fs/vdisk
[root@rhel1 bin]# dd if=/home/oracle/vdisk_bak f=/u01/ocfs2fs/vdisk     //恢复,ocfs2也可直接copy
20000+0 records in
20000+0 records out
10240000 bytes (10 MB) copied, 0.173678 seconds, 59.0 MB/s

[root@rhel1 bin]# chown oracle:oinstall /u01/ocfs2fs/vdisk
[root@rhel1 bin]# chmod 775 /u01/ocfs2fs/vdisk
[root@rhel1 bin]# /etc/init.d/init.crs start
Startup will be queued to init within 30 seconds.
[root@rhel1 bin]# ./crsctl check crs
CSS appears healthy
CRS appears healthy
EVM appears healthy

备份、恢复OCR:
备份:
我们在对集群做任何大的操作的时候,例如,Clusterware升级、环境迁移等都要对Votedisk和OCR进行备份,上面介绍了Votedisk的备份方法,这里介绍一下有关OCR的备份和恢复。
OCR有一套自动备份机制,包含如下的规则:
1.每4个小时自动生成一份OCR备份,并保留最后3个备份。
2.CRSD进程还会在每天开始时生成OCR备份,并保留最后2个备份。
3.CRSD进程还会在每周开始时生成OCR备份,并保留最后2个备份。

请注意:OCR自动备份只会保留在其中一个节点,并不是每个节点都存在自动备份。
通过OCRCONFIG可以查看到OCR自动备份的内容:
[root@rhel1 ~]# /oracle/app/crs/bin/ocrconfig -showbackup

rhel1     2010/10/26 05:20:57     /oracle/app/crs/cdata/crs

rhel1     2010/10/26 01:20:56     /oracle/app/crs/cdata/crs

rhel2     2010/10/24 22:34:18     /oracle/app/crs/cdata/crs

rhel1     2010/10/26 01:20:56     /oracle/app/crs/cdata/crs

rhel1     2010/10/22 23:54:15     /oracle/app/crs/cdata/crs

可以看到ocr备份在rhel1,rhel2都有分布。
切换到自动备份目录可以看到一共有7个备份,分别是每4小时的备份,保留最近的3个备份,当天生成的OCR备份,保留最近2个备份。还有就是每周生成的备份,保留最近的2个。总共7个。
[root@rac1 ~]# ls -l /oracle/app/crs/cdata/crs
total 23560
-rw-r--r-- 1 root root 4812800 Oct 26 05:20 backup00.ocr
-rw-r--r-- 1 root root 4812800 Oct 26 01:20 backup01.ocr
-rw-r--r-- 1 root root 4812800 Oct 24 15:54 backup02.ocr
-rw-r--r-- 1 root root 4812800 Oct 27 02:10 day_.ocr
-rw-r--r-- 1 root root 4812800 Oct 26 01:20 day.ocr
-rw-r--r-- 1 root root 4812800 Oct 29 23:04 week_.ocr
-rw-r--r-- 1 root root 4812800 Oct 22 23:54 week.ocr

除了上面的自动备份外,在执行大的操作的时候还需要进行手动备份,通过OCRCONFIG命令来执行逻辑手动备份:
[root@rhel1 ~]# /oracle/app/crs/bin/ocrconfig -export ocr_logical_backup -s online
[root@rhel1 ~]# ls -l ocr_logical_backup
-rw-r--r-- 1 root root 103969 Nov  5 20:10 ocr_logical_backup

如果是在线逻辑备份OCR,加入 -s online参数,确保OCR的一致性。
验证OCR的一致性使用:
/oracle/app/crs/bin/cluvfy comp ocr -n all

另外如果是使用ocfs2集群文件系统,我们可以直接对ocr,vdisk磁盘文件进行拷贝。如果是裸设备使用dd命令来备份ocr也是可以的。

恢复:
1.还原自动备份文件:
[root@rhel1 bin]# ./crsctl stop crs
Stopping resources. This could take several minutes.
Successfully stopped CRS resources.
Stopping CSSD.
Shutting down CSS daemon.
Shutdown request successfully issued.

[root@rhel1 bin]# cat /etc/oracle/ocr.loc
#Device/file /u01/ocfs2fs/ocr2 being deleted
ocrconfig_loc=/u01/ocfs2fs/ocr
local_only=false

[root@rhel1 bin]# mv /u01/ocfs2fs/ocr /u01/ocfs2fs/ocr_bak
[root@rhel1 crs_1]# cd cdata
[root@rhel1 cdata]# cd crs
[root@rhel1 crs]# ll
total 23144
-rwxrwxr-x 1 oracle dba  3514368 Mar  1 11:00 13968559
-rwxrwxr-x 1 oracle dba  3514368 Mar  1 07:00 33426182
-rw-r--r-- 1 root   root 3182592 Mar  8 15:17 34809936
-rwxrwxr-x 1 oracle dba  3514368 Feb 27 09:38 backup00.ocr
-rwxrwxr-x 1 oracle dba  3514368 Feb  8 06:02 backup01.ocr
-rwxrwxr-x 1 oracle dba  2142208 Nov  8 19:25 backup02.ocr
-rwxrwxr-x 1 oracle dba  2142208 Nov  8 19:25 day.ocr
-rwxrwxr-x 1 oracle dba  2142208 Nov  8 19:25 week.ocr

[root@rhel1 crs]# cd ../../bin
[root@rhel1 bin]# ./ocrconfig -restore /u01/app/oracle/crs_1/cdata/crs/backup02.ocr
PROT-16: Internal Error
[root@rhel1 bin]#
touch /u01/ocfs2fs/ocr
[root@rhel1 bin]#
./ocrconfig -restore /u01/app/oracle/crs_1/cdata/crs/backup02.ocr
[root@rhel1 bin]# ./crsctl start crs
Attempting to start CRS stack
The CRS stack will be started shortly
[root@rhel1 bin]# ./crsctl check crs
CSS appears healthy
CRS appears healthy
EVM appears healthy

2.恢复逻辑备份:
[root@rhel1 ~]# /oracle/app/crs/bin/ocrconfig -import logical_backup.ocr

在对Clusterware做大操作之前都应该养成备份OCR和VOTEDISK的好习惯,并且物理备份和逻辑备份都要有。

注意:ocrconfig在使用-export和-import备份恢复的时候也需要停止crs的运行,来完成。如果想在在线完成这个操作的话,需要在-export的时候指定:-export <filename> [-s online]。

其他:
./ocrconfig -showbackup     //查看自动备份。
./ocrconfig -backuploc <dirname>     //改变自动备份目录。

//心跳超时时间
[oracle@rhel1 bin]$ ./crsctl get css misscount
60
//查看crs css evm对应模块
crsctl lsmodules css|crs|evm



向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI