crs_register命令主要是将资源注册到CRS。该方法通常结合crs_stat -p 或者crs_profile先创建配置文件。同时crs_register也具有更新CRS的功能。本文将描述crs_register以及crs_unregister的用法。
在使用crs_register之前,可以使用crs_profile创建资源配置文件。缺省情况下,未指定配置文件的路径时,新创建的资源配置文件位于$ORA_CRS_HOME/crs/public 路径下,并且以.cap后缀结尾。有关crs_profile用法请参考:使用crs_profile管理RAC资源配置文件
- 1、crs_register与crs_unregister用法
- oracle@bo2dbp:~> crs_register
- Usage: crs_register resource_name [-dir directory_path] [...] [-u] [-f] [-q]
- crs_register resource_name -update [option ...] [-o option,...] -q
- oracle@bo2dbp:~> crs_unregister
- Usage: crs_unregister resource_name [...] [-q]
- 2、查看本机当前运行的服务
- oracle@bo2dbp:~> ./crs_stat.sh
- Resource name Target State
- -------------- ------ -----
- ora.GOBO4.GOBO4A.inst ONLINE ONLINE on bo2dbp
- ora.GOBO4.GOBO4B.inst ONLINE ONLINE on bo2dbs
- ora.GOBO4.GOBO4_SRV.GOBO4A.srv ONLINE ONLINE on bo2dbp
- ora.GOBO4.GOBO4_SRV.cs ONLINE ONLINE on bo2dbp
- ora.GOBO4.db ONLINE ONLINE on bo2dbs
- ora.bo2dbp.ASM1.asm ONLINE ONLINE on bo2dbp
- ora.bo2dbp.LISTENER_BO2DBP.lsnr ONLINE ONLINE on bo2dbp
- ora.bo2dbp.LISTENER_ORA10G_BO2DBP.lsnr ONLINE ONLINE on bo2dbp
- ora.bo2dbp.gsd ONLINE ONLINE on bo2dbp
- ora.bo2dbp.ons ONLINE ONLINE on bo2dbp
- ora.bo2dbp.vip ONLINE ONLINE on bo2dbp
- ora.bo2dbs.ASM2.asm ONLINE ONLINE on bo2dbs
- ora.bo2dbs.LISTENER_BO2DBS.lsnr ONLINE ONLINE on bo2dbs
- ora.bo2dbs.LISTENER_ORA10G_BO2DBS.lsnr ONLINE ONLINE on bo2dbs
- ora.bo2dbs.gsd ONLINE ONLINE on bo2dbs
- ora.bo2dbs.ons ONLINE ONLINE on bo2dbs
- ora.bo2dbs.vip ONLINE ONLINE on bo2dbs
- ora.ora10g.db ONLINE ONLINE on bo2dbs
- ora.ora10g.hr_ora10g.cs ONLINE ONLINE on bo2dbp
- ora.ora10g.hr_ora10g.ora10g1.srv ONLINE ONLINE on bo2dbp
- ora.ora10g.ora10g1.inst ONLINE ONLINE on bo2dbp
- ora.ora10g.ora10g2.inst ONLINE ONLINE on bo2dbs
- 3、使用crs_stat -p列出资源详细信息
- #下面列出了service hr_ora10g的详细信息
- #可以将下面的内容直接保存为配置文件(手工操作),等同于使用crs_profile
- oracle@bo2dbp:~> crs_stat -p ora.ora10g.hr_ora10g.ora10g1.srv
- NAME=ora.ora10g.hr_ora10g.ora10g1.srv
- TYPE=application
- ACTION_SCRIPT=/u01/oracle/db/bin/racgwrap
- ACTIVE_PLACEMENT=0
- AUTO_START=restore
- CHECK_INTERVAL=0
- DESCRIPTION=CRS application for Service Member
- FAILOVER_DELAY=0
- FAILURE_INTERVAL=0
- FAILURE_THRESHOLD=0
- HOSTING_MEMBERS=bo2dbp bo2dbs
- OPTIONAL_RESOURCES=ora.ora10g.ora10g2.inst
- PLACEMENT=restricted
- REQUIRED_RESOURCES=
- RESTART_ATTEMPTS=0
- SCRIPT_TIMEOUT=600
- START_TIMEOUT=0
- STOP_TIMEOUT=0
- UPTIME_THRESHOLD=7d
- USR_ORA_ALERT_NAME=
- USR_ORA_CHECK_TIMEOUT=0
- USR_ORA_CONNECT_STR=/ as sysdba
- USR_ORA_DEBUG=0
- USR_ORA_DISCONNECT=false
- USR_ORA_FLAGS=
- USR_ORA_IF=
- USR_ORA_INST_NOT_SHUTDOWN=
- USR_ORA_LANG=
- USR_ORA_NETMASK=
- USR_ORA_OPEN_MODE=
- USR_ORA_OPI=false
- USR_ORA_PFILE=
- USR_ORA_PRECONNECT=none
- USR_ORA_SRV=
- USR_ORA_START_TIMEOUT=0
- USR_ORA_STOP_MODE=immediate
- USR_ORA_STOP_TIMEOUT=0
- USR_ORA_VIP=
- 4、使用crs_profile命令创建资源配置文件
- oracle@bo2dbp:~> crs_profile -create ora.ora10g.hr_ora10g.ora10g1.srv -t application
- oracle@bo2dbp:~> cd /u01/oracle/crs/crs
- oracle@bo2dbp:/u01/oracle/crs/crs> ls
- admin auth demo init lib log mesg profile public script template trace
- oracle@bo2dbp:/u01/oracle/crs/crs> cd public
- #缺省情况下位于$ORA_CRS_HOME/crs/public,可以看到包含资源的全称,且以cap后缀结尾
- oracle@bo2dbp:/u01/oracle/crs/crs/public> ls
- action_scr.scr ora.ora10g.hr_ora10g.ora10g1.srv.cap
- #查看生成的资源配置文件
- oracle@bo2dbp:/u01/oracle/crs/crs/public> more ora.ora10g.hr_ora10g.ora10g1.srv.cap
- NAME=ora.ora10g.hr_ora10g.ora10g1.srv
- TYPE=application
- #注意,ACTION_SCRIPT输出的内容与之前使用crs_stat -p输出的内容不同
- ACTION_SCRIPT=/u01/oracle/crs/crs/public/ora.ora10g.hr_ora10g.ora10g1.srv.scr
- ACTIVE_PLACEMENT=0
- AUTO_START=restore
- CHECK_INTERVAL=60
- DESCRIPTION=ora.ora10g.hr_ora10g.ora10g1.srv
- FAILOVER_DELAY=0
- FAILURE_INTERVAL=0
- FAILURE_THRESHOLD=0
- HOSTING_MEMBERS=
- OPTIONAL_RESOURCES=
- PLACEMENT=balanced
- REQUIRED_RESOURCES=
- RESTART_ATTEMPTS=1
- SCRIPT_TIMEOUT=60
- START_TIMEOUT=0
- STOP_TIMEOUT=0
- UPTIME_THRESHOLD=7d
- USR_ORA_ALERT_NAME=
- USR_ORA_CHECK_TIMEOUT=0
- USR_ORA_CONNECT_STR=/ as sysdba
- USR_ORA_DEBUG=0
- USR_ORA_DISCONNECT=false
- USR_ORA_FLAGS=
- USR_ORA_IF=
- USR_ORA_INST_NOT_SHUTDOWN=
- USR_ORA_LANG=
- USR_ORA_NETMASK=
- USR_ORA_OPEN_MODE=
- USR_ORA_OPI=false
- USR_ORA_PFILE=
- USR_ORA_PRECONNECT=none
- USR_ORA_SRV=
- USR_ORA_START_TIMEOUT=0
- USR_ORA_STOP_MODE=immediate
- USR_ORA_STOP_TIMEOUT=0
- USR_ORA_VIP=
- #如果使用root帐户,则生成的文件会位于$ORA_CRS_HOME/crs/profile
- #非root用户则生成的文件会位于$ORA_CRS_HOME/crs/public
- 5、使用crs_unregister移出资源
- oracle@bo2dbp:~> crs_unregister ora.ora10g.hr_ora10g.ora10g1.srv
- CRS-0214: Could not unregister resource 'ora.ora10g.hr_ora10g.ora10g1.srv'. #提示无法移除资源,因为当前资源为start
- #下面首先将资源停止
- oracle@bo2dbp:~> crs_stop ora.ora10g.hr_ora10g.ora10g1.srv
- Attempting to stop `ora.ora10g.hr_ora10g.ora10g1.srv` on member `bo2dbp`
- Stop of `ora.ora10g.hr_ora10g.ora10g1.srv` on member `bo2dbp` succeeded.
- #再次移除该资源成功
- oracle@bo2dbp:~> crs_unregister ora.ora10g.hr_ora10g.ora10g1.srv
- #下面使用crs_stat已经查看不到被移除的资源
- oracle@bo2dbp:~> crs_stat ora.ora10g.hr_ora10g.ora10g1.srv
- CRS-0210: Could not find resource 'ora.ora10g.hr_ora10g.ora10g1.srv'.
- 6、使用crs_register注册资源到crs
- oracle@bo2dbp:~> crs_register ora.ora10g.hr_ora10g.ora10g1.srv
- Action Script `/u01/oracle/crs/crs/public/ora.ora10g.hr_ora10g.ora10g1.srv.scr` does not exist! #出现提交脚本文件不存在
- CRS-0213: Could not register resource 'ora.ora10g.hr_ora10g.ora10g1.srv'.
- #使用之前查看的脚本路径替换掉当前到处文件中的ACTION_SCRIPT下的内容
- oracle@bo2dbp:~> vi /u01/oracle/crs/crs/public/ora.ora10g.hr_ora10g.ora10g1.srv.cap
- #再次注册该资源时成功
- oracle@bo2dbp:~> crs_register ora.ora10g.hr_ora10g.ora10g1.srv
- #下面使用crs_stat已经可以看到刚刚注册的资源,其STATE处于OFFLINE
- oracle@bo2dbp:~> crs_stat ora.ora10g.hr_ora10g.ora10g1.srv
- NAME=ora.ora10g.hr_ora10g.ora10g1.srv
- TYPE=application
- TARGET=OFFLINE
- STATE=OFFLINE
- #Author :Robinson
- #Blog : http://blog.csdn.net/robinson_0612
- #下面使用crs_start来启动该资源
- oracle@bo2dbp:~> crs_start ora.ora10g.hr_ora10g.ora10g1.srv
- Attempting to start `ora.ora10g.hr_ora10g.ora10g1.srv` on member `bo2dbp`
- Start of `ora.ora10g.hr_ora10g.ora10g1.srv` on member `bo2dbp` succeeded.
- #再次查看时,TARGET与STATE都处于Online
- oracle@bo2dbp:~> crs_stat ora.ora10g.hr_ora10g.ora10g1.srv
- NAME=ora.ora10g.hr_ora10g.ora10g1.srv
- TYPE=application
- TARGET=ONLINE
- STATE=ONLINE on bo2dbp --->>转载于:http://blog.csdn.net/leshami/article/details/8239031