SRVCTL Commands

SRVCTL is installed on each node in a cluster by default. To use SRVCTL, log in to the operating system of a node and enter the SRVCTL Commands and its parameters in case-sensitive syntax.

STOP DATABASE :

srvctl stop database -d PRODB -o normal
srvctl stop database -d PRODB -o immediate
srvctl stop database -d PRODB -o transactional
srvctl stop database -d PRODB -o abort

START DATABASE :

srvctl start database -d PRODB -o nomount
srvctl start database -d PRODB -o mount
srvctl start database -d PRODB -o open

STOP AN INSTANCE :

srvctl stop instance -d PRODB -i PRODB1

START AN INSTANCE :

srvctl start instance -d PRODB -i PRODB1

REMOVING DB FROM CRS :

srvctl remove database -d PRODB -f -y

ADDING DB IN CRS :

srvctl add database -d PRODB -o /u01/app/oracle/product/12.1.0.2/dbhome_1 -p +DATA/PRODDB/parameterfile/spfilePRODB.ora

REMOVING AN INSTANCE FROM CRS :

srvctl remove instance -d PRODB - I PRODB1

ADDING AN INSTANCE TO CRS :

srvctl add instance -d PRODB - i PRODB1 -n rachost1

Enable/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

Enable/Disable auto restart of the database :

srvctl enable database -d DB_UNIQUE_NAME
srvctl disable database -d DB_UNIQUE_NAME

ADDING A SERVICE :

SYNTAX – srvctl add servicec -d {DB_NAME} -s {SERVICE_NAME} -r {“preferred_list”} -a {“available_list”} [-P {BASIC | NONE | PRECONNECT}]

srvctl add service -d PREDB -s PRDB_SRV -r "PREDB1,PREDB2" -a "PREDB2" -P BASIC

REMOVING A SERVICE :

SYNTAX – srvctl remove service -d {DB_NAME} -s {SERVICE_NAME}

srvctl remove service -d PREDB -s PRDB_SRV

START A SERVICE :

SYNTAX– srvctl start servicec -d {DB_NAME} -s {SERVICE_NAME}

srvctl start service -d PREDB -s PRDB_SRV

STOP A SERVICE :

SYNTAX– srvctl stop servicec -d {DB_NAME} -s {SERVICE_NAME}

srvctl stop service -d PREDB -s PRDB_SRV

RELOCATE A SERVICE :

SYNTAX – srvctl relocate service -d {database_name} -s {service_name} -i {old_inst_name} -r {new_inst_name}

srvctl relocate service -d PREDB -s PRDB_SVC -i PREDB2 -t PREDB1

CHECK THE STATUS OF SERVICE :

SYNTAX – srvctl status service -d {database_name} -s {service_name}

srvctl status service -d PREDB -s PRDB_SVC

CHECK THE CONFIGURATION OF SERVICE :

SYNTAX – srvctl config service -d {database_name} -s {service_name}

srvctl config service -d PREDB -s PRDB_SVC

CHECK THE SCAN LISTENER CONFIGURATION :

srvctl config scan_listener
 
SCAN Listener LISTENER_SCAN1 exists. Port: TCP:1522
Registration invited nodes:
Registration invited subnets:
SCAN Listener is enabled.
SCAN Listener is individually enabled on nodes:
SCAN Listener is individually disabled on nodes:
SCAN Listener LISTENER_SCAN2 exists. Port: TCP:1522
Registration invited nodes:
Registration invited subnets:
SCAN Listener is enabled.
SCAN Listener is individually enabled on nodes:
SCAN Listener is individually disabled on nodes:
SCAN Listener LISTENER_SCAN3 exists. Port: TCP:1522
Registration invited nodes:
Registration invited subnets:
SCAN Listener is enabled.
SCAN Listener is individually enabled on nodes:
SCAN Listener is individually disabled on nodes:

MODIFY scan_listener PORT :

srvctl modify scan_listener -p {new-SCAN-port}
 
srvctl modify scan_listener -p 1523
 
 
$GRID_HOME/bin/srvctl stop scan_listener
$GRID_HOME/bin/srvctl start scan_listener
 
Alter system set remote_listener='orcl-scan.stc.com.sa:1523' scope=both sid='*';

MANAGE ‘MGMTDB’ IN ORACLE 12c :

MGMTDB is a built-in database to store Grid Infrastructure Management Repository (GIMR)

srvctl status mgmtdb
Database is enabled
Instance -MGMTDB is running on node node12-1
 
-- stop and start MGMT db.
 
srvctl stop mgmtdb
srvctl start mgmtdb

ENABLE TRACE FOR srvctl COMMANDS :

-- set this to enable trace at os
 
SRVM_TRACE=true
export SRVM_TRACE
 
-- run any srvctl command
srvctl status database -d ORACL

SET ENVIRONMENT VARIABLES THROUGH srvctl :

-- setenv to set env variables.(ORCL is the db_unique_name)
 
srvctl setenv database -db ORCL -env "ORACLE_HOME=/oracle/app/oracle/product/12.1.0.2/dbhome_1"
srvctl setenv database -db ORCL -env "TNS_ADMIN=/oracle/app/oracle/product/12.1.0.2/dbhome_1/network/admin"
 
 
--getenv to view the env setting:
 
srvctl getenv database -db ORCL
 
ORCL:
ORACLE_HOME=/oracle/app/oracle/product/12.1.0.2/dbhome_1
TNS_ADMIN=/oracle/app/oracle/product/12.1.0.2/dbhome_1/network/admin

CHECK STATUS AND CONFIG Of ‘ASM’ INSTANCE :

srvctl config asm
ASM home:
Password file: +MGMT/orapwASM
ASM listener: LISTENER
 
srvctl status asm
ASM is running on ses11-4,ses11-5

STOP/START SERVICES RUNNING FROM ‘ORACLE_HOME‘ :

srvctl stop home -oraclehome /oracle/product/12.1.0.2/dbhome_1 -statefile /home/oracle/state.txt  -node dbhost-1
 
srvctl start home -oraclehome /oracle/product/12.1.0.2/dbhome_1 -statefile /home/oracle/state.txt  -node dbhost-1

CREATE A ‘TAF’ POLICY :

Transparent Application Failover (TAF) is a feature of the Java Database Connectivity (JDBC) Oracle Call Interface (OCI) driver. It enables the application to automatically reconnect to a database, if the database instance to which the connection is made fails.

srvctl add service -db ORCLDB -service TAF_ORCL -preferred ORCLDB1 -available ORCLDB2 -tafpolicy BASIC -failovertype SELECT
 
srvctl start service -db OMPREDB -service TAF_ORCL

Also See:

CRSCTL Commands

Server Control (SRVCTL) utility