DBA Hub

📋Steps in this guide1/18

Useful srvctl commands in RAC DBACLASS

srvctl server control utility , used in rac to add,remove,relocate services and manage them. This article contains list of useful srvctl commands and syntax.

oracle clusteringintermediate
by OracleDba
24 views
1

Overview

SRVCTL is known as server control utility, which is used to add, remove,relocate and manage different crs services or components in RAC database. 1. STOP DATABASE : SYNTAX – srvctl stop database -d db_name [-o stop_options] where stop_options is normal/immediate(default)/transactional/abort e.g
2

Section 2

2. START DATABASE SYNTAX – srvctl start database -d db_name [-o start_options] where start_option is nomount/mount/open(default) e.g

Code/Command (click line numbers to comment):

1
2
3
4
5
6
7
8
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

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

Section 3

3. STOP AN INSTANCE SYNTAX – srvctl stop instance -d db_unique_name [-i “instance_name_list”]} [-o stop_options] [-f] e.g 4. START AN INSTANCE

Code/Command (click line numbers to comment):

1
srvctl stop instance -d PRODB -i PRODB1
4

Section 4

SYNTAX – srvctl start instance -d db_unique_name [-i “instance_name_list”} [-o start_options] e.g 5. REMOVING DB FROM CRS: SYNTAX – srvctl remove database -d db_unique_name [-f] [-y] [-v] e.g

Code/Command (click line numbers to comment):

1
srvctl start instance -d PRODB -i PRODB1
5

Section 5

6. ADDING DB IN CRS : SYNTAX – srvctl add database -d db_unique_name -o ORACLE_HOME [-p spfile] e.g

Code/Command (click line numbers to comment):

1
2
3
srvctl remove database -d PRODB -f -y

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

Section 6

7. REMOVING AN INSTANCE FROM CRS: SYNTAX – srvctl remove instance -d DB_UNIQUE_NAME -i INSTANCE_NAME e.g 8.ADDING AN INSTANCE TO CRS: SYNTAX – srvctl add instance –d db_unique_name –i inst_name -n node_name e.g

Code/Command (click line numbers to comment):

1
srvctl remove instance -d PRODB - I PRODB1
7

Section 7

9. Enable/disable auto restart of the instance 10. Enable/disable auto restart of the database

Code/Command (click line numbers to comment):

1
2
3
4
srvctl add instance -d PRODB - i PRODB1 -n rachost1

srvctl enable instance -d DB_UNIQUE_NAME-i INSTANCE_NAME 
srvctl disable instance -d DB_UNIQUE_NAME-i INSTANCE_NAME
8

Section 8

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

Code/Command (click line numbers to comment):

1
2
srvctl enable database -d DB_UNIQUE_NAME 
srvctl disable database -d DB_UNIQUE_NAME
9

Section 9

e.g 12.REMOVING A SERVICE: SYNTAX – srvctl remove service -d {DB_NAME} -s {SERVICE_NAME} e.g

Code/Command (click line numbers to comment):

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

Section 10

13. START A SERVICE SYNTAX – srvctl start servicec -d {DB_NAME} -s {SERVICE_NAME} e.g 14. STOP A SERVICE

Code/Command (click line numbers to comment):

1
2
3
srvctl remove service -d PREDB -s PRDB_SRV

srvctl start service -d PREDB -s PRDB_SRV
11

Section 11

SYNTAX – srvctl stop servicec -d {DB_NAME} -s {SERVICE_NAME} e.g 15. RELOCATE A SERVICE

Code/Command (click line numbers to comment):

1
srvctl stop service -d PREDB -s PRDB_SRV
12

Section 12

SYNTAX – srvctl relocate service -d {database_name} -s {service_name} -i {old_inst_name} -r {new_inst_name} EXAMPLE: (Relocating service PRDB_SRV from PREDB2 to PREDB1) 16. Check the status of service SYNTAX – srvctl status service -d {database_name} -s {service_name}

Code/Command (click line numbers to comment):

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

Section 13

17. Check the configuration of service SYNTAX – srvctl config service -d {database_name} -s {service_name}

Code/Command (click line numbers to comment):

1
2
3
srvctl status service -d PREDB -s PRDB_SVC

srvctl config service -d PREDB -s PRDB_SVC
14

Section 14

18. Check scan listener configuration 19. Modify scan_listener port:

Code/Command (click line numbers to comment):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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:

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='*';
15

Section 15

20. Manage MGMTDB in oracle 12c: 21. Enable trace for srvctl commands:

Code/Command (click line numbers to comment):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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

-- set this to enable trace at os 

SRVM_TRACE=true
export SRVM_TRACE

-- run any srvctl command
srvctl status database -d ORACL
16

Section 16

22. Set environment variables through srvctl. 23. Check status and config of ASM instance:

Code/Command (click line numbers to comment):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
-- 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

srvctl config asm
ASM home: 
Password file: +MGMT/orapwASM
ASM listener: LISTENER


srvctl status asm
ASM is running on ses11-4,ses11-5
17

Section 17

24. Stop and start services running from ORACLE_HOME 25. Create a TAF policy

Code/Command (click line numbers to comment):

1
2
3
4
5
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

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

Section 18

SEE ALSO: - Useful CRSCTL Commands - Useful Gather Statistics Commands In Oracle - Useful ADRCI Commands In Oracle - Useful DGMGRL Commands In Oracle Dataguard - Useful database monitoring queries - Useful Flashback Related Commands - Useful scheduler job Related Commands - Useful Oracle Auditing Related Commands - Useful RMAN Commands - Useful TFACTL Commands - Useful OPATCH Commands - Useful Asmcmd Commands

Comments (0)

Please to add comments

No comments yet. Be the first to comment!