Detailed explanation of srvctl command in Oracle restart

Time:2021-1-24

Srvctl, service control utility, can be used to configure and manage Oracle restart and Oracle RAC. This article mainly introduces the application of srvctl command in Oracle restart, including the config and status commands in detail, and lists the usage of other commands.

1 srvctl command syntax

Usage: srvctl []

commands: enable|disable|start|stop|status|add|remove|modify|update|getenv|setenv|unsetenv|config|upgrade|downgrade

objects: database|service|asm|diskgroup|listener|home|ons

2 config command

The srvctl config command can display the Oracle restart configuration information of a specific component or a group of components.

2.1 srvctl config asm

Show the Oracle restart configuration information of ASM instance.

1) Grammatical structure

Usage: srvctl config asm [-all]

2) Examples

[[email protected] ~]$ srvctl config asm

ASM home:

Password file: +DATA/orapwasm

ASM listener: LISTENER

Spfile: +DATA/ASM/ASMPARAMETERFILE/registry.253.1037659875

ASM diskgroup discovery string: /dev/oracleasm/disks/*

2.2 srvctl config database

Display database related information.

1) Grammatical structure

Usage: srvctl config database [-db [-all]] [-verbose]

2) Examples

[[email protected] ~]$ srvctl config database -db orcl -all

Database unique name: orcl

Database name: orcl

Oracle home: /u01/app/oracle/product/12.1.0/dbhome_1

Oracle user: oracle

Spfile: +DATA/ORCL/PARAMETERFILE/spfile.267.1037831659

Password file:

Domain:

Start options: open

Stop options: immediate

Database role: PRIMARY

Management policy: AUTOMATIC

Disk Groups: FRA,DATA

Services:

Database is enabled

OSDBA group:

OSOPER group:

Database instance: orcl

2.3 srvctl config listener

Display information about the monitor.

1) Grammatical structure

Usage: srvctl config listener [-listener ]

2) Examples

[[email protected] ~]$ srvctl config listener

Name: LISTENER

Type: Database Listener

Home: /u01/app/grid/product/12.1.0/grid

End points: TCP:1521

Listener is enabled.

2.4 srvctl config ons

Display Oracle notification service information.

1) Grammatical structure

Usage: srvctl config ons

2) Examples

[[email protected] ~]$ srvctl config ons

ONS exists: Local port 6100, remote port 6200, EM port 2016, Uses SSL: false

2.5 srvctl config service

Display service information.

1) Grammatical structure

Usage: srvctl config service -db [-service ] [-verbose]

2) Examples

[[email protected] ~]$ srvctl config service -db orcl

3 status command

The srvctl status command is used to display the running status information of components.

3.1 srvctl status asm

1) Grammatical structure

Usage: srvctl status asm [-all] [-verbose]

2) Examples

[[email protected] ~]$ srvctl status asm -detail

ASM is running on sz

ASM is enabled.

3.2 srvctl status database

1) Grammatical structure

Usage: srvctl status database {-db | -thisversion | -thishome} [-force] [-verbose]

2) Examples

[[email protected] ~]$ srvctl status database -db orcl -verbose

Database orcl is running. Instance status: Open.

3.3 srvctl status diskgroup

1) Grammatical structure

Usage: srvctl status diskgroup -diskgroup [-all] [-verbose]

2) Examples

[[email protected] ~]$ srvctl status diskgroup -diskgroup DATA -detail

Disk Group DATA is running on sz

Disk Group DATA is enabled

3.4 srvctl status home

Show the running status of all components in a specific Oracle home.

1) Grammatical structure

Usage: srvctl status home -oraclehome -statefile

2) Examples

[[email protected] ~]$ srvctl status home -oraclehome /u01/app/grid/product/12.1.0/grid -statefile /home/grid/grid.txt

Disk Group ora.DATA.dg is running on sz

Disk Group ora.FRA.dg is running on sz

ASM is running on sz

Listener LISTENER is running on node sz

[[email protected] ~]$ cat grid.txt

diskgroup-ora.DATA.dg

diskgroup-ora.FRA.dg

asm-ora.asm

lsnr-LISTENER

3.5 srvctl status listener

1) Grammatical structure

Usage: srvctl status listener [-listener ] [-verbose]

2) Examples

[[email protected] ~]$ srvctl status listener

Listener LISTENER is enabled

Listener LISTENER is running on node(s): sz

3.6 srvctl status ons

1) Grammatical structure

Usage: srvctl status ons [-verbose]

2) Examples

[[email protected] ~]$ srvctl status ons

ONS is disabled

ONS daemon is not running

3.7 srvctl status service

1) Grammatical structure

Usage: srvctl status service -db [-service “”] [-force] [-verbose]

2) Examples

[[email protected] ~]$ srvctl status service -db orcl

4 stop command

Srvctl stop is used to stop a specific component or set of components.

[[email protected] ~]$ srvctl stop -help

 

The SRVCTL stop command stops, Oracle Restart enabled, starting or running objects.

 

Usage: srvctl stop database -db [-stopoption ] [-force]

Usage: srvctl stop service -db [-service “”] [-global_override] [-force] [-verbose]

Usage: srvctl stop asm [-stopoption ] [-force]

Usage: srvctl stop listener [-listener ] [-force]

Usage: srvctl stop diskgroup -diskgroup [-force]

Usage: srvctl stop ons [-verbose]

Usage: srvctl stop home -oraclehome -statefile [-stopoption ] [-force]

For detailed help on each command and object and its options use:

srvctl -help [-compatible]

5 start command

Srvctl start is used to start components and their services.

[[email protected] ~]$ srvctl start -help

 

The SRVCTL start command starts, Oracle Restart enabled, non-running objects.

 

Usage: srvctl start database -db [-startoption ]

Usage: srvctl start service -db [-service “”] [-startoption ] [-global_override] [-verbose]

Usage: srvctl start asm [-startoption ]

Usage: srvctl start listener [-listener ]

Usage: srvctl start diskgroup -diskgroup

Usage: srvctl start ons [-verbose]

Usage: srvctl start home -oraclehome -statefile

For detailed help on each command and object and its options use:

srvctl -help [-compatible]

6 remove command

[[email protected] ~]$ srvctl remove -help

 

The SRVCTL remove command removes the configuration, for the object from the Oracle Restart. Environment settings for the object are also removed.

 

Usage: srvctl remove database -db [-force] [-noprompt] [-verbose]

Usage: srvctl remove service -db -service [-global_override] [-force]

Usage: srvctl remove asm [-force]

Usage: srvctl remove listener [-listener | -all] [-force]

Usage: srvctl remove diskgroup -diskgroup [-force]

Usage: srvctl remove ons [-force] [-verbose]

For detailed help on each command and object and its options use:

srvctl -help [-compatible]

7 add command

[[email protected] ~]$ srvctl add -help

 

The SRVCTL add command adds the configuration and the Oracle Restart application to the OCR for the cluster database, named instances, named services, or for the named nodes.

 

Usage: srvctl add database -db -oraclehome [-domain ] [-spfile ] [-pwfile ] [-role {PRIMARY | PHYSICAL_STANDBY | LOGICAL_STANDBY | SNAPSHOT_STANDBY | FAR_SYNC}] [-startoption ] [-stopoption ] [-dbname ] [-instance ] [-policy {AUTOMATIC | MANUAL | NORESTART}] [-diskgroup “”]

Usage: srvctl add service -db -service [-role [PRIMARY][,PHYSICAL_STANDBY][,LOGICAL_STANDBY][,SNAPSHOT_STANDBY]] [-policy {AUTOMATIC | MANUAL}][-notification {TRUE|FALSE}] [-clbgoal {SHORT|LONG}] [-rlbgoal {NONE|SERVICE_TIME|THROUGHPUT}][-failovertype {NONE|SESSION|SELECT|TRANSACTION}] [-failovermethod {NONE|BASIC}][-failoverretry ] [-failoverdelay ] [-edition ] [-pdb ] [-global ] [-maxlag ] [-sql_translation_profile ] [-commit_outcome {TRUE|FALSE}] [-retention ] [replay_init_time ] [-session_state {STATIC|DYNAMIC}] [-force]

Usage: srvctl add asm [-listener ] [-spfile ] [-pwfile ] [-diskstring ]

Usage: srvctl add listener [-listener ] [-skip] [-endpoints “[TCP:][, …][/IPC:][/NMP:][/TCPS:] [/SDP:]”] [-oraclehome ]

Usage: srvctl add ons [-emport ] [-onslocalport ] [-onsremoteport ] [-remoteservers [:][,[:]…]] [-verbose]

For detailed help on each command and object and its options use:

srvctl -help [-compatible]

8 modify command

[[email protected] ~]$ srvctl modify -help

 

The SRVCTL modify command enables user to modify configuration of the object without removing and adding Oracle Restart resources. The changes takes effect when the application is restarted.

 

Usage: srvctl modify database -db [-dbname ] [-instance ] [-oraclehome ] [-user ] [-domain ] [-spfile ] [-pwfile ] [-role {PRIMARY | PHYSICAL_STANDBY | LOGICAL_STANDBY | SNAPSHOT_STANDBY}] [-startoption ] [-stopoption ] [-policy {AUTOMATIC | MANUAL | NORESTART}] [-diskgroup “”|-nodiskgroup] [-force]

Usage: srvctl modify service -db -service [-role [PRIMARY][,PHYSICAL_STANDBY][,LOGICAL_STANDBY][,SNAPSHOT_STANDBY]] [-policy {AUTOMATIC | MANUAL}][-notification {TRUE|FALSE}] [-clbgoal {SHORT|LONG}] [-rlbgoal {NONE|SERVICE_TIME|THROUGHPUT}] [-failovertype {NONE|SESSION|SELECT|TRANSACTION}] [-failovermethod {NONE|BASIC}] [-failoverretry ] [-failoverdelay ] [-edition ] [-pdb ] [-sql_translation_profile ] [-commit_outcome {TRUE|FALSE}] [-retention ] [replay_init_time ] [-session_state {STATIC|DYNAMIC}] [-global_override]

Usage: srvctl modify asm [-listener ] [-spfile ] [-pwfile ] [-diskstring ]

Usage: srvctl modify listener [-listener ] [-oraclehome ] [-endpoints “[TCP:][, …][/IPC:][/NMP:][/TCPS:] [/SDP:]”]

Usage: srvctl modify ons [-emport ] [-onslocalport ] [-onsremoteport ] [-remoteservers [:][,[:]…]] [-verbose]

For detailed help on each command and object and its options use:

srvctl -help [-compatible]

9 disable command

[[email protected] ~]$ srvctl disable -help

 

The SRVCTL disable command disables the named object so that it is unavailable to run under Oracle Restart for automatic startup, failover, or restart.

 

Usage: srvctl disable database -db

Usage: srvctl disable service -db -service “” [-global_override]

Usage: srvctl disable asm

Usage: srvctl disable listener [-listener ]

Usage: srvctl disable diskgroup -diskgroup

Usage: srvctl disable ons [-verbose]

For detailed help on each command and object and its options use:

srvctl -help [-compatible]

10 enable command

[[email protected] ~]$ srvctl enable -help

 

The SRVCTL enable command enables the named object so that it can run under Oracle Restart for automatic startup, failover, or restart.

 

Usage: srvctl enable database -db

Usage: srvctl enable service -db -service “” [-global_override]

Usage: srvctl enable asm

Usage: srvctl enable listener [-listener ]

Usage: srvctl enable diskgroup -diskgroup

Usage: srvctl enable ons [-verbose]

For detailed help on each command and object and its options use:

srvctl -help [-compatible]

11 getenv command

[[email protected] ~]$ srvctl getenv -help

 

The SRVCTL getenv command Gets and displays values for the environment from the configuration file. It allows users to administer environment configuration for the objects.

 

Usage: srvctl getenv database -db [-envs “[,…]”]

Usage: srvctl getenv asm [-envs “[,…]”]

Usage: srvctl getenv listener [-listener ] [-envs “[,…]”]

For detailed help on each command and object and its options use:

srvctl -help [-compatible]

12 setenv command

[[email protected] ~]$ srvctl setenv -help

 

The SRVCTL setenv command sets values for the environment in the configuration file. It allows users to administer environment configuration for the objects.

 

Usage: srvctl setenv database -db {-envs “=[,…]” | -env “=”}

Usage: srvctl setenv asm {-envs “=[,…]” | -env “=”}

Usage: srvctl setenv listener [-listener ] -envs “=[,…]” | -env “=”

For detailed help on each command and object and its options use:

srvctl -help [-compatible]

13 update command

[[email protected] ~]$ srvctl update -help

 

The SRVCTL update command requests specified running object to use the new configuration information stored in the OCR.

 

Usage: srvctl update database -db -startoption

For detailed help on each command and object and its options use:

srvctl -help [-compatible]

14 upgrade command

[[email protected] ~]$ srvctl upgrade -help

 

Upgrades the resources types and resources from an older version to a newer version.

 

Usage: srvctl upgrade database -db -oraclehome

srvctl -help [-compatible]

15 downgrade command

[[email protected] ~]$ srvctl downgrade -help

 

The SRVCTL downgrade command enables the user to downgrade resources from their current software version to an older version.

 

Usage: srvctl downgrade database -db -oraclehome -targetversion

srvctl -help [-compatible]