I will explain What is the SRVCTL and Useful SRVCTL Commands in Oracle RAC in this post.
Useful SRVCTL Commands in Oracle RAC
You can read the following article to learn CRSCTL utility, and RAC Management via crsctl.
What is the SRVCTL
SRVCTL ( Server Control ) is very important utility on RAC Databases for Oracle DBA. You can start and stop the database and instances and move or remove instances and services very easily.
For Example; You have Full Exadata which is 8 nodes RAC, You need to shutdown all instances. You can shutdown and startup all instances with one srvctl command easily.
There are lots of options used with SRVCTL command, these options and their descriptions are as follows.
-d Database Name
-i Instance Name
-s Service Name
-n Node Name
-r Preferred list
-a Available list
-p TAF (Transparent application failover policy)
-v Verbose
SRVCTL Status and Config Database
You can check all instance status of database as follows.
srvctl status database -d DB_NAME [oracle@MSDBdbadm01 ~]$ srvctl status database -d MSDB Instance MSDB1 is running on node MSDBdbadm01 Instance MSDB2 is running on node MSDBdbadm02 Instance MSDB3 is running on node MSDBdbadm03 Instance MSDB4 is running on node MSDBdbadm04 [oracle@MSDBdbadm01 ~]$
You can display the configurations (instances name, nodes and oracle home) of any RAC Database as follows.
srvctl config database -d DB_NAME srvctl config database -d MSDB
Shutdown RAC Database
You can shutdown all instances of any database as follows.
srvctl stop database -d db_name [-o stop_options] srvctl stop database -d DB_NAME srvctl stop database -d DB_NAME -o normal srvctl stop database -d DB_NAME -o immediate srvctl stop database -d DB_NAME -o transactional srvctl stop database -d DB_NAME -o abort [oracle@MSDBdbadm01 ~]$ srvctl stop database -d MSDB
Startup RAC Database
You can start all instances of any database as follows.
srvctl start database -d db_name [-o start_options] srvctl start database -d DB_NAME srvctl start database -d DB_NAME -o nomount srvctl start database -d DB_NAME -o mount srvctl start database -d DB_NAME -o open [oracle@MSDBdbadm01 ~]$ srvctl start database -d MSDB
Shutdown An Instance
You can shutdown only specific Instance of RAC database as follows.
srvctl stop instance -d db_unique_name [-i "instance_name_list"]} [-o stop_options] [-f] srvctl stop instance -d DB_NAME -i INSTANCE_NAME [oracle@MSDBdbadm01 ~]$ srvctl stop instance -d MSDB -i MSDB1
Startup and Status An Instance
You can startup only specific Instance(s) of RAC database as follows.
srvctl start instance -d db_unique_name [-i "instance_name_list"} [-o start_options] srvctl start instance -d DB_NAME -i INSTANCE_NAME [oracle@MSDBdbadm01 ~]$ srvctl start instance -d MSDB -i MSDB1
You can display any instance of RAC database as follows.
srvctl status instance -d DB_NAME -i INSTANCE_NAME [oracle@MSDBdbadm01 ~]$ srvctl status instance -d MSDB -i MSDB1
Add and Remove Database from CRS
You can add new DB to CRS as follows.
srvctl add database -d db_unique_name -o ORACLE_HOME [-p spfile] srvctl add database -d MSDB -o /u01/app/product/12.1.0.2/dbhome_1 -p +DATAC1/MSDB/parameterfile/spfileMSDB.ora
You can remove existing DB from CRS as follows.
srvctl remove database -d db_unique_name [-f] [-y] [-v] srvctl remove database -d DB_NAME -f -y
Stop, Start and Check ASM via SRVCTL
You can shutdown an ASM instance as follows.
srvctl stop asm -n NODE_NAME -o immediate srvctl stop asm -n msdbdbadm01 -o immediate
You can startup an ASM instance as follows.
srvctl start asm -n NODE_NAME srvctl start asm -n msdbdbadm01
You can display configuration and status an ASM instance as follows.
srvctl status asm -n NODE_NAME srvctl config asm -n NODE_NAME
[oracle@msdbdbadm01 ~]$ srvctl status asm -n msdbdbadm01 ASM is running on msdbdbadm01 [oracle@msdbdbadm01 ~]$ [oracle@msdbdbadm01 ~]$ [oracle@msdbdbadm01 ~]$ srvctl config asm -n msdbdbadm01 PRKO-2207 : Warning:-node option has been deprecated and will be ignored. ASM home: <CRS home> Password file: +DBFS_DG/orapwASM ASM listener: LISTENER [oracle@msdbdbadm01 ~]$
Stop, Start and Check Service via SRVCTL
You can start, stop and check any service on Database as follows.
srvctl status service -d db_name srvctl config service -d db_name srvctl start service -d dbname -s service_name srvctl stop service -d dbname -s service_name
srvctl add service -d {DB_NAME} -s {SERVICE_NAME} -r {"preferred_list"} -a {"available_list"} [-P {BASIC | NONE | PRECONNECT}] srvctl relocate service -d db_name -s service_name -i instance_name -t new_instance_name [-f]
You can remove any service as follows.
srvctl remove service -d {DB_NAME} -s {SERVICE_NAME} srvctl remove service -d MSDB -s MSDB_SALES
Enable/disable Autorestart of Instance and Database
You can enable and disable auto restart of the database as follows.
srvctl enable database -d DB_UNIQUE_NAME srvctl disable database -d DB_UNIQUE_NAME
You can enable and disable auto restart of the instance
srvctl enable instance -d DB_UNIQUE_NAME-i INSTANCE_NAME srvctl disable instance -d DB_UNIQUE_NAME-i INSTANCE_NAME
Start, Stop and Check status,configurations of NodeApps
srvctl status nodeapps -n nodename srvctl config nodeapps -n nodename srvctl start nodeapps -n nodename srvctl stop nodeapps -n nodename
Do you want to use Oracle DBA Scripts All in One For Oracle RAC, then Click This Link read the articles.