-- ==================================================================
-- 00. STATUS DATABASE:
-- ==================================================================
srvctl status database -database DB_UNIQUE_NAME (or)
srvctl status database -db DB_UNIQUE_NAME (or)
srvctl status database -d DB_UNIQUE_NAME
-- ==================================================================
-- 01. STOP DATABASE:
-- ==================================================================
# SYNTAX: srvctl stop database -database db_unique_name [-o stopoption] where stop_options is [ normal | immediate | transactional | abort ]
srvctl stop database -database DB_UNIQUE_NAME -stopoption normal (or)
srvctl stop database -db DB_UNIQUE_NAME -o normal (or)
srvctl stop database -d DB_UNIQUE_NAME -o normal
srvctl stop database -d DB_UNIQUE_NAME -o immediate
srvctl stop database -d DB_UNIQUE_NAME -o transactional
srvctl stop database -d DB_UNIQUE_NAME -o abort
-- ==================================================================
-- 02. START DATABASE:
-- ==================================================================
# SYNTAX: srvctl start database -database db_unique_name [-o startoption] where start_option is [ nomount | mount | open | force | open recover ]
srvctl start database -d DB_UNIQUE_NAME -o nomount
srvctl start database -d DB_UNIQUE_NAME -o mount
srvctl start database -d DB_UNIQUE_NAME -o open
srvctl start database -d DB_UNIQUE_NAME -o open
srvctl start database -database DB_UNIQUE_NAME -startoption force
srvctl start database -database DB_UNIQUE_NAME -startoption "open,recover"
-- ==================================================================
-- 03. STOP AN INSTANCE:
-- ==================================================================
# SYNTAX: srvctl stop instance -d DB_UNIQUE_NAME [-i “instance_name_list”]} [-o stop_options] [-f|-force]
srvctl stop instance -d DB_UNIQUE_NAME -i INSTANCE_NAME -o NORMAL
srvctl stop instance -d DB_UNIQUE_NAME -i INSTANCE_NAME -o TRANSACTIONAL
srvctl stop instance -d DB_UNIQUE_NAME -i INSTANCE_NAME -o IMMEDIATE
srvctl stop instance -d DB_UNIQUE_NAME -i INSTANCE_NAME -o ABORT
-- ==================================================================
-- 04. START AN INSTANCE:
-- ==================================================================
# SYNTAX: srvctl start instance -d DB_UNIQUE_NAME [-i “instance_name_list”} [-o start_options]
srvctl start instance -d DB_UNIQUE_NAME -i INSTANCE_NAME -o OPEN
srvctl start instance -d DB_UNIQUE_NAME -i INSTANCE_NAME -o MOUNT
srvctl start instance -d DB_UNIQUE_NAME -i INSTANCE_NAME -o NOMOUNT
-- ==================================================================
-- 05. REMOVING DB FROM CRS:
-- ==================================================================
# SYNTAX: srvctl remove database -d DB_UNIQUE_NAME [-f] [-y] [-v]
srvctl remove database -d DB_UNIQUE_NAME -f -y
-- ==================================================================
-- 06. ADDING DB IN CRS :
-- ==================================================================
# SYNTAX: srvctl add database -d DB_UNIQUE_NAME -o ORACLE_HOME [-p spfile]
srvctl add database -d DB_UNIQUE_NAME -o /u01/app/oracle/product/12.1.0.2/dbhome_1 -p +DATA/PRODDB/parameterfile/spfileDB_UNIQUE_NAME.ora
-- ==================================================================
-- 07. REMOVING AN INSTANCE FROM CRS:
-- ==================================================================
# SYNTAX: srvctl remove instance -d DB_UNIQUE_NAME -i INSTANCE_NAME
srvctl remove instance -d DB_UNIQUE_NAME - I DB_UNIQUE_NAME1
-- ==================================================================
-- 08. ADDING AN INSTANCE TO CRS:
-- ==================================================================
# SYNTAX: srvctl add instance –d DB_UNIQUE_NAME –i inst_name -n node_name
srvctl add instance -d DB_UNIQUE_NAME - i DB_UNIQUE_NAME1 -n rachost1
-- ==================================================================
-- 09. 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
-- ==================================================================
-- 10. ENABLE/DISABLE AUTO RESTART OF THE DATABASE
-- ==================================================================
srvctl enable database -d DB_UNIQUE_NAME
srvctl disable database -d DB_UNIQUE_NAME
-- ==================================================================
-- 11. 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 DB_NAME -s SERVICE_NAME -r "DB_NAME1,DB_NAME2" -a "DB_NAME2" -P BASIC
-- ==================================================================
-- 12.REMOVING A SERVICE:
-- ==================================================================
# SYNTAX: srvctl remove service -d {DB_NAME} -s {SERVICE_NAME}
srvctl remove service -d DB_NAME -s SERVICE_NAME
-- ==================================================================
-- 13. START A SERVICE
-- ==================================================================
# SYNTAX: srvctl start servicec -d {DB_NAME} -s {SERVICE_NAME}
srvctl start service -d DB_NAME -s SERVICE_NAME
-- ==================================================================
-- 14. STOP A SERVICE
-- ==================================================================
# SYNTAX: srvctl stop servicec -d {DB_NAME} -s {SERVICE_NAME}
srvctl stop service -d DB_NAME -s SERVICE_NAME
-- ==================================================================
-- 15. RELOCATE A SERVICE
-- ==================================================================
# SYNTAX: srvctl relocate service -d {database_name} -s {service_name} -i {old_inst_name} -r {new_inst_name}
EXAMPLE: (Relocating service SERVICE_NAME from DB_NAME2 to DB_NAME1)
srvctl relocate service -d DB_NAME -s SERVICE_NAME -i DB_NAME2 -t DB_NAME1
-- ==================================================================
-- 16. CHECK THE STATUS OF SERVICE
-- ==================================================================
# SYNTAX: srvctl status service -d {database_name} -s {service_name}
srvctl status service -d DB_NAME -s SERVICE_NAME
-- ==================================================================
-- 17. CHECK THE CONFIGURATION OF SERVICE
-- ==================================================================
# SYNTAX: srvctl config service -d {database_name} -s {service_name}
srvctl config service -d DB_NAME -s SERVICE_NAME
-- ==================================================================
-- 18. CHECK 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:
-- ==================================================================
-- 19. 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='*';
-- ==================================================================
-- 20. MANAGE MGMTDB IN ORACLE 12C:
-- ==================================================================
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
-- ==================================================================
-- 21. 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
-- ==================================================================
-- 22. 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
-- ==================================================================
-- 23. 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
-- ==================================================================
-- 24. STOP AND 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
-- ==================================================================
-- 25. CREATE A TAF POLICY
-- ==================================================================
srvctl add service -db ORCLDB -service TAF_ORCL -preferred ORCLDB1 -available ORCLDB2 -tafpolicy BASIC -failovertype SELECT srvctl start service -db OMDB_NAME -service TAF_ORCL
FONT:
https://docs.oracle.com/cd/E24696_01/doc/rac.11203/e16795/srvctladmin.htm