Oracle:解析OCR与VotingDisk以及其管理

解析OCR与VotingDisk以及其管理

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 //改变自动备份目录。

你可能感兴趣的:(ORACLE_RAC)