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
更多参考:
有关Oracle RAC请参考
使用crs_setperm修改RAC资源的所有者及权限
使用crs_profile管理RAC资源配置文件
RAC 数据库的启动与关闭
再说 Oracle RAC services
Services in Oracle Database 10g
Migrate datbase from single instance to Oracle RAC
Oracle RAC 连接到指定实例
Oracle RAC 负载均衡测试(结合服务器端与客户端)
Oracle RAC 服务器端连接负载均衡(Load Balance)
Oracle RAC 客户端连接负载均衡(Load Balance)
ORACLE RAC 下非缺省端口监听配置(listener.ora tnsnames.ora)
ORACLE RAC 监听配置 (listener.ora tnsnames.ora)
配置 RAC 负载均衡与故障转移
CRS-1006 , CRS-0215 故障一例
基于Linux (RHEL 5.5) 安装Oracle 10g RAC
使用 runcluvfy 校验Oracle RAC安装环境
有关Oracle 网络配置相关基础以及概念性的问题请参考:
配置非默认端口的动态服务注册
配置sqlnet.ora限制IP访问Oracle
Oracle 监听器日志配置与管理
设置 Oracle 监听器密码(LISTENER)
配置ORACLE 客户端连接到数据库
有关基于用户管理的备份和备份恢复的概念请参考
Oracle 冷备份
Oracle 热备份
Oracle 备份恢复概念
Oracle 实例恢复
Oracle 基于用户管理恢复的处理
SYSTEM 表空间管理及备份恢复
SYSAUX表空间管理及恢复
Oracle 基于备份控制文件的恢复(unsing backup controlfile)
有关RMAN的备份恢复与管理请参考
RMAN 概述及其体系结构
RMAN 配置、监控与管理
RMAN 备份详解
RMAN 还原与恢复
RMAN catalog 的创建和使用
基于catalog 创建RMAN存储脚本
基于catalog 的RMAN 备份与恢复
RMAN 备份路径困惑
使用RMAN实现异机备份恢复(WIN平台)
使用RMAN迁移文件系统数据库到ASM
linux 下RMAN备份shell脚本
使用RMAN迁移数据库到异机
有关ORACLE体系结构请参考
Oracle 表空间与数据文件
Oracle 密码文件
Oracle 参数文件
Oracle 联机重做日志文件(ONLINE LOG FILE)
Oracle 控制文件(CONTROLFILE)
Oracle 归档日志
Oracle 回滚(ROLLBACK)和撤销(UNDO)
Oracle 数据库实例启动关闭过程
Oracle 10g SGA 的自动化管理
Oracle 实例和Oracle数据库(Oracle体系结构)