Useful commands to manage Oracle Grid Infrastructure / RAC (crsctl / srvctl)
- How do we collect the actual execution plan from queries using Extended Event and how do we read its data - 2 December 2024
- How do we find what permissions a user has on an Oracle database - 1 November 2024
- How we enable Unified Auditing in Oracle Database - 7 October 2024
In this article we will see some useful commands to manage databases installed on Oracle Grid Infrastructure. The Oracle Cluster Resources (CRS) we manage them through the tool CRSCTL
and Oracle Database , Listener and Services with the tool SRVCTL
.
Useful CRSCTL commands
All commands CRSCTL
run by default with root
user.
To start / stop Cluster Services on the server we are connected to:
crsctl start crs crsctl stop crs
To stop/start Cluster Services on all servers:
crsctl stop cluster -all crsctl start cluster -all
To see if the health of the Cluster Services on the local node:
crsctl check crs
To see the status of each Cluster Service running on all nodes:
crsctl status resource -t
Useful SRVCTL commands
All commands SRVCTL
run by default with oracle
user.
To see the database parameters:
srvctl config database -d racdb
To stop/start the database on all nodes:
srvctl stop database -d racdb srvctl start database -d racdb
When we stop / start the base, we can also give an option (e.g. abort, mount):
srvctl stop database -d racdb -o immediate srvctl start database –d racdb -o mount
To stop / start specific instance only:
srvctl stop instance -d racdb -i racdb2 srvctl start instance -d racdb -i racdb2
To remove a database from the Cluster:
srvctl remove database -d racdb -f -y
To add a database to the Cluster beyond its name we need the ORACLE_HOME
and its location SPFILE
:
srvctl add database -d racdb -o /oracle/nfs/app/oracle/product/12.1.0.2/dbhome_1 -p /oracle/oradata/racdb/racdb/spfileracdb.ora
To remove an instance from the Cluster:
srvctl remove instance -d racdb -i racdb2
To add an instance to the Cluster, in addition to the name of the instance we also need its hostname:
srvctl add instance -d racdb -i racdb2 -n oracledev2
If we want to stop / start the database to start automatically in the Cluster:
srvctl disable database -d racdb srvctl enable database -d racdb
To stop / start listeners on nodes:
srvctl stop listener –n racdb1 , racdb2 srvctl start listener –n racdb1 , racdb2
To see the SCAN Listener parameters:
srvctl config scan_listener
For Database Services
To create a new service that will connect with priority to instance racdb1 but can also connect to racdb2 if something happens:
srvctl add service -d racdb -s REPORTING -r "racdb1" -a "racdb2" -P BASIC
To start / stop the service:
srvctl start service -d racdb -s REPORTING srvctl stop service -d racdb -s REPORTING
To remove the service:
srvctl remove service -d racdb -s REPORTING
To modify a service to run only on instance racdb1:
srvctl modify service –d racdb –s REPORTING –n –i racdb1
To move a service running on racdb2 the connections to racdb1:
srvctl relocate service -d racdb -s REPORTING -i racdb2 -t racdb1
To check where a service is currently running:
srvctl status service -d racdb -s REPORTING
To make a service for Transparent Application Failover (TAF):
srvctl add service -db racdb -service racdb_taf -preferred racdb1 -available racdb2 -tafpolicy PRECONNECT -failovertype SELECT -q true
To start a service:
srvctl start service -db racdb -service racdb_taf
To see all the parameters of a service:
srvctl config service -d racdb -s racdb_taf
Sources: