Srvctl命令详解(10g)
Srvctl命令 Srvctl命令式RAC维护中最常用的命令也是最复杂的命令。这个工具用来维护一下几种资源:Database,Instance,ASM,Service,Listener和Node Application,node Application又包括GSD,ONS,VIP。 Srvctl命令的用法: [root@felix2 bin]# ./srvctl -help
Srvctl命令
Srvctl命令式RAC维护中最常用的命令也是最复杂的命令。这个工具用来维护一下几种资源:Database,Instance,ASM,Service,Listener和Node Application,node Application又包括GSD,ONS,VIP。
Srvctl命令的用法:
[root@felix2 bin]# ./srvctl -help
Usage: srvctl
command:enable|disable|start|stop|relocate|status|add|remove|modify|getenv|setenv|unsetenv|config
objects:database|instance|service|nodeapps|asm|listener
For detailed help on each command and object andits options use:
srvctl
[root@felix2 bin]#
[root@felix1 bin]# ./srvctl -h
Usage: srvctl [-V]
Usage: srvctl add database -d
Usage: srvctl add instance -d
Usage: srvctl add service -d
Usage: srvctl add service -d
Usage: srvctl add nodeapps -n
Usage: srvctl add asm -n
Usage: srvctl config database
Usage: srvctl config database -d
Usage: srvctl config service -d
Usage: srvctl config nodeapps -n
Usage: srvctl config asm -n
Usage: srvctl config listener -n
Usage: srvctl disable database -d
Usage: srvctl disable instance -d
Usage: srvctl disable service -d
Usage: srvctl disable asm -n
Usage: srvctl enable database -d
Usage: srvctl enable instance -d
Usage: srvctl enable service -d
Usage: srvctl enable asm -n
Usage: srvctl getenv database -d
Usage: srvctl getenv instance -d
Usage: srvctl getenv service -d
Usage: srvctl getenv nodeapps -n
Usage: srvctl modify database -d
Usage: srvctl modify instance -d
Usage: srvctl modify instance -d
Usage: srvctl modify service -d
Usage: srvctl modify service -d
Usage: srvctl modify service -d
Usage: srvctl modify asm -n
Usage: srvctl modify nodeapps -n
Usage: srvctl relocate service -d
Usage: srvctl remove database -d
Usage: srvctl remove instance -d
Usage: srvctl remove service -d
Usage: srvctl remove nodeapps -n"
Usage: srvctl remove asm -n
Usage: srvctl setenv database -d
Usage: srvctl setenv instance -d
Usage: srvctl setenv service -d
Usage: srvctl setenv nodeapps -n
Usage: srvctl start database -d
Usage: srvctl start instance -d
Usage: srvctl start service -d
Usage: srvctl start nodeapps -n
Usage: srvctl start asm -n
Usage: srvctl start listener -n
Usage: srvctl status database -d
Usage: srvctl status instance -d
Usage: srvctl status service -d
Usage: srvctl status nodeapps -n
Usage: srvctl status asm -n
Usage: srvctl stop database -d
Usage: srvctl stop instance -d
Usage: srvctl stop service -d
Usage: srvctl stop nodeapps -n
Usage: srvctl stop asm -n
Usage: srvctl stop listener -n
Usage: srvctl unsetenv database -d
Usage: srvctl unsetenv instance -d
Usage: srvctl unsetenv service -d
Usage: srvctl unsetenv nodeapps -n
使用config查看配置
1.查看数据库配置。
[root@felix2 bin]# ./srvctl config database
felix
[root@felix2 bin]#
[root@felix2 bin]# ./srvctl config database -dfelix
felix1 felix1 /u01/oracle/10.2.0/db_1
felix2 felix2 /u01/oracle/10.2.0/db_1
[root@felix2 bin]#
[root@felix2 bin]# ./srvctl config database -dfelix -a
felix1 felix1 /u01/oracle/10.2.0/db_1
felix2 felix2 /u01/oracle/10.2.0/db_1
DB_UNIQUE_NAME: felix
DB_NAME: null
ORACLE_HOME: /u01/oracle/10.2.0/db_1
SPFILE: +DATA/felix/spfilefelix.ora
DOMAIN: null
DB_ROLE: null
START_OPTIONS: null
POLICY: AUTOMATIC
ENABLE FLAG: DB ENABLED
[root@felix2 bin]#
2.查看node Application的配置
[root@felix2 bin]# ./srvctl config nodeapps -nfelix
PRKC-1056 : Failed to get the hostname for nodefelix
PRKH-1001 : HASContext Internal Error
[OCRError(Native: getHostName:[21])]
[root@felix2 bin]# ./srvctl config nodeapps -nfelix1
felix1 felix1 /u01/oracle/10.2.0/db_1
[root@felix2 bin]# ./srvctl config nodeapps -nfelix1 -h
Usage: srvctl config nodeapps -n
-n
-a Display VIP configuration
-g Display GSD configuration
-s Display ONS daemonconfiguration
-l Display listenerconfiguration
-h Print usage
[root@felix2 bin]#
[root@felix2 bin]# ./srvctl config nodeapps -nfelix1 -a
VIP exists.:/felix1-vip/192.168.10.111/255.255.255.0/eth0
[root@felix2 bin]# ./srvctl config nodeapps -nfelix1 -g
GSD exists.
[root@felix2 bin]# ./srvctl config nodeapps -nfelix1 -s
ONS daemon exists.
[root@felix2 bin]# ./srvctl config nodeapps -nfelix1 -l
Listener exists.
3.产看监听状态
[root@felix2 bin]# ./srvctl config listener -nfelix1
felix1 LISTENER_FELIX1
4.查看ASM
[root@felix2 bin]# ./srvctl config asm -n felix2
+ASM2 /u01/oracle/10.2.0/db_1
[root@felix2 bin]#
5.查看service
[root@felix2 bin]# ./srvctl config service -h
Usage: srvctl config service -d
-d
-s
-a Additional attributes
-S
-h Print usage
[root@felix2 bin]#
使用add添加对象:
一般情况下,应用层的资源都是在图形化界面的帮助下注册到OCR中,比如VIP、ONS是在安装最后阶段创建的,而数据库、ASM是在执行DBCA的过程中自动注册到OCR中,LISTENER是通过NETCA工具。有写时候需要手工把资源注册到OCR中,这事就用到了add命令。
[root@felix1 bin]# ./srvctl -h
Usage: srvctl [-V]
Usage: srvctl add database -d
Usage: srvctl add instance -d
Usage: srvctl add service -d
Usage: srvctl add service -d
Usage: srvctl add nodeapps -n
Usage: srvctl add asm -n
Usage: srvctl config database
Usage: srvctl config database -d
Usage: srvctl config service -d
Usage: srvctl config nodeapps -n
Usage: srvctl config asm -n
Usage: srvctl config listener -n
Usage: srvctl disable database -d
Usage: srvctl disable instance -d
Usage: srvctl disable service -d
Usage: srvctl disable asm -n
Usage: srvctl enable database -d
Usage: srvctl enable instance -d
Usage: srvctl enable service -d
Usage: srvctl enable asm -n
Usage: srvctl getenv database -d
Usage: srvctl getenv instance -d
Usage: srvctl getenv service -d
Usage: srvctl getenv nodeapps -n
Usage: srvctl modify database -d
Usage: srvctl modify instance -d
Usage: srvctl modify instance -d
Usage: srvctl modify service -d
Usage: srvctl modify service -d
Usage: srvctl modify service -d
Usage: srvctl modify asm -n
Usage: srvctl modify nodeapps -n
Usage: srvctl relocate service -d
Usage: srvctl remove database -d
Usage: srvctl remove instance -d
Usage: srvctl remove service -d
Usage: srvctl remove nodeapps -n"
Usage: srvctl remove asm -n
Usage: srvctl setenv database -d
Usage: srvctl setenv instance -d
Usage: srvctl setenv service -d
Usage: srvctl setenv nodeapps -n
Usage: srvctl start database -d
Usage: srvctl start instance -d
Usage: srvctl start service -d
Usage: srvctl start nodeapps -n
Usage: srvctl start asm -n
Usage: srvctl start listener -n
Usage: srvctl status database -d
Usage: srvctl status instance -d
Usage: srvctl status service -d
Usage: srvctl status nodeapps -n
Usage: srvctl status asm -n
Usage: srvctl stop database -d
Usage: srvctl stop instance -d
Usage: srvctl stop service -d
Usage: srvctl stop nodeapps -n
Usage: srvctl stop asm -n
Usage: srvctl stop listener -n
Usage: srvctl unsetenv database -d
Usage: srvctl unsetenv instance -d
Usage: srvctl unsetenv service -d
Usage: srvctl unsetenv nodeapps -n
添加数据库
[oracle@felix1 conf]$ srvctl config database
Felix
[oracle@felix1 conf]$ srvctl add database -d felix001-o $ORACLE_HOME
[oracle@felix1 conf]$ srvctl config database
felix
felix001
[oracle@felix1 conf]$ srvctl remove database -dfelix001
Remove the database felix001? (y/[n]) y
[oracle@felix1 conf]$ srvctl config database
felix
[oracle@felix1 conf]$
添加实例
[oracle@felix1 conf]$ srvctl add instance -dfelix001 -h
Usage: srvctl add instance -d
-d
-i
-n
-h Print usage
[oracle@felix1 conf]$ srvctl add instance -dfelix001 -n felix1 -i inst_a1
[oracle@felix1 conf]$ srvctl remove instance -dfelix001 -h
Usage: srvctl remove instance -d
-d
-i
-f Force remove
-h Print usage
[oracle@felix1 conf]$ srvctl remove instance -dfelix001 -i inst_a1
Remove instance inst_a1 from the databasefelix001? (y/[n]) y
使用enable、disable启动和禁用对象
缺省情况下数据库、实例、服务、ASM都是随着CRS的启动而启动的,有时由于维护的需要可以先关闭这个特性。
(1) 配置数据库随CRS的启动而启动
[oracle@felix1 conf]$ srvctl config database -d felix -a
felix1 felix1 /u01/oracle/10.2.0/db_1
felix2 felix2 /u01/oracle/10.2.0/db_1
DB_UNIQUE_NAME: felix
DB_NAME: null
ORACLE_HOME: /u01/oracle/10.2.0/db_1
SPFILE: +DATA/felix/spfilefelix.ora
DOMAIN: null
DB_ROLE: null
START_OPTIONS: null
POLICY: AUTOMATIC
ENABLE FLAG: DB ENABLED
[oracle@felix1 conf]$
[oracle@felix1 conf]$ srvctl disable database -d felix
[oracle@felix1 conf]$ srvctl config database -d felix -a
felix1 felix1 /u01/oracle/10.2.0/db_1
felix2 felix2 /u01/oracle/10.2.0/db_1
DB_UNIQUE_NAME: felix
DB_NAME: null
ORACLE_HOME: /u01/oracle/10.2.0/db_1
SPFILE: +DATA/felix/spfilefelix.ora
DOMAIN: null
DB_ROLE: null
START_OPTIONS: null
POLICY: MANUAL
ENABLE FLAG: DB DISABLED, INST DISABLED ON felix1 felix2
[oracle@felix1 conf]$
[oracle@felix1 conf]$ srvctl enable database -d felix
[oracle@felix1 conf]$ srvctl config database -d felix -a
felix1 felix1 /u01/oracle/10.2.0/db_1
felix2 felix2 /u01/oracle/10.2.0/db_1
DB_UNIQUE_NAME: felix
DB_NAME: null
ORACLE_HOME: /u01/oracle/10.2.0/db_1
SPFILE: +DATA/felix/spfilefelix.ora
DOMAIN: null
DB_ROLE: null
START_OPTIONS: null
POLICY: AUTOMATIC
ENABLE FLAG: DB ENABLED
[oracle@felix1 conf]$
(2) 关闭某个实例的自动启动
[oracle@felix1 conf]$ srvctl config database -d felix -a
felix1 felix1 /u01/oracle/10.2.0/db_1
felix2 felix2 /u01/oracle/10.2.0/db_1
DB_UNIQUE_NAME: felix
DB_NAME: null
ORACLE_HOME: /u01/oracle/10.2.0/db_1
SPFILE: +DATA/felix/spfilefelix.ora
DOMAIN: null
DB_ROLE: null
START_OPTIONS: null
POLICY: AUTOMATIC
ENABLE FLAG: DB ENABLED
[oracle@felix1 conf]$ srvctl disable instance -d felix -i felix1
[oracle@felix1 conf]$ srvctl config database -d felix -a
felix1 felix1 /u01/oracle/10.2.0/db_1
felix2 felix2 /u01/oracle/10.2.0/db_1
DB_UNIQUE_NAME: felix
DB_NAME: null
ORACLE_HOME: /u01/oracle/10.2.0/db_1
SPFILE: +DATA/felix/spfilefelix.ora
DOMAIN: null
DB_ROLE: null
START_OPTIONS: null
POLICY: AUTOMATIC
ENABLE FLAG: DB ENABLED, INST DISABLED ON felix1
[oracle@felix1 conf]$ srvctl enable instance -d felix -i felix1