:v/NAME/d
仅此一条短小精悍的命令,可将不包含“NAME”的所有行一次性的删除掉,使用这种方法可以非常方便并快速地编辑停止RAC服务的脚本,具体操作如下:
RACDB1@rac1 /home/oracle$crs_stat > shutdown_services.sh
RACDB1@rac1 /home/oracle$vi shutdown_services.sh
NAME=ora.RACDB.RACDB1.inst
TYPE=application
TARGET=ONLINE
STATE=ONLINE on rac1
NAME=ora.RACDB.RACDB2.inst
TYPE=application
TARGET=ONLINE
STATE=ONLINE on rac2
NAME=ora.RACDB.db
TYPE=application
TARGET=ONLINE
STATE=ONLINE on rac1
NAME=ora.RACDB.racdb_taf.RACDB1.srv
TYPE=application
TARGET=ONLINE
STATE=ONLINE on rac1
:v/NAME/d
操作完成之后效果如下:
NAME=ora.RACDB.RACDB1.inst
NAME=ora.RACDB.RACDB2.inst
NAME=ora.RACDB.db
NAME=ora.RACDB.racdb_taf.RACDB1.srv
NAME=ora.RACDB.racdb_taf.RACDB2.srv
NAME=ora.RACDB.racdb_taf.cs
NAME=ora.rac1.ASM1.asm
NAME=ora.rac1.LISTENER_RAC1.lsnr
NAME=ora.rac1.gsd
NAME=ora.rac1.ons
NAME=ora.rac1.vip
NAME=ora.rac2.ASM2.asm
NAME=ora.rac2.LISTENER_RAC2.lsnr
NAME=ora.rac2.gsd
NAME=ora.rac2.ons
NAME=ora.rac2.vip
~
~
~
~
64 fewer lines 16,1 All
再使用“:%s/NAME=/crs_stop /g” 及完成该脚本的编辑,编辑后的脚本如下:
RACDB1@rac1 /home/oracle$cat shutdown_services.sh
crs_stop ora.RACDB.RACDB1.inst
crs_stop ora.RACDB.RACDB2.inst
crs_stop ora.RACDB.db
crs_stop ora.RACDB.racdb_taf.RACDB1.srv
crs_stop ora.RACDB.racdb_taf.RACDB2.srv
crs_stop ora.RACDB.racdb_taf.cs
crs_stop ora.rac1.ASM1.asm
crs_stop ora.rac1.LISTENER_RAC1.lsnr
crs_stop ora.rac1.gsd
crs_stop ora.rac1.ons
crs_stop ora.rac1.vip
crs_stop ora.rac2.ASM2.asm
crs_stop ora.rac2.LISTENER_RAC2.lsnr
crs_stop ora.rac2.gsd
crs_stop ora.rac2.ons
crs_stop ora.rac2.vip