Voting Disk和OCR介绍

Voting Disk和OCR是Oracle Clusterware的2部分。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时,RAC中的所有资源都必须停止。

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默认的备份路径为$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

注意:add voting disk必须是所有服务都关闭的情况下完成。

添加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镜像:

[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:

[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

查看和改变自动备份目录的命令如下:

./ocrconfig -showbackup //查看自动备份。

./ocrconfig -backuploc //改变自动备份目录。












Voting disk(表决磁盘方面):
Voting disk记录节点成员信息,如包含哪些节点成员、节点的添加删除信息记录,大小为20MB
查看voting disk位置:crsctl query css votedisk
    $ crsctl query css votedisk
    0.     0    /dev/rhdisk3
如果CRS安装过程失败,需要重新安装则需要初始化voting disk盘,可用DD或重建卷
    dd if=/dev/zero of=/dev/rhdisk3 bs=8192 count=2560
备份votedisk: dd if=/dev/rhdisk3 of=/tmp/votedisk.bak
恢复votedisk: dd if=/tmp/votedisk.bak of=/dev/rhdisk3
添加voting disk镜像盘:
crsctl add css votedisk /dev/rhdisk7 -force
删除voting disk镜像盘
crsctl delete css votedisk /dev/rhdisk7 -force


OCR方面
OCR记录节点成员的配置信息,如database、ASM、instance、listener、VIP等CRS资源的配置信息,可存储于裸设备或者群集文件系统上,推荐设置大小为100MB
如以RAW的方式,则划分一个RAW,例如:/dev/rhdisk2
如果CRS安装过程失败,需要重新安装则需要初始化OCR盘(RAW方式),可用DD或重建卷
    dd if=/dev/zero of=/dev/rhdisk2 bs=8192 count=12800
Oracle每四个小时自动发起备份,并保存三个版本,但只存在一个节点上
$ ocrconfig -showbackup
poaisdb1     2008/04/10 22:53:29     /u01/app/oracle/product/10.2.0/crs/cdata/crs
poaisdb1     2008/04/10 18:53:28     /u01/app/oracle/product/10.2.0/crs/cdata/crs
poaisdb1     2008/04/10 14:53:27     /u01/app/oracle/product/10.2.0/crs/cdata/crs
poaisdb1     2008/04/09 06:53:20     /u01/app/oracle/product/10.2.0/crs/cdata/crs
poaisdb2     2008/04/03 03:31:28     /u01/app/oracle/product/10.2.0/crs/cdata/crs
恢复OCR:ocrconfig -restore /u01/app/oracle/product/10.2.0/crs/cdata/crs/backup01.ocr
OCR手动导出:ocrconfig -export /tmp/ocr_bak
OCR手动导入:ocrconfig -import /tmp/ocr_bak
添加OCR镜像盘:
1.用crsctl stop crs停掉CRS服务
2.创建用于镜像OCR的RAW设备,比如为:/dev/rhdisk6
3.用ocrconfig –export 导出OCR的信息
4.编辑/etc/oracle/ocr.loc文件,添加ocrmirrorconfig_loc行
$ cat ocr.loc
ocrconfig_loc=/dev/rhdisk2
ocrmirrorconfig_loc=/dev/rhdisk6
local_only=FALSE
5.用ocrconfig –import 导入OCR的信息
6.检查ocr设置信息
$ ocrcheck
Status of Oracle Cluster Registry is as follows :
         Version                  :          2
         Total space (kbytes)     :     103724
         Used space (kbytes)      :       3824
         Available space (kbytes) :      99900
         ID                       : 1086971606
         Device/File Name         : /dev/rhdisk2    Device/File integrity check succeeded
         Device/File Name         : /dev/rhdisk6    Device/File integrity check succeeded
         Cluster registry integrity check succeeded
7.最后用crsctl start crs启动CRS服务



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值