In Oracle Real Application Clusters (RAC), the "srvctl" command-line utility is used for managing various aspects of an Oracle RAC environment. It stands for "Server Control" and provides a convenient interface to administer and configure RAC components.
The srvctl utility allows you to perform tasks such as starting, stopping, relocating, enabling, disabling, and checking the status of RAC database instances, services, and listeners. It simplifies the management of Oracle RAC by providing a unified interface to control the different components involved.
Some common tasks you can perform with srvctl include:
- Managing Database Instances: You can start, stop, relocate, or manage the state of Oracle RAC database instances using srvctl. It helps in managing the lifecycle of database instances across different nodes in the cluster.
- Managing Services: Oracle RAC uses services to define the availability and characteristics of connections to the database. With srvctl, you can create, modify, enable, disable, and manage services within the RAC environment.
- Managing Listeners: RAC environments typically have multiple listeners to handle client connections. Srvctl allows you to configure and manage the listeners associated with the RAC database.
- Managing Configuration: Srvctl can be used to modify or view the configuration of various RAC components, such as the database, instance, services, and listeners. You can modify attributes like resource dependencies, instance and service names, and listener settings.
By providing a centralized command-line interface, srvctl simplifies the management of Oracle RAC components and reduces the complexity of manual configuration and administration tasks.
In Oracle Real Application Clusters (RAC), the "crsctl" command-line utility is used for managing the Oracle Clusterware components. Clusterware is a key component of Oracle RAC that provides the infrastructure for managing and maintaining the cluster.
The crsctl utility allows you to perform various administrative tasks related to Oracle Clusterware in a RAC environment. It provides a command-line interface to manage and control the Clusterware resources, including the Cluster Ready Services (CRS), Oracle Clusterware stack, and Oracle Automatic Storage Management (ASM) instances.
Here are some common tasks that can be performed with crsctl:
- Managing the Clusterware Stack: You can start, stop, and restart the Oracle Clusterware stack using crsctl. This includes managing the Clusterware components such as the Cluster Synchronization Services (CSS), Event Manager (EVM), and Oracle Notification Service (ONS).
- Managing Resources: Clusterware resources are managed using crsctl. You can start, stop, enable, disable, relocate, or modify the attributes of resources such as database instances, services, listeners, virtual IPs, and ASM instances.
- Checking Cluster Status: Crsctl provides commands to check the status of the cluster and its components. You can use commands like "crsctl check cluster" or "crsctl check crs" to verify the health and availability of the cluster.
- Managing Voting Disks and OCR: Voting disks and the Oracle Cluster Registry (OCR) are critical components of Oracle Clusterware. Crsctl allows you to manage and maintain these components, including adding, removing, or relocating voting disks and OCR files.
- Viewing Logs and Diagnostic Information: Crsctl provides commands to view and manage log files and diagnostic information related to Clusterware components. You can retrieve logs, trace files, and diagnostic details to troubleshoot issues or monitor the cluster health.
- The crsctl utility plays a crucial role in the administration and management of Oracle Clusterware in a RAC environment. It is important to note that crsctl commands are typically run as the "root" user or with the appropriate administrative privileges to perform cluster-related operations
START/STOPPING 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
srvctl start database -d Dbname -o mount
START/STOPING INSTANCE:
srvctl stop instance -d Dbname -i instancename
srvctl start instance -d Dbname -i instancename
STOPPING/STARTING ASM:
srvctl start asm -n node2
srvctl stop asm -n node2
[grid@ora-db10 ~]$ sqlplus "/as sysasm"
SQL*Plus: Release 12.2.0.1.0 Production on Sat Jul 21 22:27:40 2023
Copyright (c) 1982, 2016, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
SQL> shutdown immediate;
ASM diskgroups dismounted
ASM instance shutdown
SQL> exit
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
srvctl config database -d PRODB
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:
Check the configuration of service
srvctl config service -d PREDB -s PRDB_SVC
srvctl add service -d PREDB -s PRDB_SRV -r "PREDB1,PREDB2" -a "PREDB2" -P BASIC
srvctl add service -d xxxxx -s test
srvctl start service -s test -d xxxxxx
or
[oracle@rac1 bin]$ ./srvctl add service -d cdbs -s cdbs_srvc -r cdbs1,cdbs2 -P BASIC
STOPPING/STARTING SERVICE:
srvctl stop service -d Dbname this will stop all the services on this db
srvctl start service -d Dbname this will start all the services on this db
srvctl stop service -d marsdb -s mars_oltp -i marsdb1
Error:
oracle@rac1 bin:/home/oracle>srvctl relocate service -d marsdb -s mars_oltp -i marsdb1 -t marsdb2
PRCD-1346 : failed to relocate services of database marsdb
PRCR-1089 : Failed to relocate resource ora.marsdb.mars_oltp.svc.
CRS-2717: Server 'oracle@rac1 bin' is not in any of the server pool(s) hosting resource 'ora.marsdb.mars_oltp.svc'
Solution:
When you create a service, you define which instances typically support that service. These are known as the preferred instances for that service.
You can also define other instances to support a service if the service's preferred instance fails. These are known as available instances for a service.
Here earlier the Available instances: marsdb has only one node
Preferred instances: marsdb1
Available instances: marsdb2
Here we have ran the below command and we have added extra node3 and node4
srvctl modify service -db marsdb -service mars_oltp -n -preferred marsdb2 -available marsdb1,marsdb2
Preferred instances: marsdb1
Available instances: marsdb2,marsdb1
srvctl relocate service -db marsdb -service mars_oltp -i marsdb1 -t marsdb2
REMOVING A SERVICE:
srvctl remove service -d PREDB -s PRDB_SRV
START A SERVICE
srvctl start service -d PREDB -s PRDB_SRV
. RELOCATE A SERVICE
srvctl relocate service -d PREDB -s PRDB_SVC -i PREDB2 -t PREDB1
Check the status of service
srvctl status service -d PREDB -s PRDB_SVC
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:
crs alert log file location
/u01/app/base/diag/crs/hostname/crs/trace
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='*';
/grid/12.1.0/grid/bin/crsctl status res -t
/grid/12.1.0/grid/bin/crsctl start res db.instance.lsproddb -f
/grid/12.1.0/grid/bin/crsctl status res -t
/grid/12.1.0/grid/bin/crsctl status res -t
/grid/12.1.0/grid/bin/crsctl stop res db.instance.lsproddb -f
/grid/12.1.0/grid/bin/crsctl status res -t
crsctl check cluster -all
Start and stop the Clusterware on all nodes or Single node
Start the clusterware
crsctl start cluster -all | -n nodename
Stop the clusterware
crsctl stop cluster -all | -n nodename
How to stop a particular resource
#crsctl stop resource myAppVIP
#crsctl stop resource myApache
#crsctl stop resource ora.asm
crs_stat -t|grep gsd
ora.node1.gsd application OFFLINE OFFLINE
ora.node2.gsd application OFFLINE OFFLINE
ora.gsd ora.gsd.type OFFLINE OFFLINE
How to stop a particular resource type. The following command will stop all resources belonging to scan_listener type
#crsctl stop resource -w “TYPE = ora.scan_listener.type”
Add and Delete resource with Crsctl commands
Example register apache web server application
crsctl add resource my_apache -type generic_application -attr "START_PROGRAM='/usr/sbin/httpd -k start',STOP_PROGRAM='/usr/sbin/httpd -k stop', PID_FILES=/etc/httpd/run/httpd.pid"
Drop resource
crsctl delete resource resource_name
Get the cluster configuration
crsctl get cluster configuration
Configure the CRS
#crsctl config crs
CRS-4622: Oracle High Availability Services autostart is enabled
Enable and disable the CRS
For enable
#crsctl enable crs
CRS-4622: Oracle High Availability Services autostart is enabled
For disable
#crsctl disable crs
CRS-4621: Oracle High Availability Services autostart is disabled
# ls -ltr /etc/oracle/scls_scr/rhel5-test/root/
-rw-r--r-- 1 root root 7 Sep 7 00:56 crsstart
-rw-r--r-- 1 root oinstall 5 Nov 22 17:04 ohasdrun
-rw-r--r-- 1 root oinstall 8 Nov 22 17:12 ohasdstr
# cat /etc/oracle/scls_scr/rhel5-test/root/crsstart
enable
# cat /etc/oracle/scls_scr/rhel5-test/root/ohasdstr
disable
To disable and stop Oracle Restart, use the CRSCTL utility to run the following commands:
$ <GI_HOME>crsctl check has
$ <GI_HOME>crsctl disable has
$ <GI_HOME>crsctl stop has
Use the CRSCTL utility to enable automatic restart of the components managed by Oracle Restart:
crsctl enable has
Use the CRSCTL utility to start Oracle Restart:
crsctl start has
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
srvctl start|stop mgmtlsnr
srvctl config mgmtlsnr
srvctl config mgmtlsnr
Name: MGMTLSNR
Type: Management Listener
Owner: grid
Home: <CRS home>
End points: TCP:1525
Management listener is enabled.
Management listener is individually enabled on nodes:
Management listener is individually disabled on nodes:
srvctl modify mgmtlsnr -endpoints “TCP:1531”
Manage MGMTDB Audit Files – See MOS 2202044.1
• Location: <GRID_BASE>/admin/_mgmtdb/adump
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 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
Create a TAF policy
srvctl add service -database orcl -service CRM -preferred ORCL1,ORCL2
srvctl add service -db ORCLDB -service TAF_ORCL -preferred ORCLDB1 -available ORCLDB2 -tafpolicy BASIC -failovertype SELECT
srvctl start service -db OMPREDB -service TAF_ORCL
Enjoy the work and do like me if you like this article!!!