当前位置:Gxlcms > mysql > Srvctl命令详解(10g)

Srvctl命令详解(10g)

时间:2021-07-01 10:21:17 帮助过:19人阅读

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

[root@felix2 bin]#

[root@felix1 bin]# ./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 ""

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

-n 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 [-s] [-a] [-S ]

-d Unique name forthe database

-s Service name

-a Additional attributes

-S 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 -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 ""

添加数据库

[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 -i -n

-d Unique name forthe database

-i Instance name

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

-d Unique name forthe database

-i 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

人气教程排行