OCRCONFIG工具主要功能是备份、恢复ocr的。
虽然用oracle用户可以直接运行ocrconfig,但是大部分命令还需要root用户才有权限执行:
bash-2.03$ ocrconfig
名称:
ocrconfig - Oracle集群注册表的配置工具。
概要:
ocrconfig [option]
option:
-export <filename> [-s online]
-将集群注册表内容导出到文件
-import <filename> -从文件导入集群注册表内容
-upgrade [<user> [<group>]]
-从早期版本升级集群注册表
-downgrade [-version <version string>]
-将集群注册表降级到指定版本
-backuploc <dirname> -配置定期备份位置
-showbackup -显示备份信息
-restore <filename> -从物理备份中恢复
-replace ocr|ocrmirror [<filename>] -添加/替换/删除OCR设备/文件
-overwrite -覆盖磁盘上的OCR配置
-repair ocr|ocrmirror <filename> -修复本地OCR配置
-help -打印此帮助信息
注:
将在
$ORACLE_HOME/log/<hostname>/client/ocrconfig_<pid>.log中创建日志文件。在
运行此工具前,请确保
您具有在以上目录中创建文件的权限。
bash-2.03$ ocrconfig -export /export/home/oracle/ocr.log
PROT-20:权限不足,无法继续。要求用户具有权限
bash-2.03$ su -
Password:
Sun Microsystems Inc. SunOS 5.8 Generic Patch October 2001
You have new mail.
# bash
bash-2.03# /data/oracle/product/10.2/crs/bin/ocrconfig -export /export/home/oracle/ocr.log
通过export方式可以将ocr的内容导出到文件:
bash-2.03$ strings ocr.log
SYSTEM
root
_other
DATABASE
root
_other
root
_other
SYSTEM.css
root
_other
SYSTEM.language
AMERICAN_AMERICA.WE8ISO8859P1
root
_other
SYSTEM.version
root
_other
SYSTEM.versionstring
10G Release 2
root
_other
SYSTEM.ORA_CRS_HOME
/data/oracle/product/10.2/crs
root
_other
SYSTEM.local_only
false
root
_other
SYSTEM.evm
root
_other
SYSTEM.crs
root
_other
SYSTEM.OCR
root
_root
DATABASE.NODEAPPS
oracle
_oinstall
DATABASE.VIP_RANGE
oracle
_oinstall
DATABASE.LOG
?oracle
_oinstall
DATABASE.ASM
oracle
_oinstall
DATABASE.DATABASES
oracle
_oinstall
DATABASE.ONS_HOSTS
oracle
_oinstall
.
.
.
DATABASE.NODEAPPS.racnode1.VIP.IP
racnode1-vip
?root
_other
DATABASE.NODEAPPS.racnode1.VIP.NETMASK
255.255.255.0
?root
_other
DATABASE.NODEAPPS.racnode1.VIP.INTERFACES
?root
_other
DATABASE.NODEAPPS.racnode2.VIP.IP
racnode2-vip
?root
_other
DATABASE.NODEAPPS.racnode2.VIP.NETMASK
255.255.255.0
?root
_other
DATABASE.NODEAPPS.racnode2.VIP.INTERFACES
?root
_other
DATABASE.DATABASES.testrac.INSTANCE.testrac1
testrac1
oracle
_dba
DATABASE.DATABASES.testrac.INSTANCE.testrac2
testrac2
oracle
_dba
SYSTEM.css.interfaces.global.ce0.172|d25|d0|d0
oracle
_oinstall
SYSTEM.css.interfaces.global.ce1.10|d0|d0|d0
oracle
_oinstall
SYSTEM.crs.10.2.0.4
root
_other
DATABASE.DATABASES.testrac.INSTANCE.testrac1.NODE
racnode1
oracle
_dba
DATABASE.DATABASES.testrac.INSTANCE.testrac1.ENABLED
true
oracle
_dba
DATABASE.DATABASES.testrac.INSTANCE.testrac1.ENVIRONMENT
oracle
_dba
DATABASE.DATABASES.testrac.INSTANCE.testrac2.NODE
racnode2
oracle
_dba
DATABASE.DATABASES.testrac.INSTANCE.testrac2.ENABLED
true
oracle
_dba
DATABASE.DATABASES.testrac.INSTANCE.testrac2.ENVIRONMENT
oracle
_dba
SYSTEM.css.interfaces.global.ce0.172|d25|d0|d0.1
public
oracle
_oinstall
SYSTEM.css.interfaces.global.ce1.10|d0|d0|d0.1
cluster_interconnect
oracle
_oinstall
可以看到,得到的文件包括了cluster各个方面的详细信息。如果ocr磁盘出现故障,也可以利用这个文件执行-import来恢复ocr磁盘。
处理逻辑备份外,ocrconfig命令还可以管理物理备份,检查ocr备份信息:
bash-2.03# /data/oracle/product/10.2/crs/bin/ocrconfig -showbackup
racnode1 2010/11/19 20:33:56 /data/oracle/product/10.2/crs/cdata/crs
racnode1 2010/11/19 16:33:55 /data/oracle/product/10.2/crs/cdata/crs
racnode1 2010/11/19 12:33:54 /data/oracle/product/10.2/crs/cdata/crs
racnode1 2010/11/18 00:33:49 /data/oracle/product/10.2/crs/cdata/crs
racnode1 2010/11/11 00:33:37 /data/oracle/product/10.2/crs/cdata/crs
利用-backuploc可以修改ocr自动备份的目标目录。而利用-restore可以通过备份恢复ocr,-replace ocr用来新增、替换ocr磁盘,-repair ocr会修复本地ocr配置。
bash-2.03# ls -l /data/oracle/product/10.2/crs/cdata/crs
total 67312
-rw-r--r-- 1 root root 4911104 Nov 20 20:33 backup00.ocr
-rw-r--r-- 1 root root 4911104 Nov 20 16:33 backup01.ocr
-rw-r--r-- 1 root root 4911104 Nov 20 12:33 backup02.ocr
-rw-r--r-- 1 root root 4911104 Nov 19 00:33 day.ocr
-rw-r--r-- 1 root root 4911104 Nov 20 00:33 day_.ocr
-rw-r--r-- 1 root root 4911104 Nov 11 00:33 week.ocr
-rw-r--r-- 1 root root 4911104 Nov 18 00:33 week_.ocr
bash-2.03# /data/oracle/product/10.2/crs/bin/ocrconfig -restore /data/oracle/product/10.2/crs/cdata/crs/backup00.ocr
PROT-19: Cannot proceed while clusterware is running. Shutdown clusterware first
bash-2.03# /etc/init.d/init.crs stop
Shutting down Oracle Cluster Ready Services (CRS):
Nov 21 00:53:15.442 | INF | daemon shutting down
Stopping resources. This could take several minutes.
Successfully stopped CRS resources.
Stopping CSSD.
Shutting down CSS daemon.
Shutdown request successfully issued.
Shutdown has begun. The daemons should exit soon.
bash-2.03# /data/oracle/product/10.2/crs/bin/ocrconfig -restore /data/oracle/product/10.2/crs/cdata/crs/backup00.ocr
这是一个restore的例子,显然cluster处于启动状态是没有办法执行ocr的恢复的,不过只要本节点上的cluster关闭后,就可以执行restore,这个例子中远端节点的cluster并没有关闭。
最后是一个-import的例子:
bash-2.03# /data/oracle/product/10.2/crs/bin/ocrconfig -export /export/home/oracle/ocr.log
bash-2.03# /etc/init.d/init.crs stop
Shutting down Oracle Cluster Ready Services (CRS):
Nov 23 16:49:14.522 | INF | daemon shutting down
Stopping resources. This could take several minutes.
Successfully stopped CRS resources.
Stopping CSSD.
Shutting down CSS daemon.
Shutdown request successfully issued.
Shutdown has begun. The daemons should exit soon.
bash-2.03# /data/oracle/product/10.2/crs/bin/ocrconfig -import /export/home/oracle/ocr.log
唯一需要注意的是,在执行逻辑恢复ocr的时候,需要确保所有实例的cluster都已经关闭,否则可能会导致ocr不一致的错误。
oracle视频教程请关注:http://u.youku.com/user_video/id_UMzAzMjkxMjE2.html