RAC 常用的脚本说明,参考我的Blog:
Oracle RAC 常用维护工具和命令
http://www.cndba.cn/Dave/article/1188
crs_stat 命令在显示上比srvctl 直观。 先查询一下:
[oracle@rac1 u01]$ crs_stat -t
Name Type Target State Host
------------------------------------------------------------
ora....SM2.asm application ONLINE ONLINE rac1
ora....C1.lsnr application ONLINE ONLINE rac1
ora.rac1.gsd application ONLINE ONLINE rac1
ora.rac1.ons application ONLINE OFFLINE
ora.rac1.vip application ONLINE ONLINE rac1
ora....SM1.asm application ONLINE ONLINE rac2
ora....C2.lsnr application ONLINE ONLINE rac2
ora.rac2.gsd application ONLINE ONLINE rac2
ora.rac2.ons application ONLINE OFFLINE
ora.rac2.vip application ONLINE ONLINE rac2
可以直观的列出各节点进程的状态。 但是这个命令的不足之处,就是Name列,不能显示全,那么在使用的时候就有点不方便。比如我们启动和关闭相关进程的时候。
比如:
[oracle@rac1 u01]$ crs_start ora.rac2.ons
Attempting to start `ora.rac2.ons` on member `rac2`
Start of `ora.rac2.ons` on member `rac2` succeeded.
[oracle@rac1 u01]$ crs_start ora.rac1.ons
--我们这里要写全进程的名称,如果名称过长,就不能显示全。
Attempting to start `ora.rac1.ons` on member `rac1`
Start of `ora.rac1.ons` on member `rac1` succeeded.
[oracle@rac1 u01]$ crs_stat -t
Name Type Target State Host
------------------------------------------------------------
ora....SM2.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....SM1.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
无意中网上看到一个脚本,很好的解决了这个问题,感谢作者的辛勤劳动。
crs_stat.sh
awk /
'BEGIN {printf "%-30s %-10s %-10s %-10s/n","Name ","Target ","State ","Host ";
printf "%-30s %-10s %-10s %-10s/n","------------------------------","----------", "---------","-------";}'
crs_stat | awk /
'BEGIN { FS="=| ";state = 0;}
$1~/NAME/ {appname = $2; state=1};
state == 0 {next;}
$1~/TARGET/ && state == 1 {apptarget = $2; state=2;}
$1~/STATE/ && state == 2 {appstate = $2; apphost = $4; state=3;}
state == 3 {printf "%-30s %-10s %-10s %-10s/n", appname,apptarget,appstate,apphost; state=0;}'
效果如下:
[oracle@rac1 u01]$ sh crs_stat.sh
Name Target State Host
------------------------------ ---------- --------- -------
ora.rac1.ASM2.asm ONLINE ONLINE rac1
ora.rac1.LISTENER_RAC1.lsnr ONLINE ONLINE rac1
ora.rac1.gsd ONLINE ONLINE rac1
ora.rac1.ons ONLINE ONLINE rac1
ora.rac1.vip ONLINE ONLINE rac1
ora.rac2.ASM1.asm ONLINE ONLINE rac2
ora.rac2.LISTENER_RAC2.lsnr ONLINE ONLINE rac2
ora.rac2.gsd ONLINE ONLINE rac2
ora.rac2.ons ONLINE ONLINE rac2
ora.rac2.vip ONLINE ONLINE rac2
通过这个脚本,可以完整的显示进程的名称。 我们操作的时候,就方便很多了。
---------------------------------------------------------------------------------------------------
QQ: 492913789
Email:ahdba@qq.com
Blog: http://www.cndba.cn/dave
DBA1 群:62697716(满); DBA2 群:62697977(满) DBA3 群:62697850(满)
DBA 超级群:63306533(满); DBA4 群: 83829929 DBA5群: 142216823
聊天 群:40132017
--加群需要在备注说明Oracle表空间和数据文件的关系,否则拒绝申请