• 博客访问: 1033814
  • 博文数量: 442
  • 用 户 组: 普通用户
  • 注册时间: 2007-12-30 18:35
个人简介

暂无介绍

ITPUB论坛APP

ITPUB论坛APP



APP发帖 享双倍积分

文章分类

全部博文(442)

文章存档

2011年(22)

2010年(13)

2008年(22)

2007年(229)

2006年(106)

2005年(50)

我的朋友
微信关注

IT168企业级官微



微信号:IT168qiye



系统架构师大会



微信号:SACC2013

让crs_stat显示更直观明了 2011-04-13 20:45:29

分类: Oracle

RAC中默认的crs_stat显示信息不全,也不够直观,如:

[@more@]

[oracle@test04 bdump]$ /oracle/product/10.2.0/crs/bin/crs_stat -t
Name Type Target State Host
------------------------------------------------------------
ora....SM1.asm application ONLINE ONLINE test01
ora....01.lsnr application ONLINE ONLINE test01
ora.test01.gsd application ONLINE ONLINE test01
ora.test01.ons application ONLINE ONLINE test01
ora.test01.vip application ONLINE ONLINE test01
ora....SM2.asm application ONLINE ONLINE test02
ora....02.lsnr application ONLINE ONLINE test02
ora.test02.gsd application ONLINE ONLINE test02
ora.test02.ons application ONLINE ONLINE test02
ora.test02.vip application ONLINE ONLINE test02
ora....SM3.asm application ONLINE ONLINE test03
ora....03.lsnr application ONLINE ONLINE test03
ora.test03.gsd application ONLINE ONLINE test03
ora.test03.ons application ONLINE ONLINE test03
ora.test03.vip application ONLINE ONLINE test03
ora....SM4.asm application ONLINE ONLINE test04
ora....04.lsnr application ONLINE ONLINE test04
ora.test04.gsd application ONLINE ONLINE test04
ora.test04.ons application ONLINE ONLINE test04
ora.test04.vip application ONLINE ONLINE test04
ora.dwrac.db application ONLINE ONLINE test02
ora....c.dw.cs application ONLINE ONLINE test01
ora....ac1.srv application ONLINE ONLINE test01
ora....ac2.srv application ONLINE ONLINE test02
ora....ac3.srv application ONLINE ONLINE test03
ora....ac4.srv application ONLINE ONLINE test04
ora....c1.inst application ONLINE ONLINE test01
ora....c2.inst application ONLINE ONLINE test02
ora....c3.inst application ONLINE ONLINE test03
ora....c4.inst application ONLINE ONLINE test04

可以通过以下脚本封装一下crs_stat命令,让结果显示得更直观明了:

[oracle@test04 bdump]$ vi /usr/bin/crs_stat

export ORACLE_BASE=/oracle
export ORA_CRS_HOME=$ORACLE_BASE/product/10.2.0/crs
export ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db

RSC_KEY=$1
QSTAT=-u
AWK=/usr/bin/awk # if not available use /usr/bin/awk

# Table header:echo ""
$AWK
'BEGIN {printf "%-45s %-10s %-18sn", "HA Resource", "Target", "State";
printf "%-45s %-10s %-18sn", "-----------", "------", "-----";}'

# Table body:
$ORA_CRS_HOME/bin/crs_stat $QSTAT | $AWK
'BEGIN { FS="="; state = 0; }
$1~/NAME/ && $2~/'$RSC_KEY'/ {appname = $2; state=1};
state == 0 {next;}
$1~/TARGET/ && state == 1 {apptarget = $2; state=2;}
$1~/STATE/ && state == 2 {appstate = $2; state=3;}
state == 3 {printf "%-45s %-10s %-18sn", appname, apptarget, appstate; state=0;}'


echo "------------------------"

$ORA_CRS_HOME/bin/crs_stat $QSTAT |grep STATE|sort|uniq -c

--------------------------------------------------------------
[oracle@test04 bdump]$ crs_stat
HA Resource Target State
----------- ------ -----
ora.test01.ASM1.asm ONLINE ONLINE on test01
ora.test01.LISTENER_test01.lsnr ONLINE ONLINE on test01
ora.test01.gsd ONLINE ONLINE on test01
ora.test01.ons ONLINE ONLINE on test01
ora.test01.vip ONLINE ONLINE on test01
ora.test02.ASM2.asm ONLINE ONLINE on test02
ora.test02.LISTENER_test02.lsnr ONLINE ONLINE on test02
ora.test02.gsd ONLINE ONLINE on test02
ora.test02.ons ONLINE ONLINE on test02
ora.test02.vip ONLINE ONLINE on test02
ora.test03.ASM3.asm ONLINE ONLINE on test03
ora.test03.LISTENER_test03.lsnr ONLINE ONLINE on test03
ora.test03.gsd ONLINE ONLINE on test03
ora.test03.ons ONLINE ONLINE on test03
ora.test03.vip ONLINE ONLINE on test03
ora.test04.ASM4.asm ONLINE ONLINE on test04
ora.test04.LISTENER_test04.lsnr ONLINE ONLINE on test04
ora.test04.gsd ONLINE ONLINE on test04
ora.test04.ons ONLINE ONLINE on test04
ora.test04.vip ONLINE ONLINE on test04
ora.dwrac.db ONLINE ONLINE on test02
ora.dwrac.dw.cs ONLINE ONLINE on test01
ora.dwrac.dw.dwrac1.srv ONLINE ONLINE on test01
ora.dwrac.dw.dwrac2.srv ONLINE ONLINE on test02
ora.dwrac.dw.dwrac3.srv ONLINE ONLINE on test03
ora.dwrac.dw.dwrac4.srv ONLINE ONLINE on test04
ora.dwrac.dwrac1.inst ONLINE ONLINE on test01
ora.dwrac.dwrac2.inst ONLINE ONLINE on test02
ora.dwrac.dwrac3.inst ONLINE ONLINE on test03
ora.dwrac.dwrac4.inst ONLINE ONLINE on test04
------------------------
8 STATE=ONLINE on test01
8 STATE=ONLINE on test02
7 STATE=ONLINE on test03
7 STATE=ONLINE on test04

阅读(2902) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~
评论热议
请登录后评论。

登录 注册