管理oracle clusterware OCR

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

 

If you already mirror the OCR, then you do not need to add an OCR location; Oracle automatically manages two OCRs when it mirrors the OCR. Oracle RAC environments do not support more than two OCRs, a primary OCR and a second OCR.

 

ocrconfig语法

[root@rac1 ~]# ocrconfig -help 

Nameocrconfig - 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

NoteA 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.

 

自动备份 OCR

– 每 小时:CRS 会保留最后 个副本。

– 每天结束时:CRS 会保留最后 个副本。

– 每周结束时:CRS 会保留最后 个副本。

  自动备份由Master Node CRSD进程完成,备份的默认位置是$CRS_HOME/crs/cdata/<cluster_name>目录下,可以通过ocrconfig -backuploc <directory_name> 命令修改到新的目录。

 

示例:——显示备份信息

[root@rac1 ~]# ocrconfig -showbackup

  rac1     2012/02/20 204532     /u01/crs1020/cdata/crs

  rac1     2012/02/19 164547     /u01/crs1020/cdata/crs

  rac1     2012/02/18 221840     /u01/crs1020/cdata/crs

  rac1     2012/02/19 164547     /u01/crs1020/cdata/crs

rac1     2012/02/19 164547     /u01/crs1020/cdata/crs 

[root@rac1 ~]# ll /u01/crs1020/cdata/crs/ 

total 28296 

-rw-r——r—— 1 root root 4816896 Feb 20 2045 backup00.ocr 

-rw-r——r—— 1 root root 4816896 Feb 19 1645 backup01.ocr 

-rw-r——r—— 1 root root 4816896 Feb 18 2218 backup02.ocr 

-rw-r——r—— 1 root root 4816896 Feb 20 2045 day_.ocr 

-rw-r——r—— 1 root root 4816896 Feb 19 1645 day.ocr 

-rw-r——r—— 1 root root 4816896 Feb 19 1645 week.ocr

 

——更改备份位置

[root@rac1 ~]# ocrconfig -backuploc /oracle/backup/ocr

 

使用物理备份恢复 OCR 

1. 找到物理备份:$ ocrconfig showbackup 

2. 检查其内容:# ocrdump file_name backupfile 

3. 停止所有节点上的 Oracle Clusterware# crsctl stop crs

4. 还原 OCR 物理备份:# ocrconfig restore <CRS HOME>/cdata/jfv_clus/day.ocr 

5. 重新启动所有节点上的 Oracle Clusterware# crsctl start crs 

6. 检查 OCR 完整性:$ cluvfy comp ocr -n all

 

示例:

——找到物理备份:[root@rac1 ~]# ocrconfig -showbackup

——检查其内容,dump不成功:

[root@rac1 crs]# ocrdump  -backupfile day.ocr 

PROT-302: Failed to initialize ocrdump

——停止所有节点上的 Oracle Clusterware

[root@rac2 ~]# crsctl stop crs [root@rac1 ~]# crsctl stop crs

——还原 OCR 物理备份:

[root@rac1 ~]# ocrconfig -restore /u01/crs1020/cdata/crs/backup00.ocr

——重新启动所有节点上的 Oracle Clusterware

[root@rac2 ~]# crsctl start crs 

[root@rac1 ~]# crsctl start crs

 

  ——检查 OCR 完整性:RACDB1@rac1 /home/oracle$ cluvfy comp ocr -n all

 

手动备份 OCR

每天都应将 OCR 自动备份

在进行重大更改之前和之后应对 OCR 进行逻辑备份:

# ocrconfig export file name

确保还原与当前系统配置相匹配的 OCR 备份。

 

使用逻辑备份恢复 OCR 

1. 找到使用 OCR 导出文件创建的逻辑备份。

2. 停止所有节点上的 Oracle Clusterware# crsctl stop crs 

3. 还原逻辑 OCR 备份:# ocrconfig import /shared/export/ocrback.dmp 

4. 重新启动所有节点上的 Oracle Clusterware# crsctl start crs 

5. 检查 OCR 完整性:$ cluvfy comp ocr -n all

 

修复 OCR 配置

添加,替换,删除OCR配置或OCR配置更改时,如果某些节点停止了,需要在这些节点上修复OCR配置。

 

模拟修复过程:

1. 停止节点 上的 Oracle Clusterware# crsctl stop crs 

2.  从节点 添加 OCR 镜像:# ocrconfig replace ocrmirror /dev/raw/raw8 

3.  修复节点 上的 OCR 镜像位置:# ocrconfig repair ocrmirror /dev/raw/raw8 

4.  启动节点 上的 Oracle Clusterware# crsctl start crs

 

更改 OCR 文件位置

示例:

——查看是否有OCR备份

[root@rac1 ~]# ocrconfig -showbackup

  rac1     2012/02/19 164547     /u01/crs1020/cdata/crs

  rac1     2012/02/18 221840     /u01/crs1020/cdata/crs

  rac1     2012/02/12 195233     /u01/crs1020/cdata/crs

  rac1     2012/02/18 221840     /u01/crs1020/cdata/crs

  rac1     2012/02/19 164547     /u01/crs1020/cdata/crs

 

——查看当前OCR配置

[root@rac1 ~]# ocrcheck 

Status of Oracle Cluster Registry is as follows 

Version                  : 

Total space kbytes)     :     104344 

Used space kbytes)      :       4588 

Available space kbytes) :      99756 

ID                       : 2037585895 

Device/File Name         : /dev/raw/raw1 

Device/File integrity check succeeded

  Device/File not configured

  Cluster registry integrity check succeeded

 

  ——添加OCR镜像,如果只有一个OCR文件,是不能直接改变这个OCR文件配置的,必须先添加镜像后再修改。

 

  [root@rac1 ~]# ocrconfig -replace ocrmirror /dev/raw/raw8

 

——确认添加成功

[root@rac1 ~]# ocrcheck 

Status of Oracle Cluster Registry is as follows 

Version                  :          

Total space kbytes)     :     104344 

Used space kbytes)      :       4588 

Available space kbytes) :      99756 

ID                       : 2037585895 

Device/File Name         : /dev/raw/raw1 

Device/File integrity check succeeded 

Device/File Name         : /dev/raw/raw8 

Device/File integrity check succeeded

  Cluster registry integrity check succeeded

 

——更改Primary OCR位置,并进行确认

[root@rac1 ~]# ocrconfig -replace ocr /dev/raw/raw5  ——我这里raw5存储太小了(PROT-22: Storage too small

 

[root@rac1 ~]# ocrcheck 

Status of Oracle Cluster Registry is as follows 

Version                  :          

Total space kbytes)     :     104344 

Used space kbytes)      :       4588 

Available space kbytes) :      99756 

ID                       : 2037585895 

Device/File Name         : /dev/raw/raw5 

Device/File integrity check succeeded 

Device/File Name         : /dev/raw/raw8 

Device/File integrity check succeeded

  Cluster registry integrity check succeeded

 

OCR 注意事项

如果使用裸设备还原 OCR 文件,则在执行添加或替换操作之前需要先确保这些文件已存在。

  使用 ocrconfig 时,必须具有 root 用户身份才能添加、替换或删除 OCR 文件。

  添加或替换 OCR 文件时,其镜像需要处于联机状态。

  如果删除了 OCR 主文件,则 OCR 镜像文件将成为主文件。

任何时候都不能删除最后一个保留的 OCR 文件。

 

转自:http://www.codesky.net/article/201202/166656.html

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值