Srvctl命令详解(10g)「建议收藏」

2022-10-03 16:43:59 浏览数 (1)

大家好,又见面了,我是你们的朋友全栈君。

Srvctl命令

Srvctl命令式RAC维护中最常用的命令也是最复杂的命令。这个工具用来维护一下几种资源:Database,Instance,ASM,Service,Listener和Node Application,node Application又包括GSD,ONS,VIP。

Srvctl命令的用法:

[root@felix2 bin]# ./srvctl -help

Usage: srvctl <command> <object>[<options>]

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<command> <object> -h

[root@felix2 bin]#

[root@felix1 bin]# ./srvctl -h

Usage: srvctl [-V]

Usage: srvctl add database -d <name> -o<oracle_home> [-m <domain_name>] [-p <spfile>] [-A<name|ip>/netmask] [-r {PRIMARY | PHYSICAL_STANDBY | LOGICAL_STANDBY}][-s <start_options>] [-n <db_name>] [-y {AUTOMATIC | MANUAL}]

Usage: srvctl add instance -d <name> -i<inst_name> -n <node_name>

Usage: srvctl add service -d <name> -s<service_name> -r “<preferred_list>” [-a “<available_list>”][-P <TAF_policy>]

Usage: srvctl add service -d <name> -s<service_name> -u {-r “<new_pref_inst>” | -a”<new_avail_inst>”}

Usage: srvctl add nodeapps -n <node_name> -o<oracle_home> -A <name|ip>/netmask[/if1[|if2|…]]

Usage: srvctl add asm -n <node_name> -i<asm_inst_name> -o <oracle_home> [-p <spfile>]

Usage: srvctl config database

Usage: srvctl config database -d <name> [-a][-t]

Usage: srvctl config service -d <name> [-s<service_name>] [-a] [-S <level>]

Usage: srvctl config nodeapps -n <node_name>[-a] [-g] [-s] [-l]

Usage: srvctl config asm -n <node_name>

Usage: srvctl config listener -n <node_name>

Usage: srvctl disable database -d <name>

Usage: srvctl disable instance -d <name> -i”<inst_name_list>”

Usage: srvctl disable service -d <name> -s”<service_name_list>” [-i <inst_name>]

Usage: srvctl disable asm -n <node_name> [-i<inst_name>]

Usage: srvctl enable database -d <name>

Usage: srvctl enable instance -d <name> -i”<inst_name_list>”

Usage: srvctl enable service -d <name> -s”<service_name_list>” [-i <inst_name>]

Usage: srvctl enable asm -n <node_name> [-i<inst_name>]

Usage: srvctl getenv database -d <name> [-t”<name_list>”]

Usage: srvctl getenv instance -d <name> -i<inst_name> [-t “<name_list>”]

Usage: srvctl getenv service -d <name> -s<service_name> [-t “<name_list>”]

Usage: srvctl getenv nodeapps -n <node_name>[-t “<name_list>”]

Usage: srvctl modify database -d <name> [-n<db_name] [-o <ohome>] [-m <domain>] [-p <spfile>] [-r {PRIMARY | PHYSICAL_STANDBY |LOGICAL_STANDBY}] [-s <start_options>] [-y {AUTOMATIC | MANUAL}]

Usage: srvctl modify instance -d <name> -i<inst_name> -n <node_name>

Usage: srvctl modify instance -d <name> -i<inst_name> {-s <asm_inst_name> | -r}

Usage: srvctl modify service -d <name> -s<service_name> -i <old_inst_name> -t <new_inst_name> [-f]

Usage: srvctl modify service -d <name> -s<service_name> -i <avail_inst_name> -r [-f]

Usage: srvctl modify service -d <name> -s<service_name> -n -i <prefered_inst> [-a <available_list>][-f]

Usage: srvctl modify asm -n <node_name> -i<asm_inst_name> [-o <oracle_home>] [-p <spfile>]

Usage: srvctl modify nodeapps -n <node_name>[-o <oracle_home>] [-A <new_vip_address>]

Usage: srvctl relocate service -d <name> -s<service_name> -i <old_inst_name> -t <new_inst_name> [-f]

Usage: srvctl remove database -d <name> [-f]

Usage: srvctl remove instance -d <name> -i<inst_name> [-f]

Usage: srvctl remove service -d <name> -s<service_name> [-i <inst_name>] [-f]

Usage: srvctl remove nodeapps -n”<node_name_list>” [-f]

Usage: srvctl remove asm -n <node_name> [-i<asm_inst_name>] [-f]

Usage: srvctl setenv database -d <name> {-t<name>=<val>[,<name>=<val>,…] | -T<name>=<val>}

Usage: srvctl setenv instance -d <name> [-i<inst_name>] {-t”<name>=<val>[,<name>=<val>,…]” | -T”<name>=<val>”}

Usage: srvctl setenv service -d <name> [-s<service_name>] {-t”<name>=<val>[,<name>=<val>,…]” | -T”<name>=<val>”}

Usage: srvctl setenv nodeapps -n <node_name>{-t “<name>=<val>[,<name>=<val>,…]” | -T”<name>=<val>”}

Usage: srvctl start database -d <name> [-o<start_options>]

Usage: srvctl start instance -d <name> -i”<inst_name_list>” [-o <start_options>]

Usage: srvctl start service -d <name> [-s”<service_name_list>” [-i <inst_name>]] [-o<start_options>]

Usage: srvctl start nodeapps -n <node_name>

Usage: srvctl start asm -n <node_name> [-i<asm_inst_name>] [-o <start_options>]

Usage: srvctl start listener -n <node_name>[-l <lsnr_name_list>]

Usage: srvctl status database -d <name> [-f][-v] [-S <level>]

Usage: srvctl status instance -d <name> -i”<inst_name_list>” [-f] [-v] [-S <level>]

Usage: srvctl status service -d <name> [-s”<service_name_list>”] [-f] [-v] [-S <level>]

Usage: srvctl status nodeapps -n <node_name>

Usage: srvctl status asm -n <node_name>

Usage: srvctl stop database -d <name> [-o<stop_options>]

Usage: srvctl stop instance -d <name> -i”<inst_name_list>” [-o <stop_options>]

Usage: srvctl stop service -d <name> [-s”<service_name_list>” [-i <inst_name>]] [-f]

Usage: srvctl stop nodeapps -n <node_name>[-r]

Usage: srvctl stop asm -n <node_name> [-i<asm_inst_name>] [-o <stop_options>]

Usage: srvctl stop listener -n <node_name>[-l <lsnr_name_list>]

Usage: srvctl unsetenv database -d <name> -t”<name_list>”

Usage: srvctl unsetenv instance -d <name>[-i <inst_name>] -t “<name_list>”

Usage: srvctl unsetenv service -d <name> [-s<service_name>] -t “<name_list>”

Usage: srvctl unsetenv nodeapps -n<node_name> -t “<name_list>”

使用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 <node_name>[-a] [-g] [-s] [-l]

-n<node> Node name

-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 <name> [-s<service_name>] [-a] [-S <level>]

-d<name> Unique name forthe database

-s<service> Service name

-a Additional attributes

-S <level> Additional information for EM Console

-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 <name> -o<oracle_home> [-m <domain_name>] [-p <spfile>] [-A<name|ip>/netmask] [-r {PRIMARY | PHYSICAL_STANDBY | LOGICAL_STANDBY}][-s <start_options>] [-n <db_name>] [-y {AUTOMATIC | MANUAL}]

Usage: srvctl add instance -d <name> -i<inst_name> -n <node_name>

Usage: srvctl add service -d <name> -s<service_name> -r “<preferred_list>” [-a”<available_list>”] [-P <TAF_policy>]

Usage: srvctl add service -d <name> -s<service_name> -u {-r “<new_pref_inst>” | -a”<new_avail_inst>”}

Usage: srvctl add nodeapps -n <node_name> -o<oracle_home> -A <name|ip>/netmask[/if1[|if2|…]]

Usage: srvctl add asm -n <node_name> -i<asm_inst_name> -o <oracle_home> [-p <spfile>]

Usage: srvctl config database

Usage: srvctl config database -d <name> [-a][-t]

Usage: srvctl config service -d <name> [-s<service_name>] [-a] [-S <level>]

Usage: srvctl config nodeapps -n <node_name>[-a] [-g] [-s] [-l]

Usage: srvctl config asm -n <node_name>

Usage: srvctl config listener -n <node_name>

Usage: srvctl disable database -d <name>

Usage: srvctl disable instance -d <name> -i”<inst_name_list>”

Usage: srvctl disable service -d <name> -s”<service_name_list>” [-i <inst_name>]

Usage: srvctl disable asm -n <node_name> [-i<inst_name>]

Usage: srvctl enable database -d <name>

Usage: srvctl enable instance -d <name> -i”<inst_name_list>”

Usage: srvctl enable service -d <name> -s”<service_name_list>” [-i <inst_name>]

Usage: srvctl enable asm -n <node_name> [-i<inst_name>]

Usage: srvctl getenv database -d <name> [-t”<name_list>”]

Usage: srvctl getenv instance -d <name> -i<inst_name> [-t “<name_list>”]

Usage: srvctl getenv service -d <name> -s<service_name> [-t “<name_list>”]

Usage: srvctl getenv nodeapps -n <node_name>[-t “<name_list>”]

Usage: srvctl modify database -d <name> [-n<db_name] [-o <ohome>] [-m <domain>] [-p <spfile>] [-r {PRIMARY | PHYSICAL_STANDBY |LOGICAL_STANDBY}] [-s <start_options>] [-y {AUTOMATIC | MANUAL}]

Usage: srvctl modify instance -d <name> -i<inst_name> -n <node_name>

Usage: srvctl modify instance -d <name> -i<inst_name> {-s <asm_inst_name> | -r}

Usage: srvctl modify service -d <name> -s<service_name> -i <old_inst_name> -t <new_inst_name> [-f]

Usage: srvctl modify service -d <name> -s<service_name> -i <avail_inst_name> -r [-f]

Usage: srvctl modify service -d <name> -s<service_name> -n -i <prefered_inst> [-a <available_list>][-f]

Usage: srvctl modify asm -n <node_name> -i<asm_inst_name> [-o <oracle_home>] [-p <spfile>]

Usage: srvctl modify nodeapps -n <node_name>[-o <oracle_home>] [-A <new_vip_address>]

Usage: srvctl relocate service -d <name> -s<service_name> -i <old_inst_name> -t <new_inst_name> [-f]

Usage: srvctl remove database -d <name> [-f]

Usage: srvctl remove instance -d <name> -i<inst_name> [-f]

Usage: srvctl remove service -d <name> -s<service_name> [-i <inst_name>] [-f]

Usage: srvctl remove nodeapps -n”<node_name_list>” [-f]

Usage: srvctl remove asm -n <node_name> [-i<asm_inst_name>] [-f]

Usage: srvctl setenv database -d <name> {-t<name>=<val>[,<name>=<val>,…] | -T<name>=<val>}

Usage: srvctl setenv instance -d <name> [-i<inst_name>] {-t”<name>=<val>[,<name>=<val>,…]” | -T”<name>=<val>”}

Usage: srvctl setenv service -d <name> [-s<service_name>] {-t “<name>=<val>[,<name>=<val>,…]”| -T “<name>=<val>”}

Usage: srvctl setenv nodeapps -n <node_name>{-t “<name>=<val>[,<name>=<val>,…]” | -T”<name>=<val>”}

Usage: srvctl start database -d <name> [-o<start_options>]

Usage: srvctl start instance -d <name> -i”<inst_name_list>” [-o <start_options>]

Usage: srvctl start service -d <name> [-s”<service_name_list>” [-i <inst_name>]] [-o<start_options>]

Usage: srvctl start nodeapps -n <node_name>

Usage: srvctl start asm -n <node_name> [-i<asm_inst_name>] [-o <start_options>]

Usage: srvctl start listener -n <node_name>[-l <lsnr_name_list>]

Usage: srvctl status database -d <name> [-f][-v] [-S <level>]

Usage: srvctl status instance -d <name> -i”<inst_name_list>” [-f] [-v] [-S <level>]

Usage: srvctl status service -d <name> [-s”<service_name_list>”] [-f] [-v] [-S <level>]

Usage: srvctl status nodeapps -n <node_name>

Usage: srvctl status asm -n <node_name>

Usage: srvctl stop database -d <name> [-o<stop_options>]

Usage: srvctl stop instance -d <name> -i”<inst_name_list>” [-o <stop_options>]

Usage: srvctl stop service -d <name> [-s”<service_name_list>” [-i <inst_name>]] [-f]

Usage: srvctl stop nodeapps -n <node_name>[-r]

Usage: srvctl stop asm -n <node_name> [-i<asm_inst_name>] [-o <stop_options>]

Usage: srvctl stop listener -n <node_name>[-l <lsnr_name_list>]

Usage: srvctl unsetenv database -d <name> -t”<name_list>”

Usage: srvctl unsetenv instance -d <name>[-i <inst_name>] -t “<name_list>”

Usage: srvctl unsetenv service -d <name> [-s<service_name>] -t “<name_list>”

Usage: srvctl unsetenv nodeapps -n<node_name> -t “<name_list>”

添加数据库

[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 <name> -i<inst_name> -n <node_name>

-d<name> Unique name forthe database

-i<inst> Instance name

-n<node> Node name

-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 <name> -i<inst_name> [-f]

-d<name> Unique name forthe database

-i<inst> Instance name

-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

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/197228.html原文链接:https://javaforall.cn

0 人点赞