srvctl command line

srvctl (Server Control) is a command-line utility used in Oracle Real Application Clusters to manage cluster resources like databases, instances, ASM, listeners, and services.

oraclesqlhigh-availabilityv1.0.0
0 stars0 downloads26 views0 comments
By fathy • Created

Code

(125 lines)
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
SRVCTL is known as server control utility, which is used to add, remove,relocate and manage different crs services or components in RAC database.

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

------------ START/STOP AN INSTANCE ------------
srvctl stop instance -d db_unique_name [-i “instance_name_list”]} [-o stop_options] [-f]
srvctl stop instance -d PRODB -i PRODB1
srvctl start instance -d db_unique_name [-i “instance_name_list”} [-o start_options]
srvctl start instance -d PRODB -i PRODB1

----------REMOVING DB FROM CRS--------------
###srvctl remove database -d db_unique_name [-f] [-y] [-v]

-f = Force removal
-y = (yes) Automatic confirmation 
-v = Verbose output

srvctl remove database -d PRODB -f -y

------------ADDING DB IN CRS-----------
###srvctl add database -d db_unique_name -o ORACLE_HOME [-p spfile]
srvctl add database -d PRODB -o /u01/app/oracle/product/19.1.0.2/dbhome_1 -p +DATA/PRODDB/parameterfile/spfilePRODB.ora

-----------REMOVING AN INSTANCE FROM CRS--------------
#######srvctl remove instance -d DB_UNIQUE_NAME -i INSTANCE_NAME
srvctl remove instance -d PRODB - I PRODB1

---------ADDING AN INSTANCE TO CRS---------
###srvctl add instance –d db_unique_name –i inst_name -n node_name
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----------
###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---------
###srvctl remove service -d {DB_NAME} -s {SERVICE_NAME}
srvctl remove service -d PREDB -s PRDB_SRV

--------START/STOP A SERVICE------------
###srvctl start servicec -d {DB_NAME} -s {SERVICE_NAME}
srvctl start service -d PREDB -s PRDB_SRV
srvctl stop service -d PREDB -s PRDB_SRV

--------change SERVICE location --------
###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---------
###srvctl status service -d {database_name} -s {service_name}
srvctl status service -d PREDB -s PRDB_SVC

---------- configuration of service---------
###srvctl config service -d {database_name} -s {service_name}
srvctl config service -d PREDB -s PRDB_SVC

----------scan listener configuration--------
srvctl config scan_listener
srvctl config scan

----------Modify scan_listener port--------
srvctl modify scan_listener -p {new-SCAN-port}
srvctl modify scan_listener -p 1523


----------START/STOP scan_listener-----------
srvctl stop scan_listener
srvctl start scan_listener
srvctl stat scan_listener



Alter system set remote_listener='orcl-scan.stc.com.sa:1523' scope=both sid='*';


-----------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/19.1.0.2/dbhome_1"
srvctl setenv database -db ORCL -env "TNS_ADMIN=/oracle/app/oracle/product/19.1.0.2/dbhome_1/network/admin"

----------------get environment to view the env setting:

srvctl getenv database -db ORCL

ORCL:
ORACLE_HOME=/oracle/app/oracle/product/19.1.0.2/dbhome_1
TNS_ADMIN=/oracle/app/oracle/product/19.1.0.2/dbhome_1/network/admin


-----------Check status and config of ASM instance-------
srvctl config asm
srvctl status asm

----------- START/STOP services running from ORACLE_HOME-----
srvctl stop home -oraclehome /oracle/product/19.1.0.2/dbhome_1 -statefile /home/oracle/state.txt -node dbhost-1
srvctl start home -oraclehome /oracle/product/19.1.0.2/dbhome_1 -statefile /home/oracle/state.txt -node dbhost-1


----------- Create a TAF policy -------------
srvctl add service -db ORCLDB -service TAF_ORCL \
-preferred ORCLDB1 -available ORCLDB2 \
-tafpolicy BASIC -failovertype SELECT




please do not impleamant this command in prodactuin envirment

Usage Instructions

Always make sure you test the changes in a non-production (DEV/UAT) environment first before implementing them in Production.

General Comments(0)

Tip: Click on a line number in the code to add a line-specific comment

No general comments yet. Be the first to comment!