1.启动crs
如果crs没有启动在使用crs_stat命令查看集群状态的时候将会收到如下的报错信息。
racdb1@rac1 /home/oracle$ /oracle/app/crs/bin/crs_stat -t
crs-0184: cannot communicate with the crs daemon.
在rac环境下启动所有节点上的crs。
[root@rac1 ~]# /oracle/app/crs/bin/crsctl start crs
attempting to start crs stack
the crs stack will be started shortly
[root@rac2 ~]# /oracle/app/crs/bin/crsctl start crs
集群从启动到全部启动完毕的总时间与系统想能和配置有关,一般需要3~10分钟的时间,请耐心等待。
注意:为保证集群环境可以正常无误的启动,一定要确保集群环境中各个节点的时钟保持一致。
与之对应的停止crs命令为:“crsctl stop crs”。
2.查看crs资源状态
集群资源启动完毕后,以在第一节点查看集群状态为例。
name type target state host
------------------------------------------------------------
ora....b1.inst application online online rac1
ora....b2.inst application online online rac2
ora.racdb.db application online online rac2
ora....db1.srv application online online rac1
ora....db2.srv application online online rac2
ora.....taf.cs application online online rac1
ora....sm1.asm application online online rac1
ora....c1.lsnr application online online rac1
ora.rac1.gsd application online online rac1
ora.rac1.ons application online online rac1
ora.rac1.vip application online online rac1
ora....sm2.asm application online online rac2
ora....c2.lsnr application online online rac2
ora.rac2.gsd application online online rac2
ora.rac2.ons application online online rac2
ora.rac2.vip application online online rac2
3.关闭特定集群资源
1)获取集群资源名的方法
crs_stat命令会给出集群资源名的基本信息,结合适当的shell技巧便可以得到当前环境下集群资源名信息。
racdb1@rac1 /home/oracle$ crs_stat | grep -i name= | cut -d '=' -f2
ora.racdb.racdb1.inst
ora.racdb.racdb2.inst
ora.racdb.db
ora.racdb.taf.racdb1.srv
ora.racdb.taf.racdb2.srv
ora.racdb.taf.cs
ora.rac1.asm1.asm
ora.rac1.listener_rac1.lsnr
ora.rac1.gsd
ora.rac1.ons
ora.rac1.vip
ora.rac2.asm2.asm
ora.rac2.listener_rac2.lsnr
ora.rac2.gsd
ora.rac2.ons
ora.rac2.vip
2)以关闭ora.racdb.racdb1.inst资源为例
racdb1@rac1 /home/oracle$ /oracle/app/crs/bin/crs_stop ora.racdb.racdb1.inst
attempting to stop `ora.racdb.racdb1.inst` on member `rac1`
stop of `ora.racdb.racdb1.inst` on member `rac1` succeeded.
提示已成功关闭racdb1数据库实例。
确认关闭后集群资源状态:
ora....b1.inst application offline offline
ora....db1.srv application online offline
4.启动特定集群资源
启动ora.racdb.racdb1.inst资源
racdb1@rac1 /home/oracle$ /oracle/app/crs/bin/crs_start ora.racdb.racdb1.inst
attempting to start `ora.racdb.racdb1.inst` on member `rac1`
start of `ora.racdb.racdb1.inst` on member `rac1` succeeded.
确认启动后状态:
5.同时停掉所有集群资源
racdb1@rac1 /home/oracle$ /oracle/app/crs/bin/crs_stop -all
attempting to stop `ora.racdb.taf.racdb1.srv` on member `rac1`
attempting to stop `ora.rac1.gsd` on member `rac1`
attempting to stop `ora.racdb.taf.cs` on member `rac1`
attempting to stop `ora.rac1.ons` on member `rac1`
attempting to stop `ora.racdb.taf.racdb2.srv` on member `rac2`
attempting to stop `ora.rac2.gsd` on member `rac2`
attempting to stop `ora.rac2.ons` on member `rac2`
stop of `ora.racdb.taf.racdb2.srv` on member `rac2` succeeded.
stop of `ora.racdb.taf.racdb1.srv` on member `rac1` succeeded.
attempting to stop `ora.racdb.db` on member `rac2`
stop of `ora.rac2.gsd` on member `rac2` succeeded.
stop of `ora.rac1.gsd` on member `rac1` succeeded.
stop of `ora.rac1.ons` on member `rac1` succeeded.
stop of `ora.rac2.ons` on member `rac2` succeeded.
stop of `ora.racdb.taf.cs` on member `rac1` succeeded.
stop of `ora.racdb.db` on member `rac2` succeeded.
`ora.racdb.racdb1.inst` is already offline.
`ora.racdb.racdb2.inst` is already offline.
attempting to stop `ora.rac1.listener_rac1.lsnr` on member `rac1`
attempting to stop `ora.rac1.asm1.asm` on member `rac1`
attempting to stop `ora.rac2.asm2.asm` on member `rac2`
attempting to stop `ora.rac2.listener_rac2.lsnr` on member `rac2`
stop of `ora.rac1.listener_rac1.lsnr` on member `rac1` succeeded.
attempting to stop `ora.rac1.vip` on member `rac1`
stop of `ora.rac2.listener_rac2.lsnr` on member `rac2` succeeded.
attempting to stop `ora.rac2.vip` on member `rac2`
stop of `ora.rac1.vip` on member `rac1` succeeded.
stop of `ora.rac2.vip` on member `rac2` succeeded.
stop of `ora.rac2.asm2.asm` on member `rac2` succeeded.
stop of `ora.rac1.asm1.asm` on member `rac1` succeeded.
crs-0216: could not stop resource 'ora.racdb.racdb1.inst'.
crs-0216: could not stop resource 'ora.racdb.racdb2.inst'.
确认集群资源停止后状态
ora....b2.inst application offline offline
ora.racdb.db application offline offline
ora....db1.srv application offline offline
ora....db2.srv application offline offline
ora.....taf.cs application offline offline
ora....sm1.asm application offline offline
ora....c1.lsnr application offline offline
ora.rac1.gsd application offline offline
ora.rac1.ons application offline offline
ora.rac1.vip application offline offline
ora....sm2.asm application offline offline
ora....c2.lsnr application offline offline
ora.rac2.gsd application offline offline
ora.rac2.ons application offline offline
ora.rac2.vip application offline offline
6.同时启动所有集群资源
racdb1@rac1 /home/oracle$ /oracle/app/crs/bin/crs_start -all
attempting to start `ora.rac1.vip` on member `rac1`
attempting to start `ora.rac1.asm1.asm` on member `rac1`
attempting to start `ora.rac2.vip` on member `rac2`
attempting to start `ora.rac2.asm2.asm` on member `rac2`
start of `ora.rac1.vip` on member `rac1` succeeded.
attempting to start `ora.rac1.listener_rac1.lsnr` on member `rac1`
start of `ora.rac2.vip` on member `rac2` succeeded.
attempting to start `ora.rac2.listener_rac2.lsnr` on member `rac2`
start of `ora.rac1.listener_rac1.lsnr` on member `rac1` succeeded.
start of `ora.rac2.listener_rac2.lsnr` on member `rac2` succeeded.
start of `ora.rac1.asm1.asm` on member `rac1` succeeded.
start of `ora.rac2.asm2.asm` on member `rac2` succeeded.
attempting to start `ora.racdb.racdb2.inst` on member `rac2`
start of `ora.racdb.racdb2.inst` on member `rac2` succeeded.
crs-1002: resource 'ora.rac1.ons' is already running on member 'rac1'
crs-1002: resource 'ora.rac2.ons' is already running on member 'rac2'
crs-1002: resource 'ora.racdb.db' is already running on member 'rac1'
attempting to start `ora.racdb.taf.racdb2.srv` on member `rac2`
attempting to start `ora.racdb.taf.cs` on member `rac1`
attempting to start `ora.racdb.taf.racdb1.srv` on member `rac1`
attempting to start `ora.rac1.gsd` on member `rac1`
attempting to start `ora.rac2.gsd` on member `rac2`
start of `ora.racdb.taf.cs` on member `rac1` succeeded.
start of `ora.racdb.taf.racdb2.srv` on member `rac2` succeeded.
start of `ora.rac2.gsd` on member `rac2` succeeded.
start of `ora.racdb.taf.racdb1.srv` on member `rac1` succeeded.
start of `ora.rac1.gsd` on member `rac1` succeeded.
crs-0223: resource 'ora.racdb.db' has placement error.
crs-0223: resource 'ora.rac1.ons' has placement error.
crs-0223: resource 'ora.rac2.ons' has placement error.
确认集群资源启动后状态
ora.racdb.db application online online rac1
note:如果集群资源状态是unknown,使用crs_start –all命令将无法完成正常启动。
7.使用srvctl停止和启动节点应用
racdb1@rac1 /home/oracle$ /oracle/app/crs/bin/srvctl stop nodeapps -n rac1
racdb1@rac1 /home/oracle$ /oracle/app/crs/bin/srvctl start nodeapps -n rac1
有关更多的srvctl命令的参考可以通过下面的方法获得:
racdb1@rac1 /home/oracle$ /oracle/app/crs/bin/srvctl
usage: srvctl <command> <object> [<options>]
command: enable|disable|start|stop|relocate|status|add|remove|modify|getenv|setenv|unsetenv|config
objects: database|instance|service|nodeapps|asm|listener
for detailed help on each command and object and its options use:
srvctl <command> <object> -h
使用“-h”选项可以获得更加详细的用法。
8.停止当前节点所有crs资源
racdb1@rac1 /home/oracle$ /oracle/app/crs/bin/crsctl stop resources
stopping resources. this could take several minutes.
successfully stopped crs resources.
ora....b1.inst application online offline
ora.racdb.db application online offline
ora.....taf.cs application online offline
ora....sm1.asm application online offline
9.启动当前节点所有crs资源
racdb1@rac1 /home/oracle$ /oracle/app/crs/bin/crsctl start resources
starting resources.
successfully started crs resources
racdb1@rac1 /home/oracle$ crs_stat -t
10.对crs后台进程做健康检查
racdb1@rac1 /home/oracle$ /oracle/app/crs/bin/crsctl check crs
css appears healthy
crs appears healthy
evm appears healthy
11.检查ocr
racdb1@rac1 /home/oracle$ /oracle/app/crs/bin/ocrcheck
status of oracle cluster registry is as follows :
version : 2
total space (kbytes) : 104216
used space (kbytes) : 4604
available space (kbytes) : 99612
id : 529429773
device/file name : /dev/raw/raw1
device/file integrity check succeeded
device/file not configured
cluster registry integrity check succeeded
12.检查表决磁盘
racdb1@rac1 /home/oracle$ /oracle/app/crs/bin/crsctl query css votedisk
0. 0 /dev/raw/raw2
located 1 votedisk(s).
13.小结
以上演示了在rac环境与crs有关的维护命令,这些命令的使用频率较高,需要熟练掌握。管理crs的命令较多,建议对每一个命令的具体选项做实际的测试,以便降低误操作的风险。