解析OCR与Voting Disk以及其管理

数据库 Oracle
Oracle Clusterware由2部分组成,分别是Voting Disk和 OCR。本文详细论述了Voting Disk和OCR的配置过程和一些与之相关的知识,相信会让读者获益匪浅的。

Voting DiskOCR是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:

  1. [root@rhel1 bin]#./crsctl add css votedisk /u01/ocfs2fs/vdisk2  
  2.  
  3. Cluster is not in a ready state for online disk addition  
  4.  
  5. [root@rhel1 bin]#./crsctl add css votedisk /u01/ocfs2fs/vdisk2-force  
  6.  
  7. Now formatting voting disk: /u01/ocfs2fs/vdisk2   
  8.  
  9. successful addition of votedisk /u01/ocfs2fs/vdisk2. chown oracle:oinstall /u01/ocfs2fs/vdisk2  
  10.  
  11. chmod 775 /u01/ocfs2fs/vdisk2  
  12.  
  13. [root@rhel1 bin]# /etc/init.crs start  
  14.  
  15. [root@rhel1 bin]#./crsctl query css votedisk  
  16.  
  17. 0. 0 /u01/ocfs2fs/vdisk  
  18.  
  19. 1. 0 /u01/ocfs2fs/vdisk2 

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

#p#

添加OCR镜像:

  1. [root@rhel1 bin]# touch /u01/ocfs2fs/ocr2  
  2.  
  3. [root@rhel1 bin]#./ocrconfig -replace ocrmirror /u01/ocfs2fs/ocr2   
  4.  
  5. [root@rhel1 bin]#./ocrcheck   
  6.  
  7. Status of Oracle Cluster Registry is as follows :   
  8.  
  9. Version : 2  
  10.  
  11. Total space (kbytes) : 262120   
  12.  
  13. Used space (kbytes) : 2756   
  14.  
  15. Available space (kbytes) : 259364   
  16.  
  17. ID : 2062708016   
  18.  
  19. Device/File Name : /u01/ocfs2fs/ocr   
  20.  
  21. Device/File integrity check succeeded   
  22.  
  23. Device/File Name : /u01/ocfs2fs/ocr2   
  24.  
  25. Device/File integrity check succeeded   
  26.  
  27. Cluster registry integrity check succeeded  

注意:add ocr可以是在线完成。

删除OCR镜像:

  1. [root@rhel1 bin]#./ocrconfig -replace ocrmirror   
  2.  
  3. [root@rhel1 bin]#./ocrcheck   
  4.  
  5. Status of Oracle Cluster Registry is as follows :   
  6.  
  7. Version : 2   
  8.  
  9. Total space (kbytes) : 262120   
  10.  
  11. Used space (kbytes) : 2756   
  12.  
  13. Available space (kbytes) : 259364   
  14.  
  15. ID : 2062708016   
  16.  
  17. Device/File Name : /u01/ocfs2fs/ocr   
  18.  
  19. Device/File integrity check succeeded   
  20.  
  21. Device/File not configured   
  22.  
  23. Cluster registry integrity check succeeded   
  24.  
  25. [root@rhel1 bin]#cat /etc/oracle/ocr.loc   
  26.  
  27. #Device/file /u01/ocfs2fs/ocr2 being deleted   
  28.  
  29. ocrconfig_loc=/u01/ocfs2fs/ocr 

删除Voting Disk:

  1. [root@rhel1 bin]#./crsctl delete css votedisk /u01/ocfs2fs/vdisk2   
  2.  
  3. Cluster is not in a ready state for online disk removal   
  4.  
  5. [root@rhel1 bin]#./crsctl stop crs   
  6.  
  7. Stopping resources. This could take several minutes.   
  8.  
  9. Successfully stopped CRS resources.   
  10.  
  11. Stopping CSSD.   
  12.  
  13. Shutting down CSS daemon.   
  14.  
  15. Shutdown request successfully issued.   
  16.  
  17. [root@rhel1 bin]# ./crsctl delete css votedisk /u01/ocfs2fs/vdisk2  
  18.  
  19. Cluster is not in a ready state for online disk removal   
  20.  
  21. [root@rhel1 bin]#./crsctl delete css votedisk /u01/ocfs2fs/vdisk2-force  
  22.  
  23. successful deletion of votedisk /u01/ocfs2fs/vdisk2.  
  24.  
  25. [root@rhel1 bin]#./crsctl query css votedisk   
  26.  
  27. 0. 0 /u01/ocfs2fs/vdisk   
  28.  
  29. located 1 votedisk(s). 

 #p#

备份、恢复Voting Disk:

  1. [root@rhel1 bin]#./crsctl check crs  
  2.  
  3. Failure 1 contacting CSS daemon  
  4.  
  5. Cannot communicate with CRS  
  6.  
  7. Cannot communicate with EVM  
  8.  
  9. [root@rhel1 bin]# dd if=/u01/ocfs2fs/vdisk f=/home/oracle/vdisk_bak //备份,ocfs2也可直接copy  
  10.  
  11. 20000+0 records in   
  12.  
  13. 20000+0 records out   
  14.  
  15. 10240000 bytes (10 MB) copied, 0.301106 seconds, 34.0 MB/s  
  16.  
  17. [root@rhel1 bin]# rm -rf /u01/ocfs2fs/vdisk  
  18.  
  19. [root@rhel1 bin]#dd if=/home/oracle/vdisk_bak f=/u01/ocfs2fs/vdisk //恢复,ocfs2也可直接copy  
  20.  
  21. 20000+0 records in  
  22.  
  23. 20000+0 records out  
  24.  
  25. 10240000 bytes (10 MB) copied, 0.173678 seconds, 59.0 MB/s  
  26.  
  27. [root@rhel1 bin]# chown oracle:oinstall /u01/ocfs2fs/vdisk  
  28.  
  29. [root@rhel1 bin]# chmod 775 /u01/ocfs2fs/vdisk   
  30.  
  31. [root@rhel1 bin]#/etc/init.d/init.crs start   
  32.  
  33. Startup will be queued to init within 30 seconds.   
  34.  
  35. [root@rhel1 bin]#./crsctl check crs   
  36.  
  37. CSS appears healthy   
  38.  
  39. CRS appears healthy   
  40.  
  41. EVM appears healthy 

备份、恢复OCR:

  1. [root@rhel1 bin]# ./crsctl stop crs   
  2.  
  3. Stopping resources. This could take several minutes.   
  4.  
  5. Successfully stopped CRS resources.   
  6.  
  7. Stopping CSSD.   
  8.  
  9. Shutting down CSS daemon.   
  10.  
  11. Shutdown request successfully issued.   
  12.  
  13. [root@rhel1 bin]# cat /etc/oracle/ocr.loc   
  14.  
  15. #Device/file /u01/ocfs2fs/ocr2 being deleted   
  16.  
  17. ocrconfig_loc=/u01/ocfs2fs/ocr   
  18.  
  19. local_only=false   
  20.  
  21. [root@rhel1 bin]# mv /u01/ocfs2fs/ocr /u01/ocfs2fs/ocr_bak   
  22.  
  23. [root@rhel1 crs_1]# cd cdata   
  24.  
  25. [root@rhel1 cdata]# cd crs   
  26.  
  27. [root@rhel1 crs]# ll   
  28.  
  29. total 23144   
  30.  
  31. -rwxrwxr-x 1 oracle dba 3514368 Mar 1 11:00 13968559   
  32.  
  33. -rwxrwxr-x 1 oracle dba 3514368 Mar 1 07:00 33426182   
  34.  
  35. -rw-r--r-- 1 root root 3182592 Mar 8 15:17 34809936   
  36.  
  37. -rwxrwxr-x 1 oracle dba 3514368 Feb 27 09:38 backup00.ocr   
  38.  
  39. -rwxrwxr-x 1 oracle dba 3514368 Feb 8 06:02 backup01.ocr   
  40.  
  41. -rwxrwxr-x 1 oracle dba 2142208 Nov 8 19:25 backup02.ocr   
  42.  
  43. -rwxrwxr-x 1 oracle dba 2142208 Nov 8 19:25 day.ocr   
  44.  
  45. -rwxrwxr-x 1 oracle dba 2142208 Nov 8 19:25 week.ocr   
  46.  
  47. [root@rhel1 crs]# cd ../../bin   
  48.  
  49. [root@rhel1 bin]# ./ocrconfig -restore /u01/app/oracle/crs_1/cdata/crs/backup02.ocr   
  50.  
  51. PROT-16: Internal Error   
  52.  
  53. [root@rhel1 bin]#touch /u01/ocfs2fs/ocr   
  54.  
  55. [root@rhel1 bin]#./ocrconfig -restore /u01/app/oracle/crs_1/cdata/crs/backup02.ocr   
  56.  
  57. [root@rhel1 bin]# ./crsctl start crs   
  58.  
  59. Attempting to start CRS stack   
  60.  
  61. The CRS stack will be started shortly   
  62.  
  63. [root@rhel1 bin]# ./crsctl check crs   
  64.  
  65. CSS appears healthy   
  66.  
  67. CRS appears healthy   
  68.  
  69. EVM appears healthy 

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

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

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

【编辑推荐】

  1. 解析OracleOLAP使用MView刷新Cube
  2. 因为Oracle推EF for Oracle引发的口水战
  3. 浅谈禁用以操作系统认证方式登录Oracle数据库
  4. Oracle数据导入MySQL的快捷工具:MySQL Migration Toolkit
责任编辑:赵鹏 来源: CSDN博客
相关推荐

2013-10-11 17:24:47

Linux运维内存管理

2023-11-10 08:03:00

2009-10-10 13:14:53

RHEL进程管理

2010-06-12 13:21:56

UML全称

2009-06-29 17:10:24

什么是JSP

2010-10-09 08:50:16

2016-08-23 10:50:50

WebJavascript缓存

2010-04-27 13:39:05

Oracle OCR镜

2009-12-25 10:44:37

VDSL上网

2023-11-10 16:28:02

TCP窗口

2018-05-23 10:59:14

DNS原理解析

2010-06-17 12:48:08

UML用例模型

2010-07-13 16:24:55

SQL Server快

2009-06-12 11:32:49

Java游戏

2010-08-19 16:47:14

DB2 9.5分区管理

2015-06-17 11:27:47

Hadoop集群管理安全机制

2017-05-03 11:15:09

优化MongoDB数据库

2019-08-29 10:17:42

OracleKfkTOP N

2010-09-16 10:12:55

无线规划

2009-08-24 16:46:58

什么是ASP.NET
点赞
收藏

51CTO技术栈公众号