RAC中的srvctl和crs命令

srvctl 命令

$ srvctl -h
Usage: srvctl [-V]
Usage: srvctl add database -d -o [-m ] [-p ] [-A /netmask] [-r {PRIMARY | PHYSICAL_STANDBY | LOGICAL_STANDBY}] [-s ] [-n ] [-y {AUTOMATIC | MANUAL}]
Usage: srvctl add instance -d -i -n
Usage: srvctl add service -d -s -r "" [-a ""] [-P ]
Usage: srvctl add service -d -s -u {-r "" | -a ""}
Usage: srvctl add nodeapps -n -o -A /netmask[/if1[|if2|...]]
Usage: srvctl add asm -n -i -o [-p ]
Usage: srvctl config database
Usage: srvctl config database -d [-a] [-t]
Usage: srvctl config service -d [-s ] [-a] [-S ]
Usage: srvctl config nodeapps -n [-a] [-g] [-s] [-l]
Usage: srvctl config asm -n
Usage: srvctl config listener -n
Usage: srvctl disable database -d
Usage: srvctl disable instance -d -i ""
Usage: srvctl disable service -d -s "" [-i ]
Usage: srvctl disable asm -n [-i ]
Usage: srvctl enable database -d
Usage: srvctl enable instance -d -i ""
Usage: srvctl enable service -d -s "" [-i ]
Usage: srvctl enable asm -n [-i ]
Usage: srvctl getenv database -d [-t ""]
Usage: srvctl getenv instance -d -i [-t ""]
Usage: srvctl getenv service -d -s [-t ""]
Usage: srvctl getenv nodeapps -n [-t ""]
Usage: srvctl modify database -d [-n ] [-m ] [-p ]  [-r {PRIMARY | PHYSICAL_STANDBY | LOGICAL_STANDBY}] [-s ] [-y {AUTOMATIC | MANUAL}]
Usage: srvctl modify instance -d -i -n
Usage: srvctl modify instance -d -i {-s | -r}
Usage: srvctl modify service -d -s -i -t [-f]
Usage: srvctl modify service -d -s -i -r [-f]
Usage: srvctl modify service -d -s -n -i [-a ] [-f]
Usage: srvctl modify asm -n -i [-o ] [-p ]
Usage: srvctl modify nodeapps -n [-o ] [-A ]
Usage: srvctl relocate service -d -s -i -t [-f]
Usage: srvctl remove database -d [-f]
Usage: srvctl remove instance -d -i [-f]
Usage: srvctl remove service -d -s [-i ] [-f]
Usage: srvctl remove nodeapps -n "" [-f]
Usage: srvctl remove asm -n [-i ] [-f]
Usage: srvctl setenv database -d {-t =[,=,...] | -T =}
Usage: srvctl setenv instance -d [-i ] {-t "=[,=,...]" | -T "="}
Usage: srvctl setenv service -d [-s ] {-t "=[,=,...]" | -T "="}
Usage: srvctl setenv nodeapps -n {-t "=[,=,...]" | -T "="}
Usage: srvctl start database -d [-o ]
Usage: srvctl start instance -d -i "" [-o ]
Usage: srvctl start service -d [-s "" [-i ]] [-o ]
Usage: srvctl start nodeapps -n
Usage: srvctl start asm -n [-i ] [-o ]
Usage: srvctl start listener -n [-l ]
Usage: srvctl status database -d [-f] [-v] [-S ]
Usage: srvctl status instance -d -i "" [-f] [-v] [-S ]
Usage: srvctl status service -d [-s ""] [-f] [-v] [-S ]
Usage: srvctl status nodeapps -n
Usage: srvctl status asm -n
Usage: srvctl stop database -d [-o ]
Usage: srvctl stop instance -d -i "" [-o ]
Usage: srvctl stop service -d [-s "" [-i ]] [-f]
Usage: srvctl stop nodeapps -n [-r]
Usage: srvctl stop asm -n [-i ] [-o ]
Usage: srvctl stop listener -n [-l ]
Usage: srvctl unsetenv database -d -t ""
Usage: srvctl unsetenv instance -d [-i ] -t ""
Usage: srvctl unsetenv service -d [-s ] -t ""
Usage: srvctl unsetenv nodeapps -n -t ""
$
从上我们可以看到 srvctl 这个命令工具很强大,可以操作 database, instance ,asm ,service , listener,nodeapps (gsd,vip ,ons)这些资源
 
1.通过srvctl命令来start/stop/check所有的实例
$srvctl start|stop|status database -d rac1
[oracle@rac1 ~]$ srvctl status database -d testrac
Instance testrac1 is running on node rac1
Instance testrac2 is running on node rac2
 
2.start/stop 指定的实例
$srvctl start |stop |status instance -d -i
[oracle@rac1 ~]$ srvctl status instance  -d testrac -i testrac1
Instance testrac1 is running on node rac1
 
3.列出当前rac下所有的
$ srvctl config database -d
[oracle@rac1 ~]$ srvctl config database -d testrac
rac1 testrac1 /u01/product/database
rac2 testrac2 /u01/product/database
 
4.start/stop/check 所有的nodeapps,比如:VIP, GSD, listener, ONS:
$ srvctl start|stop|status nodeapps -n
[oracle@rac1 ~]$ srvctl status nodeapps -n rac1
VIP is running on node: rac1
GSD is running on node: rac1
Listener is running on node: rac1
ONS daemon is running on node: rac1
 
5.srvctl也可以start/stop ASM实例:
$ srvctl start|stop asm -n [-i ] [-o]
[oracle@rac1 ~]$ srvctl start asm -n rac1
 
6.获取所有的环境信息
$ srvctl getenv database -d [-i ]
 
7.设置全局环境变量:
$ srvctl setenv database -d -t LANG=en
 
8.从OCR中删除已有的数据库:
$ srvctl remove database -d
 
9.向OCR中添加一个数据库:
$ srvctl add database -d -o [-m ] [-p] [-A /netmask] [-r {PRIMARY | PHYSICAL_STANDBY |LOGICAL_STANDBY}] [-s ]
 
10.向OCR中添加一个数据库的实例:
$ srvctl add instance -d -i -n
 
11.向OCR中添加一个ASM实例:
$ srvctl add asm -n -i -o
 
12.添加一个service
$ srvctl add service -d -s -r [-a ] [-P ] [-u]
例如:
srvctl add service -d msdb -s msrac -r msdb1 -a msdb2 -P preconnect
新建了一个服务名叫“msrac”,首先调用msdb1服务器,若有问题则自动调用msdb2服务器。
调用RAC中的该服务,只需要注意URL中的service_name为上面配置的“msrac”即可。
jdbc:oracle:thin:@(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = racdb3-vip)(PORT = 1521))(ADDRESS = (PROTOCOL = TCP)(HOST = racdb4-vip)(PORT = 1521))(CONNECT_DATA =(SERVER = DEDICATED)( SERVICE_NAME = msrac)(FAILOVER_MODE =(TYPE = SELECT)(METHOD = PRECONNECT)(RETRIES = 180)(DELAY = 5))))
 
13.修改在其他节点上的service(修改的是配置,此时使用的实例不变)
$ srvctl modify service -d -s -i -t
 
14.relocate 某个节点的service到其他节点(当taf转到avail实例上后,又想转到pre的实例上,用relocate)
srvctl relocate service -d -s - i -t
 
crs 命令

1.查看状态的命令
Usage:  crs_stat [resource_name [...]] [-v] [-l] [-q] [-c cluster_member]
        crs_stat [resource_name [...]] -t [-v] [-q] [-c cluster_member]
        crs_stat -p [resource_name [...]] [-q]
        crs_stat [-a] application -g
        crs_stat [-a] application -r [-c cluster_member]
        crs_stat -f [resource_name [...]] [-q] [-c cluster_member]
        crs_stat -ls [resource_name [...]] [-q]
 
$crs_stat -t 查看crs及所有的service的状态
[oracle@rac1 ~]$ crs_stat -t
Name           Type           Target    State     Host       
------------------------------------------------------------
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    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       
ora.testrac.db application    ONLINE    ONLINE    rac1       
ora....c1.inst application    ONLINE    ONLINE    rac1       
ora....c2.inst application    ONLINE    ONLINE    rac2  
 
2.crsctl check crs  检查CRS相关服务状态
[oracle@rac1 ~]$ crsctl check crs
CSS appears healthy
CRS appears healthy
EVM appears healthy
 
3.启动和关闭命令
$ crs_start –all --启动所有的crs服务
$ crs_stop –all --停止所有的crs服务
$ crsctl start crs --启动crs服务
$ crsctl stop crs --停止crs服务
$ srvctl start nodeapps -n rac1(rac2) --启动某节点上所有的应用
$ srvctl stop nodeapps -n rac1(rac2) --停止某节点上所有的应用
$ srvctl start listener -n rac1(rac2) --启动某个节点的listener
$ srvctl stop listener -n rac1(rac2) --停止某个节点的listener
$ srvctl start instance –d db –i rac1(rac2) --启动某个instance
$ srvctl stop instance –d db –i rac1(rac2) --停止某个instance
$ srvctl start database –d db --启动数据库
$ srvctl stop database –d db --停止数据库

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/9399028/viewspace-697128/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/9399028/viewspace-697128/

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值