Oracle 10g RAC OCR 和 VotingDisk 的备份与恢复

来源:互联网 发布:mac网线接口 编辑:程序博客网 时间:2024/05/21 20:30

Voting Disk

Voting Disk 这个文件主要用于记录节点成员状态,在出现脑裂时,决定那个Partion获得控制权,其他的Partion必须从集群中剔除。Voting disk使用的是一种“多数可用算法”,如果有多个Voting  disk,,则必须一半以上的Votedisk同时使用,Clusterware才能正常使用。 比如配置了4个Votedisk,坏一个Votedisk,集群可以正常工作,如果坏了2个,则不能满足半数以上,集群会立即宕掉,所有节点立即重启,所以如果添加Votedisk,尽量不要只添加一个,而应该添加2个。这点和OCR 不一样。OCR 只需配置一个。

查看votedisk的位置:

[root@rac1 ~]# crsctl query css votedisk

0.    0   /dev/raw/raw2

located 1 votedisk(s).

备份votedisk盘:

[root@raw1 bin]# dd if=/dev/raw/raw2 of=/home/oracle/voting_disk.bak

294912+0 records in

294912+0 records out

恢复votedisk盘:

[root@raw1 bin]# dd if=/home/oracle/voting_disk.bak of=/dev/raw/raw2

294912+0 records in

294912+0 records out

通过Strings 命令来查看 voting disk的内容

[root@raw1 oracle]# strings voting_disk.bak |sort -u

fSLC

ssLckcoT

SslcLlik

sSlcrEp0

}|{z

OCR

Oracle Clusterware把整个集群的配置信息放在共享存储上,这些信息包括了集群节点的列表、集群数据库实例到节点的映射以及CRS应用程序资源信息。存放的位置就在OCR Disk上. 在整个集群中,只有一个节点能对OCR Disk 进行读写操作,这个节点叫作Master Node,所有节点都会在内存中保留一份OCR的拷贝,同时有一个OCR Process 从这个内存中读取内容。 OCR 内容发生改变时,由Master Node的OCR Process负责同步到其他节点的OCR Process。

因为OCR的内容如此重要,所以Oracle 每4个小时对其做一次备份,并且保留最后的3个备份,以及前一天,前一周的最后一个备份。 这个备份由Master Node CRSD进程完成,备份的默认位置是$CRS_HOME/crs/cdata/<cluster_name>目录下,可以通过ocrconfig -backuploc <directory_name> 命令修改到新的目录。 每次备份后,备份文件名自动更改,以反应备份时间顺序,最近一次的备份叫作backup00.ocr。这些备份文件除了保存在本地,DBA还应该在其他存储设备上保留一份,以防止意外的存储故障。

[root@raw1 crs]# pwd

/u01/app/oracle/product/crs/cdata/crs

[root@raw1 crs]# ls -lrt

total 22632

-rw-r--r--  1 root root 4595712 Mar  9 01:03 backup02.ocr

-rw-r--r--  1 root root 4620288 Mar  9 21:20 backup01.ocr

-rw-r--r--  1 root root 4632576 Apr  8 19:46 backup00.ocr

-rw-r--r--  1 root root 4632576 Apr  8 19:46 day.ocr

-rw-r--r--  1 root root 4632576 Apr  8 19:46 week.ocr

在安装clusterware过程中,如果选择External Redundancy冗余方式,则只能输入一个OCR磁盘位置。 但是Oracle允许配置两个OCR 磁盘互为镜像,以防止OCR 磁盘的单点故障。 OCR 磁盘和Votedisk磁盘不一样,OCR磁盘最多只能有两个,一个Primary OCR 和一个Mirror OCR。

Oracle 推荐在对集群做调整时,比如增加,删除节点之前,修改RAC IP之前,对OCR做一个备份,可以使用export 备份到指定文件,如果做了replace或者restore 等操作,Oracle 建议使用 cluvfy comp ocr -n all 命令来做一次全面的检查。对OCR的备份与恢复,我们可以使用ocrconfig 命令。

[root@raw1 bin]# ./ocrconfig --help

Name:

        ocrconfig - Configuration tool for Oracle Cluster Registry.

Synopsis:

        ocrconfig [option]

        option:

                -export <filename> [-s online]

                                                    - Export cluster register contents to a file

                -import <filename>                  - Import cluster registry contents from a file

                -upgrade [<user> [<group>]]

                                                    - Upgrade cluster registry from previous version

                -downgrade [-version <version string>]

                                                    - Downgrade cluster registry to the specified version

                -backuploc <dirname>                - Configure periodic backup location

                -showbackup                         - Show backup information

                -restore <filename>                 - Restore from physical backup

                -replace ocr|ocrmirror [<filename>] - Add/replace/remove a OCR device/file

                -overwrite                          - Overwrite OCR configuration on disk

                -repair ocr|ocrmirror <filename>    - Repair local OCR configuration

                -help                               - Print out this help information

Note:

        A log file will be created in

        $ORACLE_HOME/log/<hostname>/client/ocrconfig_<pid>.log. Please ensure

        you have file creation privileges in the above directory before

        running this tool.

1.  用导出导入备份恢复OCR

1首先关闭所有节点的CRS

[root@raw1 bin]# ./crsctl stop crs

Stopping resources.

Successfully stopped CRS resources

Stopping CSSD.

Shutting down CSS daemon.

Shutdown request successfully issued.

2root用户导出OCR内容

[root@raw1 bin]# ./ocrconfig -export /u01/ocr.exp

3重启CRS

[root@raw1 bin]# ./crsctl start crs

Attempting to start CRS stack

The CRS stack will be started shortly

4检查CRS状态

[root@raw1 bin]# ./crsctl check crs

CSS appears healthy

CRS appears healthy

EVM appears healthy

5)破坏OCR内容

[root@raw1 bin]# dd if=/dev/zero of=/dev/raw/raw1 bs=1024 count=102400

102400+0 records in

102400+0 records out

6检查OCR一致性

[root@raw1 bin]# ./ocrcheck

PROT-601: Failed to initialize ocrcheck

7)使用cluvfy工具检查一致性

[root@raw1 cluvfy]# ./runcluvfy.sh comp ocr -n all

Verifying OCR integrity

Unable to retrieve nodelist from Oracle clusterware.

Verification cannot proceed.

8使用Import恢复OCR 内容

[root@raw1 bin]# ./ocrconfig -import /u01/ocr.exp

注意: 使用restore选项只能导入OCR自动产生的物理备份,

         import选项只能导入通过export选项导出的的逻辑备份。

9)再次检查OCR

[root@raw1 bin]# ./ocrcheck

Status of Oracle Cluster Registry is as follows :

         Version               :          2

         Total space (kbytes)     :     147352

         Used space (kbytes)    :       4364

         Available space (kbytes) :     142988

         ID                    :  610419116

         Device/File Name        : /dev/raw/raw1

                                    Device/File integrity check succeeded

                                    Device/File not configured

         Cluster registry integrity check succeeded

10使用cluvfy工具检查

[root@raw1 cluvfy]# ./runcluvfy.sh comp ocr -n all

2. 自动备份恢复OCR

1)关闭运行在集群数据库的所有节点上的CRS服务程序

        /etc/init.d/init.crs stop

在Oracle 11gR2 中已经没有了init.crs 命令了。 只能通过

       #crsctl stop crs

命令来关闭CRS.

2.通过ocrconfig showbackup选项查看最近的备份

[root@racnode1 ~]# ocrconfig -showbackup

racnode1     2010/11/22 13:30:27     /u01/app/11.2.0/grid/cdata/racnode-cluster/backup00.ocr

racnode1     2010/11/22 09:30:27     /u01/app/11.2.0/grid/cdata/racnode-cluster/backup01.ocr

racnode1     2010/11/22 05:30:26     /u01/app/11.2.0/grid/cdata/racnode-cluster/backup02.ocr

racnode1     2010/11/21 05:30:23     /u01/app/11.2.0/grid/cdata/racnode-cluster/day.ocr

racnode1     2010/11/11 03:35:10     /u01/app/11.2.0/grid/cdata/racnode-cluster/week.ocr

3)通过ocrconfigrestoreimport选项导入OCR数据

ocrconfig  -restore  filename_location                          

如:

ocrconfig  -restore  /u01/app/11.2.0/grid/cdata/racnode-cluster/backup00.ocr

注意: 使用restore选项只能导入OCR自动产生的物理备份,

         import选项只能导入通过export选项导出的的逻辑备份。

4检查CRS

[root@raw1 bin]# ./ocrcheck

使用cluvfy工具检查

[root@raw1 cluvfy]# ./runcluvfy.sh comp ocr -n all

5)在所有节点上重新启动CRS                                             

      /etc/init.d/init.crs   start

在Oracle 11gR2使用:#crsctl start crs 命令来启动CRS.