CRS提供了很多命令可以管理和查看集群服务状态,常用的有crs_stat、crs_start、crs_stop、crsctl等,这里依次介绍。
1、 查看集群状态
通过crs_stat命令可以查看集群中所有资源的状态,包括资源状态、资源运行在哪个节点上、资源类型等信息。例如:
[Oracle@node-rac1 ~]$ crs_stat –t Name Type Target State Host ------------------------------------------------------------ ora....SM1.asm application ONLINE ONLINE node-rac1 ora....C1.lsnr application ONLINE ONLINE node-rac1 ora....ac1.gsd application ONLINE ONLINE node-rac1 ora....ac1.ons application ONLINE ONLINE node-rac1 ora....ac1.vip application ONLINE ONLINE node-rac1 ora....SM2.asm application ONLINE ONLINE node-rac2 ora....C2.lsnr application ONLINE ONLINE node-rac2 ora....ac2.gsd application ONLINE ONLINE node-rac2 ora....ac2.ons application ONLINE ONLINE node-rac2 ora....ac2.vip application ONLINE ONLINE node-rac2 ora.racdb.db application ONLINE ONLINE node-rac2 ora....b1.inst application ONLINE ONLINE node-rac1 ora....b2.inst application ONLINE ONLINE node-rac2 ora....test.cs application ONLINE ONLINE node-rac2 ora....db1.srv application ONLINE ONLINE node-rac1 ora....db2.srv application ONLINE ONLINE node-rac2
如果要更详细的了解每个资源的名称及状态,还可以使用“crs_stat -l”命令,例如:
[oracle@node-rac2 ~]$crs_stat -l|head -n 15 NAME=ora.node-rac1.ASM1.asm TYPE=application TARGET=ONLINE STATE=ONLINE on node-rac1 NAME=ora.node-rac1.LISTENER_NODE-RAC1.lsnr TYPE=application TARGET=ONLINE STATE=ONLINE on node-rac1 NAME=ora.node-rac1.gsd TYPE=application TARGET=ONLINE STATE=ONLINE on node-rac1
可以看到,这个输出中包含了每个服务完整的名称和运行状态。通过了解节点运行状态,有助于对RAC集群的管理和维护。
还可以使用crs_stat -p 来查看资源的属性情况,包括依赖关系等等,例如:
[oracle@node-rac1 ~]$crs_stat -p ora.node-rac2.LISTENER_NODE-RAC2.lsnr
2.1 crs_stop与crs_start命令
通过crs_stop可以方便的关闭某个服务资源,例如:
[oracle@node-rac1 admin]$ crs_stop ora.node-rac1.LISTENER_NODE-RAC1.lsnr Attempting to stop `ora.node-rac1.LISTENER_NODE-RAC1.lsnr` on member `node-rac1` Stop of `ora.node-rac1.LISTENER_NODE-RAC1.lsnr` on member `node-rac1` succeeded.
此时,查看node-rac1节点的LISTENER服务状态:
[oracle@node-rac1 ~]$ crs_stat -t|grep lsnr ora....C1.lsnr application OFFLINE OFFLINE ora....C2.lsnr application ONLINE ONLINE node-rac2
从输出可知,node-rac1节点的LISTENER服务已经处于OFFLINE状态了。
接着启动node-rac1节点的LISTENER服务:
[oracle@node-rac1 ~]$crs_start ora.node-rac1.LISTENER_NODE-RAC1.lsnr Attempting to start `ora.node-rac1.LISTENER_NODE-RAC1.lsnr` on member `node-rac1` Start of `ora.node-rac1.LISTENER_NODE-RAC1.lsnr` on member `node-rac1` succeeded.
其实RAC数据库的监听还可以通过如下方式启动和关闭:
[oracle@node-rac1 ~]$lsnrctl start LISTENER_NODE-RAC1 [oracle@node-rac1 ~]$lsnrctl stop LISTENER_NODE-RAC1
有时候,可能需要将集群资源全部关闭,可以通过如下命令完成:
[oracle@node-rac1 ~]$ crs_stop -all
也通过一个命令将集群所有资源全部启动,操作如下:
[oracle@node-rac2 ~]$ crs_start -all