crs_stat -t命令查看资源名称不完整,如下:

[oracle@RAC1 shell]$ crs_stat -t
Name           Type           Target    State     Host        
------------------------------------------------------------
ora....C1.inst application    ONLINE    ONLINE    rac1        
ora....C2.inst application    ONLINE    OFFLINE               
ora....AC1.srv application    OFFLINE   OFFLINE               
ora.....TAF.cs application    OFFLINE   OFFLINE               
ora.HXWRAC.db  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    OFFLINE               
ora....C2.lsnr application    ONLINE    OFFLINE               
ora.rac2.gsd   application    ONLINE    OFFLINE               
ora.rac2.ons   application    ONLINE    OFFLINE               
ora.rac2.vip   application    ONLINE    ONLINE    rac1

 



这样查看非常不方便,crs_stat输出格式如下:

[oracle@RAC1 shell]$ crs_stat
NAME=ora.HXWRAC.HXWRAC1.inst
TYPE=application
TARGET=ONLINE
STATE=ONLINE on rac1

NAME=ora.HXWRAC.HXWRAC2.inst
TYPE=application
TARGET=ONLINE
STATE=OFFLINE

NAME=ora.HXWRAC.TAF.HXWRAC1.srv
TYPE=application
TARGET=OFFLINE
STATE=OFFLINE

NAME=ora.HXWRAC.TAF.cs
TYPE=application
TARGET=OFFLINE
STATE=OFFLINE

NAME=ora.HXWRAC.db
TYPE=application
TARGET=ONLINE
STATE=ONLINE on rac1

NAME=ora.rac1.ASM1.asm
TYPE=application
TARGET=ONLINE
STATE=ONLINE on rac1

NAME=ora.rac1.LISTENER_RAC1.lsnr
TYPE=application
TARGET=ONLINE
STATE=ONLINE on rac1

NAME=ora.rac1.gsd
TYPE=application
TARGET=ONLINE
STATE=ONLINE on rac1

NAME=ora.rac1.ons
TYPE=application
TARGET=ONLINE
STATE=ONLINE on rac1

NAME=ora.rac1.vip
TYPE=application
TARGET=ONLINE
STATE=ONLINE on rac1

NAME=ora.rac2.ASM2.asm
TYPE=application
TARGET=ONLINE
STATE=OFFLINE

NAME=ora.rac2.LISTENER_RAC2.lsnr
TYPE=application
TARGET=ONLINE
STATE=OFFLINE

NAME=ora.rac2.gsd
TYPE=application
TARGET=ONLINE
STATE=OFFLINE

NAME=ora.rac2.ons
TYPE=application
TARGET=ONLINE
STATE=OFFLINE

NAME=ora.rac2.vip
TYPE=application
TARGET=ONLINE
STATE=ONLINE on rac1



代码如下:

crs_stat | awk -F "=" 'BEGIN {printf "%-35s %-15s %-15s %-15s %-15s\n", "NAME","TYPE" ,"Target", "State","HOST"}
{a[$1]=$2;if(length($0)==0){x=split(a["STATE"],o," ");host=x>1?o[3]:"";
printf "%-35s %-15s %-15s %-15s %-15s\n",a["NAME"],a["TYPE"],a["TARGET"],o[1],host}}'


输出如下,可以看到完整的名称,方便:


NAME                                TYPE            Target          State           HOST           
ora.HXWRAC.HXWRAC1.inst             application     ONLINE          ONLINE          rac1           
ora.HXWRAC.HXWRAC2.inst             application     ONLINE          OFFLINE                        
ora.HXWRAC.TAF.HXWRAC1.srv          application     OFFLINE         OFFLINE                        
ora.HXWRAC.TAF.cs                   application     OFFLINE         OFFLINE                        
ora.HXWRAC.db                       application     ONLINE          ONLINE          rac1           
ora.rac1.ASM1.asm                   application     ONLINE          ONLINE          rac1           
ora.rac1.LISTENER_RAC1.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.rac2.ASM2.asm                   application     ONLINE          OFFLINE                        
ora.rac2.LISTENER_RAC2.lsnr         application     ONLINE          OFFLINE                        
ora.rac2.gsd                        application     ONLINE          OFFLINE                        
ora.rac2.ons                        application     ONLINE          OFFLINE                        
ora.rac2.vip                        application     ONLINE          ONLINE          rac1