crs_stat -tName Type Target State Host ------------------------------------------------------------ora.DATA.dg ora....up.type ONLINE ONLINE node1 ora....ER.lsnr ora....er.type ONLINE ONLINE node1 ora....N1.lsnr ora....er.type ONLINE ONLINE node2 ora....N2.lsnr ora....er.type ONLINE ONLINE node1 ora....N3.lsnr ora....er.type ONLINE ONLINE node1 ora.OCR.dg ora....up.type ONLINE ONLINE node1 ora.VOTING.dg ora....up.type ONLINE ONLINE node1 ora.asm ora.asm.type ONLINE ONLINE node1 ora.eons ora.eons.type ONLINE ONLINE node1 ora.gsd ora.gsd.type OFFLINE OFFLINE ora.lotest.db ora....se.type ONLINE ONLINE node1 ora....network ora....rk.type ONLINE ONLINE node1 ora....SM1.asm application ONLINE ONLINE node1 ora....E1.lsnr application ONLINE ONLINE node1 ora.node1.gsd application OFFLINE OFFLINE ora.node1.ons application ONLINE ONLINE node1 ora.node1.vip ora....t1.type ONLINE ONLINE node1 ora....SM2.asm application ONLINE ONLINE node2 ora....E2.lsnr application ONLINE OFFLINE ora.node2.gsd application OFFLINE OFFLINE ora.node2.ons application ONLINE ONLINE node2 ora.node2.vip ora....t1.type ONLINE ONLINE node2 ora.oc4j ora.oc4j.type OFFLINE OFFLINE ora.ons ora.ons.type ONLINE ONLINE node1 ora....ry.acfs ora....fs.type ONLINE ONLINE node1 ora.scan1.vip ora....ip.type ONLINE ONLINE node2 ora.scan2.vip ora....ip.type ONLINE ONLINE node1 ora.scan3.vip ora....ip.type ONLINE ONLINE node1
可以直觀的列出各節點進程的狀態。 但是這個命令的不足之處,就是Name列,不能顯示全,那麼在使用的時候就有點不方便。比如我們啟動和關閉相關進程的時候。
比如:crs_start ora.node2.LISTENER_NODE2.lsnr
--我們這裡要寫全進程的名稱,如果名稱過長,就不能顯示全。
其實這個指令碼不夠是把crs_stat 顯示 行轉列下而已。
那麼我們來修理下ORACLE公司開發人員,這群丫的拿了錢,做的不咋友好。不就是指令碼嘛! 我們DIY去。。。。
##10g上使用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;}'
##11g 上使用awk 'BEGIN {printf "%-30s %-26s %-10s %-10s %-10s \n","Name ","Type ","Target ","State ","Host "; printf "%-30s %-26s %-10s %-10s %-10s\n","-----------------------------------","--------------------------","----------", "---------","-------";}'crs_stat | awk 'BEGIN { FS="=| ";state = 0;} $1~/NAME/ {appname = $2; state=1}; state == 0 {next;} $1~/TYPE/ && state == 1 {apptype = $2; state=2;} $1~/TARGET/ && state == 2 {apptarget = $2; state=3;} $1~/STATE/ && state == 3 {appstate = $2; apphost = $4; state=4;} state == 4 {printf "%-30s %-26s %-10s %-10s %-10s\n", appname,apptype,apptarget,appstate,apphost; state=0;}'猩猩酷酷找到了上面兩個指令碼。本來在大名頂頂Davi 也有一篇 http://blog.csdn.net/tianlesoftware/article/details/6269010不過這位老兄的指令碼awk 後面帶了個"/" 在redhat linux 5.3 x64下 老是報錯. 兄弟我不才,awk不懂! linux下很多東西太複雜,太難學,太難記憶了。所以大家還是用上面兩個指令碼。各位把上面指令碼放進VI編輯器時候注意分行符號\n\r,知道大家都喜歡COPY TO。把指令碼的換行刪除掉,變成2行。awk 'BEGIN.................crs_stat | awk 'BEGIN...........
我們vi crstat.sh 編輯完後。mv crstat.sh crstat
付許可權 chmod a+x crstat
然後切換成root使用者下 cp crstat /bin 這樣讓root grid 使用者都可以使用。
為了讓oracle 使用者也用上 vi ~/.bash_profile 添加
export GRID_BIN=/...........----grid用的 bin 主要是調用crs_stat命令 可以在grid用下which它下
這樣我們就很爽了 隨時隨地敲入 crstat 就顯示
[oracle@node1 dbscripts]$ crstatName Type Target State Host ----------------------------------- ------------------------------ ---------- --------- ------- ora.DATA.dg ora.diskgroup.type ONLINE ONLINE node1 ora.LISTENER.lsnr ora.listener.type ONLINE ONLINE node1 ora.LISTENER_SCAN1.lsnr ora.scan_listener.type ONLINE ONLINE node2 ora.LISTENER_SCAN2.lsnr ora.scan_listener.type ONLINE ONLINE node1 ora.LISTENER_SCAN3.lsnr ora.scan_listener.type ONLINE ONLINE node1 ora.OCR.dg ora.diskgroup.type ONLINE ONLINE node1 ora.VOTING.dg ora.diskgroup.type ONLINE ONLINE node1 ora.asm ora.asm.type ONLINE ONLINE node1 ora.eons ora.eons.type ONLINE ONLINE node1 ora.gsd ora.gsd.type OFFLINE OFFLINE ora.lotest.db ora.database.type ONLINE ONLINE node1 ora.net1.network ora.network.type ONLINE ONLINE node1 ora.node1.ASM1.asm application ONLINE ONLINE node1 ora.node1.LISTENER_NODE1.lsnr application ONLINE ONLINE node1 ora.node1.gsd application OFFLINE OFFLINE ora.node1.ons application ONLINE ONLINE node1 ora.node1.vip ora.cluster_vip_net1.type ONLINE ONLINE node1 ora.node2.ASM2.asm application ONLINE ONLINE node2 ora.node2.LISTENER_NODE2.lsnr application ONLINE OFFLINE ora.node2.gsd application OFFLINE OFFLINE ora.node2.ons application ONLINE ONLINE node2 ora.node2.vip ora.cluster_vip_net1.type ONLINE ONLINE node2 ora.oc4j ora.oc4j.type OFFLINE OFFLINE ora.ons ora.ons.type ONLINE ONLINE node1 ora.registry.acfs ora.registry.acfs.type ONLINE ONLINE node1 ora.scan1.vip ora.scan_vip.type ONLINE ONLINE node2 ora.scan2.vip ora.scan_vip.type ONLINE ONLINE node1 ora.scan3.vip ora.scan_vip.type ONLINE ONLINE node1