DBA never sleep-DBA,永不眠

Focus on Oracle/MySQL/Redis/MongoDB

Oracle 10g RAC 维护工具完全详解

节点层:olsnodes
网络层:oifcfg
集群层:crsctl、ocrcheck、ocrdump、ocrconfig
应用层:srvctl、onsctl、crs_stat


一、olsnodes 的使用
[root@rac22 ~]# olsnodes -h
Usage: olsnodes [-n] [-p] [-i] [<node> | -l] [-g] [-v]
        where
                -n print node number with the node name
                -p print private interconnect name with the node name
                -i print virtual IP name with the node name
                <node> print information for the specified node
                -l print information for the local node 
                -g turn on logging 
                -v run in verbose mode 
-----------显示每个节点的node id
[root@rac22 ~]# olsnodes -n 
rac11   1
rac22   2
[root@rac22 ~]# olsnodes -n rac22
rac22   2


------------显示节点用于 private interconnect 的网卡名称及节点信息
[root@rac22 ~]# olsnodes -p
rac11   priv11
rac22   priv22
[root@rac22 ~]# olsnodes -p -n rac22
rac22   2       priv22


------------显示节点的 VIP
[root@rac22 ~]# olsnodes -n -p -i
rac11   1       priv11  vip11
rac22   2       priv22  vip22
[root@rac22 ~]# olsnodes -p -i -n rac22
rac22   2       priv22  vip22


------------显示详细的node信息
[root@rac22 ~]# olsnodes -v
prlslms: Initializing LXL global
prlsndmain: Initializing CLSS context
prlsmemberlist: No of cluster members configured = 256
prlsmemberlist: Getting information for nodenum = 1
prlsmemberlist: node_name = rac11
prlsmemberlist: ctx->lsdata->node_num = 1
prls_printdata: Printing the node data
rac11
prlsmemberlist: Getting information for nodenum = 2
prlsmemberlist: node_name = rac22
prlsmemberlist: ctx->lsdata->node_num = 2
prls_printdata: Printing the node data
rac22
prlsndmain: olsnodes executed successfully
prlsndterm: Terminating LSF


二、oifcfg 命令的使用
[root@rac22 ~]# oifcfg


Name:
        oifcfg - Oracle Interface Configuration Tool.


Usage:  oifcfg iflist [-p [-n]]
        oifcfg setif {-node <nodename> | -global} {<if_name>/<subnet>:<if_type>}...
        oifcfg getif [-node <nodename> | -global] [ -if <if_name>[/<subnet>] [-type <if_type>] ]
        oifcfg delif [-node <nodename> | -global] [<if_name>[/<subnet>]]
        oifcfg [-help]


        <nodename> - name of the host, as known to a communications network
        <if_name>  - name by which the interface is configured in the system
        <subnet>   - subnet address of the interface
        <if_type>  - type of the interface { cluster_interconnect | public | storage }
--------iflist 显示网口列表
[root@rac22 ~]# oifcfg iflist
eth0  192.168.10.0
eth1  10.10.10.0


[root@rac22 ~]# oifcfg iflist -p -n
eth0  192.168.10.0  PRIVATE  255.255.255.0
eth1  10.10.10.0  PRIVATE  255.255.255.0


--------gettif 可以获得单个网口的信息
[root@rac22 ~]# oifcfg getif
eth0  192.168.10.0  global  public
eth1  10.10.10.0  global  cluster_interconnect
------ -node 查询节点特定的信息,仅当节点有区别于global的配置时才会有结果显示
[root@rac22 ~]# oifcfg getif -node rac11
[root@rac22 ~]# oifcfg getif -node rac22
------ -global 查询节点的 global 类型设置
[root@rac22 ~]# oifcfg getif -global rac22
eth0  192.168.10.0  global  public
eth1  10.10.10.0  global  cluster_interconnect
[root@rac22 ~]# oifcfg getif -global rac11
eth0  192.168.10.0  global  public
eth1  10.10.10.0  global  cluster_interconnect
[root@rac22 ~]# oifcfg getif -global
eth0  192.168.10.0  global  public
eth1  10.10.10.0  global  cluster_interconnect
------ -type  查看public 类型的网卡配置
[root@rac22 ~]# oifcfg getif -type public
eth0  192.168.10.0  global  public
------ -type  查看public 类型的网卡配置
[root@rac22 ~]# oifcfg getif -type cluster_interconnect
eth1  10.10.10.0  global  cluster_interconnect


--------setif 配置单个网口
------ 通过 setif 添加向集群新的网卡
usage:oifcfg setif {-node <nodename> | -global} {<if_name>/<subnet>:<if_type>}...
其中 -global/node 必须指定
[root@rac22 ~]# oifcfg setif -global eth2/10.10.11.11:public
[root@rac22 ~]# oifcfg setif -node rac22 eth3/10.10.11.12:public
[root@rac22 ~]# oifcfg getif -global 
eth0  192.168.10.0  global  public
eth1  10.10.10.0  global  cluster_interconnect
eth2  10.10.11.11  global  public
[root@rac22 ~]# oifcfg getif -node rac22
eth3  10.10.11.12  rac22  public


注意这里的添加网卡命令并不会校验网卡是否真的存在,即使是没有这两个网卡,也是可以添加成功的,但是setif命令已经修改了相应的配置文件
并生效。


--------delif 删除网口
------ 使用delif 删除刚刚添加的不存在网卡
[root@rac22 ~]# oifcfg delif -global
[root@rac22 ~]# oifcfg delif -node rac22
上面的两个命令会删除所有的网卡设置不推荐使用,通常我们会特指相应的网卡进行删除
[root@rac22 ~]# oifcfg delif -global eth2/10.10.11.11
[root@rac22 ~]# oifcfg delif -node rac22 /eth3/10.10.11.12




网络故障及解决办法:RAC 环境无法识别心跳网络的故障
新装 RAC 环境,数据库启动日志中发现:No cluster interconnect
首先查看初始化参数 cluster_interconnects 是否设置
SQL> show parameter cluster


NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
cluster_database                     boolean     TRUE
cluster_database_instances           integer     2
cluster_interconnects                string


然后查看如下视图:
SQL> col host_name for a20
SQL> select INSTANCE_NUMBER,INSTANCE_NAME,HOST_NAME,NAME_KSXPIA network_interface,IP_KSXPIA private_ip from x$ksxpia cross join v$instance where PUB_KSXPIA= 'N';


INSTANCE_NUMBER INSTANCE_NAME    HOST_NAME            NETWORK_INTERFA PRIVATE_IP
--------------- ---------------- -------------------- --------------- ----------------
              2 PROD2            rac22                eth1            10.10.10.22
注意,这里是正常情况下查询结果,如果是故障情况下,此查询将无结果。


在用 oifcfg iflist -p -v
[oracle@rac22 ~]$ oifcfg  iflist -p -n
eth0  192.168.10.0  PRIVATE  255.255.255.0
eth1  10.10.10.0  PRIVATE  255.255.255.0


如果上面的命令和连接查询均查不到结果,则表示,cluster在安装配置过程中,未将 cluster_interconnect 信息注册到 OCR 中,要解决此问题
我们并不需要重新安装和配置集群环境,只需使用 oifcfg 命令稍作配置即可
我们需要先停止数据库
[root@rac11 ~]# srvctl stop database -d prod
然后使用 oifcfg setif 命令添加一个 cluster_interconnect 网卡(必须存在)即可
[root@rac11 ~]# oifcfg setif -global eth1/10.10.10.11:cluster_interconnect
然后查看添加结果:
[root@rac11 ~]# oifcfg getif -global
eth0  192.168.10.0  global  public
eth1  10.10.10.0  global  cluster_interconnect
最后重启节点上的所有 CRS 资源(或服务),然后再重启数据库。
[root@rac11 ~]# crsctl stop crs


---------------- crsctl 命令的用法
集群层的命令包括 crsctl\ocrcheck\ocrdump\ocrconfig ,其中后三个都是针对 OCR 磁盘操作的命令
crsctl 可以用来查看 CRS 进程栈,每个CRS进程的状态,管理 voting disk,跟踪 CRS 进程等功能。
可以不带任何参数查询其用法:
[root@rac11 ~]# crsctl
Usage: crsctl check  crs          - checks the viability of the CRS stack
       crsctl check  cssd         - checks the viability of CSS
       crsctl check  crsd         - checks the viability of CRS
       crsctl check  evmd         - checks the viability of EVM
       crsctl set    css <parameter> <value> - sets a parameter override
       crsctl get    css <parameter> - gets the value of a CSS parameter
       crsctl unset  css <parameter> - sets CSS parameter to its default
       crsctl query  css votedisk    - lists the voting disks used by CSS
       crsctl add    css votedisk <path> - adds a new voting disk
       crsctl delete css votedisk <path> - removes a voting disk
       crsctl enable  crs    - enables startup for all CRS daemons
       crsctl disable crs    - disables startup for all CRS daemons
       crsctl start crs  - starts all CRS daemons.
       crsctl stop  crs  - stops all CRS daemons. Stops CRS resources in case of cluster.
       crsctl start resources  - starts CRS resources. 
       crsctl stop resources  - stops  CRS resources. 
       crsctl debug statedump evm  - dumps state info for evm objects
       crsctl debug statedump crs  - dumps state info for crs objects
       crsctl debug statedump css  - dumps state info for css objects
       crsctl debug log css [module:level]{,module:level} ... 
                             - Turns on debugging for CSS 
       crsctl debug trace css - dumps CSS in-memory tracing cache
       crsctl debug log crs [module:level]{,module:level} ... 
                             - Turns on debugging for CRS 
       crsctl debug trace crs - dumps CRS in-memory tracing cache
       crsctl debug log evm [module:level]{,module:level} ... 
                             - Turns on debugging for EVM
       crsctl debug trace evm - dumps EVM in-memory tracing cache
       crsctl debug log res <resname:level> turns on debugging for resources
       crsctl query crs softwareversion [<nodename>] - lists the version of CRS software installed
       crsctl query crs activeversion - lists the CRS software operating version
       crsctl lsmodules css - lists the CSS modules that can be used for debugging
       crsctl lsmodules crs - lists the CRS modules that can be used for debugging
       crsctl lsmodules evm - lists the EVM modules that can be used for debugging


 If necesary any of these commands can be run with additional tracing by
 adding a "trace" argument at the very front.
 Example: crsctl trace check css
 
------ 查看整个 CRS 栈状态
 [root@rac11 ~]# crsctl check crs
CSS appears healthy
CRS appears healthy
EVM appears healthy


------ 查看 CRS 栈中各个组件(cssd\crsd\evmd)的状态
[root@rac11 ~]# crsctl check cssd
CSS appears healthy
[root@rac11 ~]# crsctl check crsd
CRS appears healthy
[root@rac11 ~]# crsctl check evmd
EVM appears healthy


------ 设置 CRS 栈是否自动启动
       crsctl enable  crs    - enables startup for all CRS daemons
       crsctl disable crs    - disables startup for all CRS daemons
       有时出于维护需要,可能要关闭 CRS 栈自动启动
[root@rac11 ~]# crsctl disable crs
[root@rac11 ~]# crsctl enable crs


------ 启动和停止 CRS 栈
在 Oracle 10.1 中必须重启 clusterware,在 Oracle 10.2 以后的版本中可以通过如下命令进行启动和关闭 CRS 栈的操作:
[root@rac11 ~]# crsctl stop crs
Stopping resources.
Successfully stopped CRS resources 
Stopping CSSD.
Shutting down CSS daemon.
Shutdown request successfully issued
------ 执行上述命令后的结果
[oracle@rac22 ~]$ crs_stat -t -v
Name           Type           R/RA   F/FT   Target    State     Host        
----------------------------------------------------------------------
ora....D1.inst application    0/5    0/0    ONLINE    OFFLINE               
ora....D2.inst application    0/5    0/0    ONLINE    ONLINE    rac22       
ora.PROD.db    application    0/1    0/1    ONLINE    ONLINE    rac22       
ora....SM1.asm application    0/5    0/0    ONLINE    OFFLINE               
ora....11.lsnr application    0/5    0/0    ONLINE    OFFLINE               
ora.rac11.gsd  application    0/5    0/0    ONLINE    OFFLINE               
ora.rac11.ons  application    0/3    0/0    ONLINE    OFFLINE               
ora.rac11.vip  application    0/0    0/0    ONLINE    OFFLINE               
ora....SM2.asm application    0/5    0/0    ONLINE    ONLINE    rac22       
ora....22.lsnr application    0/5    0/0    ONLINE    ONLINE    rac22       
ora.rac22.gsd  application    0/5    0/0    ONLINE    ONLINE    rac22       
ora.rac22.ons  application    0/3    0/0    ONLINE    ONLINE    rac22       
ora.rac22.vip  application    0/0    0/0    ONLINE    ONLINE    rac22
注意在一个node上执行,只会停止该节点上的 CRS 
[root@rac11 ~]# crsctl start crs
Attempting to start CRS stack 
The CRS stack will be started shortly
------经crs_stat -t -v 观察启动过程会很慢,暂不清楚其具体过程


------ 查看 votedisk 磁盘的位置
[oracle@rac22 ~]$ crsctl query css votedisk
 0.     0    /dev/raw/raw2


located 1 votedisk(s).


------ 查看和修改 CRS 参数
使用 get 命令查看参数
[oracle@rac22 ~]$ crsctl get css misscount
60
使用 set 命令修改参数(慎用,必须以 root 用户执行)
[root@rac11 ~]# crsctl set css misscount 100
Configuration parameter misscount is now set to 100.
[root@rac11 ~]# crsctl set css misscount 60
Configuration parameter misscount is now set to 60.


CRS 由 CRS\CSS\EVM 3 个服务组成,每个服务又由一系列的 module 组成, 可以使用 crsctl对每个module进行跟踪,并把跟踪内容记录到日志中。
[root@rac11 ~]# crsctl lsmodules css
The following are the CSS modules :: 
    CSSD
    COMMCRS
    COMMNS
[root@rac11 ~]# crsctl lsmodules evm
The following are the EVM modules :: 
   EVMD
   EVMDMAIN
   EVMCOMM
   EVMEVT
   EVMAPP
   EVMAGENT
   CRSOCR
   CLUCLS
   CSSCLNT
   COMMCRS
   COMMNS
[root@rac11 ~]# crsctl lsmodules crs
The following are the CRS modules :: 
    CRSUI
    CRSCOMM
    CRSRTI
    CRSMAIN
    CRSPLACE
    CRSAPP
    CRSRES
    CRSCOMM
    CRSOCR
    CRSTIMER
    CRSEVT
    CRSD
    CLUCLS
    CSSCLNT
    COMMCRS
    COMMNS


以下以跟踪 CSSD 模块为例讲述如何操作(必须以root用户执行):
[root@rac11 ~]# crsctl debug log css "CSSD:1"
Configuration parameter trace is now set to 1.
Set CRSD Debug Module: CSSD  Level: 1
查看跟踪产生的日志信息:
[root@rac11 ~]# tail -f /u01/crs10.2.0/log/rac11/cssd/ocssd.log 
[    CSSD]2012-07-16 10:45:06.480 [100371360] >TRACE:   clssgmClientConnectMsg: Connect from con(0xb6707fb8) proc(0xb6728e50) pid() proto(10:2:1:1)
[    CSSD]2012-07-16 10:45:57.613 [100371360] >TRACE:   clssgmClientConnectMsg: Connect from con(0xb67269c0) proc(0xb6727af8) pid() proto(10:2:1:1)
[    CSSD]2012-07-16 10:46:58.567 [100371360] >TRACE:   clssgmClientConnectMsg: Connect from con(0xb6707fb8) proc(0xb67087c0) pid() proto(10:2:1:1)
[    CSSD]2012-07-16 10:47:59.701 [100371360] >TRACE:   clssgmClientConnectMsg: Connect from con(0xb6707fb8) proc(0xb6708848) pid() proto(10:2:1:1)
[    CSSD]2012-07-16 10:49:01.148 [100371360] >TRACE:   clssgmClientConnectMsg: Connect from con(0xb6707fb8) proc(0xb6708848) pid() proto(10:2:1:1)
[    CSSD]2012-07-16 10:50:02.570 [100371360] >TRACE:   clssgmClientConnectMsg: Connect from con(0xb6707fb8) proc(0xb6708848) pid() proto(10:2:1:1)
[    CSSD]2012-07-16 10:51:03.946 [100371360] >TRACE:   clssgmClientConnectMsg: Connect from con(0xb6707fb8) proc(0xb6708848) pid() proto(10:2:1:1)
[    CSSD]2012-07-16 10:51:19.703 [40508320] >TRACE:   clssscSetDebugLevel: The logging level is set to 1 ,the cache level is set to


------- 维护 votedisk
图形化界面安装 clusterware 过程中,配置 votedisk 时,如果选择 external redundancy 策略,则只能选一个 votedisk
其实,即使选择了该选项也可以使用crsctl 命令添加多块 votedisk 盘,这些 votedisk 盘可以互为镜像。
votedisk 采用多数可用算法,如果存在多个 votedisk ,则必须有一半以上的 votedisk 可用时集群才能正常工作。
例如,如果一个cluster配置了4个 votedisk ,当其中有一个votedisk 损坏时,集群能够正常工作,但是当其中有两个 votedisk 损坏时,
集群就无法工作了,会立即宕机。
votedisk 的添加原则:奇数个,操作前必须先停止数据库、ASM、CRS Stack ,操作时必须加上 -force 参数。


------- 添加 votedisk 示例:
1、创建共享磁盘:
在Windows主机上进入Oracle Virtual Box 的安装路径:
VBoxManage createhd --filename G:\share2\share2.vdi --size 4000 --format VDI --variant Fixed
在G:\Shared2目录下创建共享磁盘,大小为4g
将刚刚创建的共享磁盘添加到node1和node2虚拟主机
      首先,关闭两个节点主机node1和node2,然后执行以下两条语句
    VBoxManage storageattach rac11 --storagectl "IDE 控制器" --port 1 --device 1 --type hdd --medium G:\share2\share3.vdi --mtype shareable
    VBoxManage storageattach rac22 --storagectl "IDE 控制器" --port 0 --device 1 --type hdd --medium G:\share2\share3.vdi --mtype shareable
      --storagectl "IDE 控制器" :在虚拟机看到的名称,如果是英文版的,可能名称不一样
         --port 0  :第一个IDE接口
         --device 1  :IDE接口的辅盘,主盘为 0
启用共享磁盘
       VBoxManage modifyhd G:\share2\share2.vdi --type shareable


2、当前 votedisk 的位置:
[root@rac22 ~]# crsctl query css votedisk
 0.     0    /dev/raw/raw2


located 1 votedisk(s).
3、停止所有节点上的 CRS
[root@rac11 ~]# crsctl stop crs
Stopping resources.
Successfully stopped CRS resources 
Stopping CSSD.
Shutting down CSS daemon.
Shutdown request successfully issued.
[root@rac11 ~]# crsctl check crs
Failure 1 contacting CSS daemon
Cannot communicate with CRS
Cannot communicate with EVM 


4、添加 votedisk (添加两个使votedisk 个数为奇数)
[root@rac11 ~]# crsctl add css votedisk /dev/raw/raw5
Cluster is not in a ready state for online disk addition
即使是在 CRS 关闭后,也必须指定 -force 参数来添加或删除 votedisk。且 -force 参数只有在 CRS 关闭时使用才安全。
[root@rac11 ~]# crsctl add css votedisk -force /dev/raw/raw5
Now formatting voting disk: /dev/raw/raw5
successful addition of votedisk /dev/raw/raw5.
[root@rac11 ~]# crsctl add css votedisk -force /dev/raw/raw6
Now formatting voting disk: /dev/raw/raw6
successful addition of votedisk /dev/raw/raw6.


5、查询添加结果
[root@rac22 ~]# crsctl query css votedisk
 0.     0    /dev/raw/raw2
 1.     0    /dev/raw/raw5
 2.     0    /dev/raw/raw6


located 3 votedisk(s).


6、启动 CRS
[root@rac22 ~]# crsctl start crs
Attempting to start CRS stack 
The CRS stack will be started shortly
[root@rac11 ~]# crsctl start crs
Attempting to start CRS stack 
The CRS stack will be started shortly


-------- 删除 votedisk 示例:
1、查看 votedisk 路径
[root@rac11 ~]# crsctl query css votedisk
 0.     0    /dev/raw/raw2
 1.     0    /dev/raw/raw5
 2.     0    /dev/raw/raw6
2、停止所有节点上的 crs
[root@rac11 ~]# crsctl stop crs
Stopping resources.
Successfully stopped CRS resources 
Stopping CSSD.
Shutting down CSS daemon.
Shutdown request successfully issued.
[root@rac22 ~]# crsctl stop crs
Stopping resources.
Successfully stopped CRS resources 
Stopping CSSD.
Shutting down CSS daemon.
Shutdown request successfully issued.
3、删除 votedisk
[root@rac11 ~]# crsctl | grep votedisk
       crsctl query  css votedisk    - lists the voting disks used by CSS
       crsctl add    css votedisk <path> - adds a new voting disk
       crsctl delete css votedisk <path> - removes a voting disk
[root@rac11 ~]# crsctl delete css votedisk /dev/raw/raw6 -force
successful deletion of votedisk /dev/raw/raw6.
4、查看是否删除成功
[root@rac11 ~]# crsctl query css votedisk
 0.     0    /dev/raw/raw2
 1.     0    /dev/raw/raw5


located 2 votedisk(s).


---------- OCR 命令
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


OCR 维护相关的命令
--------ocrdump 的用法
ocrdump 可以按 ASCII 的方式打印输出 OCR 的内容,但这个命令不能用作 OCR 的备份恢复,仅供阅读 OCR 不供恢复 OCR。
[root@rac22 ~]# ocrdump -h
Name:
        ocrdump - Dump contents of Oracle Cluster Registry to a file.


Synopsis:
        ocrdump [<filename>|-stdout] [-backupfile <backupfilename>] [-keyname <keyname>] [-xml] [-noheader]


Description:
        Default filename is OCRDUMPFILE. Examples are:


        prompt> ocrdump
        writes cluster registry contents to OCRDUMPFILE in the current directory


        prompt> ocrdump MYFILE
        writes cluster registry contents to MYFILE in the current directory


        prompt> ocrdump -stdout -keyname SYSTEM
        writes the subtree of SYSTEM in the cluster registry to stdout


        prompt> ocrdump -stdout -xml
        writes cluster registry contents to stdout in xml format


Notes:
        The header information will be retrieved based on best effort basis.
        A log file will be created in
        $ORACLE_HOME/log/<hostname>/client/ocrdump_<pid>.log. Make sure
        you have file creation privileges in the above directory before
        running this tool.


-------- 将 SYSTEM.css 键的内容以 .xml 格式打印输出到屏幕
OCR key 主要有三类:SYSTEM、DATABASE、CRS
[oracle@rac11 ~]$ ocrdump -stdout -keyname SYSTEM.css -xml | more
<OCRDUMP>


<TIMESTAMP>07/16/2012 10:12:34</TIMESTAMP>
<COMMAND>ocrdump -stdout -keyname SYSTEM.css -xml </COMMAND>


<KEY>
<NAME>SYSTEM.css</NAME>
<VALUE_TYPE>UNDEF</VALUE_TYPE>
<VALUE><![CDATA[]]></VALUE>
<USER_PERMISSION>PROCR_ALL_ACCESS</USER_PERMISSION>
<GROUP_PERMISSION>PROCR_READ</GROUP_PERMISSION>
<OTHER_PERMISSION>PROCR_READ</OTHER_PERMISSION>
<USER_NAME>root</USER_NAME>
<GROUP_NAME>root</GROUP_NAME>
..................................
..................................


该命令将在 $CRS_HOME/log/node_name/client目录下产生日志文件,格式为 ocrdump_pid.ora,pid 为进程号
--------- 将 SYSTEM.css key 的内容以文件形式打印输出
[root@rac11 client]# ocrdump '/home/oracle/ocrdump_test.log' -keyname SYSTEM.css -xml


---------------ocrcheck 命令
ocrcheck 命令用于检查 OCR 内容的一致性:命令执行过程中会在此目录下产生日志 $ORACLE_HOME/log/<hostname>/client/ocrcheck_<pid>.log 
ocrcheck 命令不需要参数
[oracle@rac11 ~]$ ocrcheck -h
Name:
        ocrcheck - Displays health of Oracle Cluster Registry.


Synopsis:
        ocrcheck 


Description:
        prompt> ocrcheck
        Displays current usage, location and health of the cluster registry


Notes:
        A log file will be created in
        $ORACLE_HOME/log/<hostname>/client/ocrcheck_<pid>.log. Please ensure
        you have file creation privileges in the above directory before
        running this tool.

如果 OCR 内容一致,则产生的输出如下:
[root@rac22 ~]# ocrcheck
Status of Oracle Cluster Registry is as follows :
         Version                  :          2
         Total space (kbytes)     :     204712
         Used space (kbytes)      :       3840
         Available space (kbytes) :     200872
         ID                       : 1788954814
         Device/File Name         : /dev/raw/raw1
                                    Device/File integrity check succeeded


                                    Device/File not configured


         Cluster registry integrity check succeeded
如果不一致则产生如下输出:
[root@rac22 ~]# ocrcheck
Status of Oracle Cluster Registry is as follows :
         Version                  :          2
         Total space (kbytes)     :     204712
         Used space (kbytes)      :       3840
         Available space (kbytes) :     200872
         ID                       : 1788954814
         Device/File Name         : /dev/raw/raw1
                                    Device/File need to be synchronized with the other device


                                    Device/File not configured


         Cluster registry integrity check succeeded


------------- ocrconfig 命令
ocrconfig 命令用于维护 OCR 磁盘。
在安装 clusterware 过程中如果选择 external redundancy ,则只能指定一个 OCR disk。但是 Oracle 允许且只允许配置两个 OCR disk 互为
镜像,以防止 OCR 磁盘发生单点故障。OCR 磁盘和 votedisk 不一样,最多只能有两个,一个为 Primary OCR 一个为 Mirror OCR。
[root@rac22 ~]# ocrconfig -h
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.


---------使用 ocrconfig 查看自动备份
[root@rac22 ~]# ocrconfig -showbackup


---------修改 OCR 自动备份的位置
默认位置为:$OCR_HOME/crs/cdata/cluster_name/
[root@rac22 ~]# ocrconfig -backuploc /home/oracle/backup


---------使用导出、导入进行备份和恢复
Oracle建议在对集群做调整(增加、删除节点)之前,对OCR进行备份,可以使用 export 备份到指定文件。如果做了 replace 或 restore 操作,Oracle
还建议使用 cluvfy compocr-n all 做一次全面的检查。
1、首先关闭所有节点的 CRS
[root@rac22 ~]# crsctl stop crs
Stopping resources.
Successfully stopped CRS resources 
Stopping CSSD.
Shutting down CSS daemon.
Shutdown request successfully issued.
2、导出 OCR 的内容(必须以 root 权限)
[root@rac22 ocr_backup]# ocrconfig -export ocrexp.exp  /home/oracle/ocr_backup/ocrexp.exp
3、重启 CRS
[root@rac11 ~]# crsctl start crs
Attempting to start CRS stack 
The CRS stack will be started shortly


[root@rac22 ~]# crsctl start crs
Attempting to start CRS stack 
The CRS stack will be started shortly


4、检查 CRS 状态
[root@rac11 ~]# crsctl check crs
CSS appears healthy
CRS appears healthy
EVM appears healthy
[root@rac22 ~]# crsctl check crs
CSS appears healthy
CRS appears healthy
EVM appears healthy


5、破坏 OCR 内容
[root@rac11 ~]# dd if=/dev/zero of=/dev/raw/raw1 bs=1024 count=200
200+0 records in
200+0 records out


6、运行 cluvfy 工具检查 OCR 一致性(失败)
[root@rac11 ~]# /soft/clusterware/cluvfy/runcluvfy.sh comp ocr -n all


Verifying OCR integrity 


ERROR: 
User equivalence unavailable on all the nodes.
Verification cannot proceed.




Verification of OCR integrity was unsuccessful on all the nodes. 
7、使用ocrcheck 检查 OCR 的一致性
[root@rac11 ~]# ocrcheck
PROT-601: Failed to initialize ocrcheck


8、使用 import 恢复 OCR 的内容
[root@rac11 ~]# ocrconfig -import /home/oracle/ocr_backup/ocrexp.exp 
PROT-19: Cannot proceed while clusterware is running. Shutdown clusterware first
先关闭 CRS,然后再执行 import 恢复
在本例中,因为是在打开 CRS 的时候破坏了 OCR,因此是无法成功关闭 CRS 的,关闭时会报错。只能重启系统,重启后CRS将无法启动这时
执行上述命令即可成功:
[root@rac11 ~]# ocrconfig -import /home/oracle/ocr_backup/ocrexp.exp
9、再次使用 ocrcheck 检查一致性状态(通过)
[root@rac11 ~]# ocrcheck
Status of Oracle Cluster Registry is as follows :
         Version                  :          2
         Total space (kbytes)     :     204712
         Used space (kbytes)      :       3840
         Available space (kbytes) :     200872
         ID                       :  825485411
         Device/File Name         : /dev/raw/raw1
                                    Device/File integrity check succeeded


                                    Device/File not configured


         Cluster registry integrity check succeeded
10、使用cluvfy工具检查(通过)。
[root@rac11 ~]# /soft/clusterware/cluvfy/runcluvfy.sh comp ocr -n all
Verifying OCR integrity 


ERROR: 
User equivalence unavailable on all the nodes.
Verification cannot proceed.




Verification of OCR integrity was unsuccessful on all the nodes. 
----------这里检测的结果不成功,不知何因。


11、启动 CRS
crsctl start crs

crsctl check crs



如需转载,请注明出处及原文链接

http://blog.csdn.net/xiangsir/article/details/8576849




















阅读更多
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/xiangsir/article/details/8576849
个人分类: Oracle 10g RAC
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭