Difference between revisions of "RAC"

From dbawiki
Jump to: navigation, search
(Status of an ASM instance on a RAC node)
 
(45 intermediate revisions by the same user not shown)
Line 1: Line 1:
 +
===Oracle RAC Overview===
 +
* [https://dbaprakash.wordpress.com/2015/03/30/oracle-rac-overview/ dbaprakash.wordpress.com]
 
Real Application Clusters (RAC) is an clustering solution whereby multiple Oracle instances can communicate with one database located on shared storage.<br />
 
Real Application Clusters (RAC) is an clustering solution whereby multiple Oracle instances can communicate with one database located on shared storage.<br />
Datafiles and controlfiles are shared but each instance will have its own redo log files and undo tablespace.
+
Datafiles and controlfiles are shared but each instance will have its own redo log files and undo tablespace.<br />
 +
Use crsctl to manage the clusterware<br />
 +
Use srvctl to manage the cluster<br />
 +
<br />
 +
* [https://saruamit4.wordpress.com/2013/04/10/cloning-oracle-home-in-rac/ cloning oracle home in RAC - Amit Saraswat]
 +
* [http://www.oracledbasupport.co.uk/rac-asm-crash-scenario/ Loss of a voting disk - oracledbasupport.co.uk]
 +
Know nothing about RAC? Go through the RAC Attack labs step-by-step installation for [https://en.wikibooks.org/wiki/RAC_Attack_-_Oracle_Cluster_Database_at_Home 11g RAC_Attack!]<br />
 +
or [https://en.wikibooks.org/wiki/RAC_Attack_-_Oracle_Cluster_Database_at_Home/RAC_Attack_12c 12c RACAttack] for an excellent (hands on) introduction.<br />
 +
* [[RAC Attack template]]
 +
===How to Backup and Restore a RAC Database===
 +
* [https://dbaprakash.wordpress.com/category/backup-and-recovery/ dbaprakash.wordpress.com]
 
===RAC components===
 
===RAC components===
 
====Virtual IP====
 
====Virtual IP====
Line 16: Line 28:
 
* evmd – Event Manager Daemon  
 
* evmd – Event Manager Daemon  
 
===RAC commands===
 
===RAC commands===
 +
====Location of Oracle Local Registry configuration file (olr.loc)====
 +
This file points to the clusters local node repository and depending on the OS, it is in one of these 2 locations
 +
<pre>
 +
cat /etc/oracle/olr.loc
 +
cat /var/loc/oracle/olr.loc
 +
</pre>
 +
This file is managed by OHASD and will point to the olrconfig_loc and the crs_home
 +
====Location of cluster config files====
 +
<pre>
 +
/etc/oracle/scls_scr/$HOSTNAME
 +
</pre>
 +
 +
====Some cluster control commands to check the status / health of the clusterware====
 +
<pre>
 +
crsctl status resource -t
 +
crsctl status server
 +
crsctl check cluster
 +
crsctl check crs
 +
crsctl query css votedisk
 +
crsctl query crs activeversion
 +
crsctl query crs releaseversion
 +
crsctl query crs softwareversion
 +
</pre>
 +
====List network interfaces available to this cluster node====
 +
<pre>
 +
oifcfg iflist -p
 +
</pre>
 +
====Is Oracle Restart (High Availability Service) enabled?====
 +
<pre>
 +
cat /etc/oracle/scls_scr/$HOSTNAME/oracle/ohasdstr
 +
crsctl check has
 +
crsctl config has
 +
crsctl start has
 +
crsctl stop has
 +
crsctl disable has
 +
crsctl enable has
 +
</pre>
 +
 +
====Is ASM autostart enabled?====
 +
<pre>
 +
crsctl stat res ora.asm
 +
</pre>
 +
====Are diskgroups registered?====
 +
<pre>
 +
srvctl status diskgroup -g DATA
 +
crsctl stat res ora.DATA.dg
 +
</pre>
 +
====Is database registered and autostart enabled?====
 +
<pre>
 +
srvctl config database -d <database>
 +
</pre>
 +
if not...
 +
<pre>
 +
srvctl add database <database>
 +
srvctl enable database <database>
 +
</pre>
 +
====Set ASM diskgroups to be used by database====
 +
<pre>
 +
srvctl modify database -d <database> -diskgroup "DATA,FRA"
 +
</pre>
 
====Stop and start the clusterware services====
 
====Stop and start the clusterware services====
To find the correct home, can also search /etc/oratab for the relevant ASM instance and use . oraenv
+
To set the correct home, can also search /etc/oratab for the relevant ASM instance and use . oraenv
 
<pre>
 
<pre>
export ORA_CRS_HOME=/u01/app/12.1.0.2/grid
+
export ORA_CRS_HOME=$(awk -F: '/+ASM/ {print $2}' /etc/oratab)
 
$ORA_CRS_HOME/bin/crsctl start crs
 
$ORA_CRS_HOME/bin/crsctl start crs
 
$ORA_CRS_HOME/bin/crsctl stop crs
 
$ORA_CRS_HOME/bin/crsctl stop crs
 
</pre>
 
</pre>
 +
 
===Prevent cluster services from starting up on boot===
 
===Prevent cluster services from starting up on boot===
 
<pre>
 
<pre>
 
$ORA_CRS_HOME/bin/crsctl disable crs
 
$ORA_CRS_HOME/bin/crsctl disable crs
 
</pre>
 
</pre>
===Re-enable cluster services===
+
===Re-enable clusterware services===
 
<pre>
 
<pre>
 
$ORA_CRS_HOME/bin/crsctl enable crs
 
$ORA_CRS_HOME/bin/crsctl enable crs
 
</pre>
 
</pre>
 +
 
===List the resources under cluster control===
 
===List the resources under cluster control===
 
<pre>
 
<pre>
$ORA_CRS_HOME/bin/crs_stat -t
+
$ORA_CRS_HOME/bin/crsctl status resource -t
 +
or
 +
$ORA_CRS_HOME/bin/crsctl stat res -t
 +
</pre>
 +
or
 +
<pre>
 +
crsctl status res |grep -v "^$"|awk -F "=" 'BEGIN {print " "} {printf("%s",NR%4 ? $2"|" : $2"\n")}'|sed -e 's/  *, /,/g' -e 's/, /,/g'|\
 +
awk -F "|" 'BEGIN { printf "%-40s%-35s%-20s%-50s\n","Resource Name","Resource Type","Target ","State" }{ split ($3,trg,",") split ($4,st,",")}{for (i in trg) {printf "%-40s%-35s%-20s%-50s\n",$1,$2,trg[i],st[i]}}'
 +
</pre>
 +
 
 +
===Find the ORACLE_HOME from a database cluster metadata file===
 +
<pre>
 +
crsctl stat res ora.proddb11.db -p | grep ORACLE_HOME
 +
</pre>
 +
===Stop all the cluster resources for a particular ORACLE_HOME===
 +
If all resources for a home need to go down (e.g. for patching), this should do it.<br />
 +
Save the state so that the start command knows what to start and what not to.
 +
<pre>
 +
srvctl stop home -o /oracle/product/11.2.0.4 -s /oracle/state_file_11204
 +
or
 +
srvctl stop home -oraclehome /oracle/product/11.2.0.4 -statefile /oracle/state_file_11204
 +
or
 +
srvctl stop home -oraclehome /u01/app/oracle/product/12.1.0.2/dbhome_1 -statefile /home/oracle/home_state_20170111 -node sdtcsynoda02-rac -stopoption IMMEDIATE -force
 +
</pre>
 +
Before running the startup, the state file can be edited and instances added/removed as it is a simple text file
 +
<pre>
 +
srvctl start home -o /u01/app/oracle/product/12.1.0.2/dbhome_1 -s /oracle/state_file_12102 -node sdtcsynoda02-rac
 
</pre>
 
</pre>
  
Line 53: Line 153:
 
====Stop all instances of a RAC database====
 
====Stop all instances of a RAC database====
 
<pre>
 
<pre>
srvctl stop instance –d <db_name>
+
srvctl stop database –db <db_name>
 +
e.g.
 +
srvctl stop database -db ACCINGPX
 +
</pre>
 +
====Start all instances of a RAC database====
 +
<pre>
 +
srvctl start database –db <db_name>
 +
e.g.
 +
srvctl start database -db ACCINGPX
 +
</pre>
 +
====Start a database in mount mode====
 +
<pre>
 +
srvctl start database –db <db_name> -o <start option>
 +
e.g.
 +
srvctl start database -db ACCINGPX -o mount
 
</pre>
 
</pre>
  
Line 63: Line 177:
 
</pre>
 
</pre>
  
====Stop all node applications on a RAC node====
+
====Start / Stop all node applications on a RAC node====
 
<pre>
 
<pre>
 +
srvctl start nodeapps –n <rac node>
 
srvctl stop nodeapps –n <rac node>
 
srvctl stop nodeapps –n <rac node>
 +
srvctl status nodeapps –n <rac node>
 
</pre>
 
</pre>
 +
 
====Start / Stop a listener on a RAC node====
 
====Start / Stop a listener on a RAC node====
 
<pre>
 
<pre>
 
srvctl start|stop listener -n node_name [-l listener_name_list]
 
srvctl start|stop listener -n node_name [-l listener_name_list]
 +
e.g.
 +
srvctl start listener -n node2
 +
srvctl start listener -n node2 -l DATAGUARD_LISTENER
 +
srvctl stop LISTENER_SCAN1
 
</pre>
 
</pre>
 +
 
====Start / Stop services on a RAC node====
 
====Start / Stop services on a RAC node====
'''srvctl stop database command implicity does a srvctl stop services (because services are dependent on database).However, a subsequent srvctl start database requires an explicit srvctl start service'''
+
'''srvctl stop database command implicity does a srvctl stop services (because services are dependent on database).'''<br />
 +
'''However, a subsequent srvctl start database requires an explicit srvctl start service'''
 
* service name list is optional and if not provided, the SRVCTL starts all of the database's services<br />
 
* service name list is optional and if not provided, the SRVCTL starts all of the database's services<br />
 
* -c connect_str Connect string (default: / as sysdba)<br />
 
* -c connect_str Connect string (default: / as sysdba)<br />
Line 83: Line 206:
 
====Status of an ASM instance on a RAC node====
 
====Status of an ASM instance on a RAC node====
 
<pre>
 
<pre>
srvctl status asm -n oranode1
+
srvctl status asm -n sdtcsynoda01-rac
srvctl status asm -n oranode2
+
srvctl status asm -n sdtcsynoda02-rac
 +
</pre>
 +
====Status of the database, all instances and all services====
 +
<pre>
 +
srvctl status database -d TSTEV3 -v
 +
</pre>
 +
<pre>
 +
Instance TSTEV31 is running on node sdtcsynoda01-rac
 +
Instance TSTEV32 is running on node sdtcsynoda02-rac
 +
</pre>
 +
====Status of named instances with their current services (if on local node)====
 +
<pre>
 +
srvctl status instance -d TSTEV3 -i TSTEV31 -v
 +
</pre>
 +
<pre>
 +
Instance TSTEV31 is running on node sdtcsynoda01-rac. Instance status: Open.
 +
</pre>
 +
<pre>
 +
srvctl status instance -d TSTEV3 -i TSTEV32 -v
 +
</pre>
 +
<pre>
 +
Instance TSTEV32 is running on node sdtcsynoda02-rac with online services DOTS. Instance status: Open.
 +
</pre>
 +
====Add a new node====
 +
<pre>
 +
srvctl add nodeapps -n myclust-1 -o $ORACLE_HOME –A 139.184.201.1/255.255.255.0/hme0
 +
</pre>
 +
====Add a new database====
 +
<pre>
 +
srvctl add database -d ORACLE -o $ORACLE_HOME
 +
eg.
 +
srvctl add database -d MASTASPO -o /u01/app/oracle/product/12.1.0.2/dbhome_1 -r PHYSICAL_STANDBY -s MOUNT
 +
</pre>
 +
 
 +
====Add named instances to an existing database====
 +
<pre>
 +
srvctl add instance -d ORACLE -i RAC01 -n myclust-1
 +
srvctl add instance -d ORACLE -i RAC02 -n myclust-2
 +
srvctl add instance -d ORACLE -i RAC03 -n myclust-3
 +
eg.
 +
srvctl add instance -d MASTASPO -i MASTASPO -n sdtcoda01-rac
 +
</pre>
 +
 
 +
====Add a service to an existing database with preferred instances (-r) and available instances (-a). Use basic failover to the available instances====
 +
<pre>
 +
srvctl add service -d ORACLE -s STD_BATCH -r RAC01 -a RAC02
 +
</pre>
 +
 
 +
====Add a service to an existing database with preferred instances (-r) and available instances (-a). Use preconnect at the available instances====
 +
<pre>
 +
srvctl add service -d ORACLE -s STD_BATCH -r RAC01 -a RAC02 -P PRECONNECT
 +
</pre>
 +
====Remove the applications for a database====
 +
<pre>
 +
srvctl remove database -d ORACLE
 +
</pre>
 +
====Remove the applications for named instances of an existing database====
 +
<pre>
 +
srvctl remove instance -d ORACLE -i RAC03
 +
srvctl remove instance -d ORACLE -i RAC04
 +
</pre>
 +
====Remove the service====
 +
<pre>
 +
srvctl remove service -d ORACLE -s STD_BATCH
 +
</pre>
 +
====Remove the service from the instances====
 +
<pre>
 +
srvctl remove service -d ORACLE -s STD_BATCH -i RAC03,RAC04
 +
</pre>
 +
====Remove all node applications from a node====
 +
<pre>
 +
srvctl remove nodeapps -n myclust-4
 +
</pre>
 +
====Modify an instance to execute on another node====
 +
<pre>
 +
srvctl modify instance -d ORACLE -n myclust-4
 +
</pre>
 +
====Modify a service to execute on another node====
 +
<pre>
 +
srvctl modify service -d ORACLE -s HOT_BATCH -i RAC01 -t RAC02
 +
</pre>
 +
====Modify an instance to be a preferred instance for a service====
 +
<pre>
 +
srvctl modify service -d ORACLE -s HOT_BATCH -i RAC02 –r
 +
</pre>
 +
====Relocate a service from one instance to another====
 +
<pre>
 +
srvctl relocate service -d orac -s CRM -i RAC04 -t RAC01
 +
</pre>
 +
====Switchover / failover a database from one node (server) to another====
 +
<pre>
 +
srvctl relocate db -d orac -n server02
 +
</pre>
 +
 
 +
===Enable CRS resources (resources can be up or down when these commands are issued)===
 +
====Enable the database====
 +
<pre>
 +
srvctl enable database -d ORACLE
 +
</pre>
 +
====Enable the named instances====
 +
<pre>
 +
srvctl enable instance -d ORACLE -i RAC01, RAC02
 +
</pre>
 +
====Enable the service====
 +
<pre>
 +
srvctl enable service -d ORACLE -s ERP,CRM
 +
</pre>
 +
====Enable the service at the named instance====
 +
<pre>
 +
srvctl enable service -d ORACLE -s CRM -i RAC03
 +
</pre>
 +
===Disable CRS resources (resources must be down when these commands are issued)===
 +
====Disable the database globally====
 +
<pre>
 +
srvctl disable database -d ORACLE
 +
</pre>
 +
====Disable the named instances====
 +
<pre>
 +
srvctl disable instance -d ORACLE -i RAC01, RAC02
 +
</pre>
 +
====Disable the service(s) globally====
 +
<pre>
 +
srvctl disable service -d ORACLE -s ERP,CRM
 +
</pre>
 +
 
 +
====Disable the service on the named instance====
 +
<pre>
 +
srvctl disable service -d ORACLE -s CRM -i RAC02
 +
</pre>
 +
 
 +
====Status of a named services====
 +
<pre>
 +
srvctl status service -d TSTEV3 -s DOTS -v
 +
</pre>
 +
 
 +
====Status of all nodes supporting database applications====
 +
<pre>
 +
srvctl status nodeapps
 
</pre>
 
</pre>
  

Latest revision as of 12:14, 4 September 2018

Contents

Oracle RAC Overview[edit]

Real Application Clusters (RAC) is an clustering solution whereby multiple Oracle instances can communicate with one database located on shared storage.
Datafiles and controlfiles are shared but each instance will have its own redo log files and undo tablespace.
Use crsctl to manage the clusterware
Use srvctl to manage the cluster

Know nothing about RAC? Go through the RAC Attack labs step-by-step installation for 11g RAC_Attack!
or 12c RACAttack for an excellent (hands on) introduction.

How to Backup and Restore a RAC Database[edit]

RAC components[edit]

Virtual IP[edit]

A virtual IP address is an IP address setup to "float" between the real IP addresses associated with each instance in the cluster. If the IP address assigned to the virtual IP becomes unavailable, the IP address from the still available instance will be assigned to the virtual IP thus maintaining database availability for the users.

Voting Disk[edit]

A Voting Disk is a file on a shared filesystem. It maintains a list of available cluster nodes and can resolve split-brain scenarios.
All instances write to the voting disk to indicate that they are still active.

Cluster Registry[edit]

The Cluster Registry (OCR) is used to store cluster wide settings and status information such as node names, IP and VIP addresses, voting disk locations, node applications, database names, instance names, listener names, etc.

Clusterware processes[edit]

A RAC cluster consists of the following daemons

  • crsd – Cluster Resource Services Daemon
  • cssd – Cluster Synchronisation Services Daemon
  • evmd – Event Manager Daemon

RAC commands[edit]

Location of Oracle Local Registry configuration file (olr.loc)[edit]

This file points to the clusters local node repository and depending on the OS, it is in one of these 2 locations

cat /etc/oracle/olr.loc
cat /var/loc/oracle/olr.loc

This file is managed by OHASD and will point to the olrconfig_loc and the crs_home

Location of cluster config files[edit]

/etc/oracle/scls_scr/$HOSTNAME

Some cluster control commands to check the status / health of the clusterware[edit]

crsctl status resource -t
crsctl status server
crsctl check cluster
crsctl check crs
crsctl query css votedisk
crsctl query crs activeversion
crsctl query crs releaseversion
crsctl query crs softwareversion

List network interfaces available to this cluster node[edit]

oifcfg iflist -p

Is Oracle Restart (High Availability Service) enabled?[edit]

cat /etc/oracle/scls_scr/$HOSTNAME/oracle/ohasdstr
crsctl check has
crsctl config has
crsctl start has
crsctl stop has
crsctl disable has
crsctl enable has

Is ASM autostart enabled?[edit]

crsctl stat res ora.asm

Are diskgroups registered?[edit]

srvctl status diskgroup -g DATA
crsctl stat res ora.DATA.dg

Is database registered and autostart enabled?[edit]

srvctl config database -d <database>

if not...

srvctl add database <database>
srvctl enable database <database>

Set ASM diskgroups to be used by database[edit]

srvctl modify database -d <database> -diskgroup "DATA,FRA"

Stop and start the clusterware services[edit]

To set the correct home, can also search /etc/oratab for the relevant ASM instance and use . oraenv

export ORA_CRS_HOME=$(awk -F: '/+ASM/ {print $2}' /etc/oratab)
$ORA_CRS_HOME/bin/crsctl start crs
$ORA_CRS_HOME/bin/crsctl stop crs

Prevent cluster services from starting up on boot[edit]

$ORA_CRS_HOME/bin/crsctl disable crs

Re-enable clusterware services[edit]

$ORA_CRS_HOME/bin/crsctl enable crs

List the resources under cluster control[edit]

$ORA_CRS_HOME/bin/crsctl status resource -t
or
$ORA_CRS_HOME/bin/crsctl stat res -t

or

crsctl status res |grep -v "^$"|awk -F "=" 'BEGIN {print " "} {printf("%s",NR%4 ? $2"|" : $2"\n")}'|sed -e 's/  *, /,/g' -e 's/, /,/g'|\
awk -F "|" 'BEGIN { printf "%-40s%-35s%-20s%-50s\n","Resource Name","Resource Type","Target ","State" }{ split ($3,trg,",") split ($4,st,",")}{for (i in trg) {printf "%-40s%-35s%-20s%-50s\n",$1,$2,trg[i],st[i]}}'

Find the ORACLE_HOME from a database cluster metadata file[edit]

crsctl stat res ora.proddb11.db -p | grep ORACLE_HOME

Stop all the cluster resources for a particular ORACLE_HOME[edit]

If all resources for a home need to go down (e.g. for patching), this should do it.
Save the state so that the start command knows what to start and what not to.

srvctl stop home -o /oracle/product/11.2.0.4 -s /oracle/state_file_11204
or
srvctl stop home -oraclehome /oracle/product/11.2.0.4 -statefile /oracle/state_file_11204
or
srvctl stop home -oraclehome /u01/app/oracle/product/12.1.0.2/dbhome_1 -statefile /home/oracle/home_state_20170111 -node sdtcsynoda02-rac -stopoption IMMEDIATE -force

Before running the startup, the state file can be edited and instances added/removed as it is a simple text file

srvctl start home -o /u01/app/oracle/product/12.1.0.2/dbhome_1 -s /oracle/state_file_12102 -node sdtcsynoda02-rac

General syntax for starting and stopping a RAC instance[edit]

srvctl start|stop instance -d <db_unique_name> -i <inst_name_list> [-o start_options]|[-o stop_options]  [-c connect_str | -q]

Stop one instance of a RAC database[edit]

srvctl stop instance –d <db_name> –i <instance_name>

Start an ASM instance on a specific node[edit]

srvctl start instance –n <node_name>
e.g.
srvctl start prodctl –n asmnode1

Stop all instances of a RAC database[edit]

srvctl stop database –db <db_name>
e.g.
srvctl stop database -db ACCINGPX

Start all instances of a RAC database[edit]

srvctl start database –db <db_name>
e.g.
srvctl start database -db ACCINGPX

Start a database in mount mode[edit]

srvctl start database –db <db_name> -o <start option>
e.g.
srvctl start database -db ACCINGPX -o mount

Stop ASM on a RAC node[edit]

srvctl stop asm –n <rac node>
e.g.
srvctl stop asm –n asmnode1 -o immediate

Start / Stop all node applications on a RAC node[edit]

srvctl start nodeapps –n <rac node>
srvctl stop nodeapps –n <rac node>
srvctl status nodeapps –n <rac node>

Start / Stop a listener on a RAC node[edit]

srvctl start|stop listener -n node_name [-l listener_name_list]
e.g.
srvctl start listener -n node2
srvctl start listener -n node2 -l DATAGUARD_LISTENER
srvctl stop LISTENER_SCAN1

Start / Stop services on a RAC node[edit]

srvctl stop database command implicity does a srvctl stop services (because services are dependent on database).
However, a subsequent srvctl start database requires an explicit srvctl start service

  • service name list is optional and if not provided, the SRVCTL starts all of the database's services
  • -c connect_str Connect string (default: / as sysdba)
  • -q Query connect string from standard input
srvctl start service -d <db_unique_name> [-s service_name_list [-i <inst_name>]]  [-o <start_options>] [-c connect_str | -q]
srvctl stop service -d db_unique_name [-s service_name_list [-i inst_name]]  [-c connect_str | -q] [-f]

Status of an ASM instance on a RAC node[edit]

srvctl status asm -n sdtcsynoda01-rac
srvctl status asm -n sdtcsynoda02-rac

Status of the database, all instances and all services[edit]

srvctl status database -d TSTEV3 -v
Instance TSTEV31 is running on node sdtcsynoda01-rac
Instance TSTEV32 is running on node sdtcsynoda02-rac

Status of named instances with their current services (if on local node)[edit]

srvctl status instance -d TSTEV3 -i TSTEV31 -v
Instance TSTEV31 is running on node sdtcsynoda01-rac. Instance status: Open.
srvctl status instance -d TSTEV3 -i TSTEV32 -v
Instance TSTEV32 is running on node sdtcsynoda02-rac with online services DOTS. Instance status: Open.

Add a new node[edit]

srvctl add nodeapps -n myclust-1 -o $ORACLE_HOME –A 139.184.201.1/255.255.255.0/hme0

Add a new database[edit]

srvctl add database -d ORACLE -o $ORACLE_HOME
eg.
srvctl add database -d MASTASPO -o /u01/app/oracle/product/12.1.0.2/dbhome_1 -r PHYSICAL_STANDBY -s MOUNT

Add named instances to an existing database[edit]

srvctl add instance -d ORACLE -i RAC01 -n myclust-1
srvctl add instance -d ORACLE -i RAC02 -n myclust-2
srvctl add instance -d ORACLE -i RAC03 -n myclust-3
eg.
srvctl add instance -d MASTASPO -i MASTASPO -n sdtcoda01-rac

Add a service to an existing database with preferred instances (-r) and available instances (-a). Use basic failover to the available instances[edit]

srvctl add service -d ORACLE -s STD_BATCH -r RAC01 -a RAC02

Add a service to an existing database with preferred instances (-r) and available instances (-a). Use preconnect at the available instances[edit]

srvctl add service -d ORACLE -s STD_BATCH -r RAC01 -a RAC02 -P PRECONNECT

Remove the applications for a database[edit]

srvctl remove database -d ORACLE

Remove the applications for named instances of an existing database[edit]

srvctl remove instance -d ORACLE -i RAC03
srvctl remove instance -d ORACLE -i RAC04

Remove the service[edit]

srvctl remove service -d ORACLE -s STD_BATCH

Remove the service from the instances[edit]

srvctl remove service -d ORACLE -s STD_BATCH -i RAC03,RAC04

Remove all node applications from a node[edit]

srvctl remove nodeapps -n myclust-4

Modify an instance to execute on another node[edit]

srvctl modify instance -d ORACLE -n myclust-4

Modify a service to execute on another node[edit]

srvctl modify service -d ORACLE -s HOT_BATCH -i RAC01 -t RAC02

Modify an instance to be a preferred instance for a service[edit]

srvctl modify service -d ORACLE -s HOT_BATCH -i RAC02 –r

Relocate a service from one instance to another[edit]

srvctl relocate service -d orac -s CRM -i RAC04 -t RAC01

Switchover / failover a database from one node (server) to another[edit]

srvctl relocate db -d orac -n server02

Enable CRS resources (resources can be up or down when these commands are issued)[edit]

Enable the database[edit]

srvctl enable database -d ORACLE

Enable the named instances[edit]

srvctl enable instance -d ORACLE -i RAC01, RAC02

Enable the service[edit]

srvctl enable service -d ORACLE -s ERP,CRM

Enable the service at the named instance[edit]

srvctl enable service -d ORACLE -s CRM -i RAC03

Disable CRS resources (resources must be down when these commands are issued)[edit]

Disable the database globally[edit]

srvctl disable database -d ORACLE

Disable the named instances[edit]

srvctl disable instance -d ORACLE -i RAC01, RAC02

Disable the service(s) globally[edit]

srvctl disable service -d ORACLE -s ERP,CRM

Disable the service on the named instance[edit]

srvctl disable service -d ORACLE -s CRM -i RAC02

Status of a named services[edit]

srvctl status service -d TSTEV3 -s DOTS -v

Status of all nodes supporting database applications[edit]

srvctl status nodeapps

How to tell if database is a RAC cluster[edit]

This will be TRUE if RAC database

show parameter cluster

or, the GV$ views will show more than 1 record

select * from gv$instance;

   INST_ID INSTANCE_NUMBER INSTANCE_NAME    HOST_NAME                                                        VERSION           STARTUP_T STATUS       PAR    THREAD# ARCHIVE LOG_SWITCH_WAIT LOGINS     SHU DATABASE_STATUS   INSTANCE_ROLE      ACTIVE_ST BLO     CON_ID INSTANCE_MO EDITION FAMILY
---------- --------------- ---------------- ---------------------------------------------------------------- ----------------- --------- ------------ --- ---------- ------- --------------- ---------- --- ----------------- ------------------ --------- --- ---------- ----------- ------- --------------------------------------------------------------------------------
         2               2 DEV32          oda02-rac                                                 12.1.0.2.0        20-JUL-16 OPEN         YES         2 STARTED                  ALLOWED    NO  ACTIVE            PRIMARY_INSTANCE   NORMAL    NO           0 REGULAR     EE
         1               1 DEV31          oda01-rac                                                 12.1.0.2.0        13-OCT-16 OPEN         YES         1 STARTED                  ALLOWED    NO  ACTIVE            PRIMARY_INSTANCE   NORMAL    NO           0 REGULAR     EE

2 rows selected.

or

set serverout on
begin
    if dbms_utility.is_cluster_database then
        dbms_output.put_line('Running in RAC mode.');
    else
        dbms_output.put_line('Running in EXCLUSIVE mode.');
    end if;
end;
/

or

select * from v_$active_instances;

or

select * from v_$thread;

Show session distribution across the RAC nodes[edit]

select inst_id
,      count(*) sessions
from   gv$session
where  type = 'USER'
group  by inst_id
/