Difference between revisions of "RAC"
(→List the resources under cluster control) |
|||
| Line 1: | Line 1: | ||
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 /> | ||
===RAC components=== | ===RAC components=== | ||
====Virtual IP==== | ====Virtual IP==== | ||
Revision as of 11:57, 12 January 2017
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
Contents
- 1 RAC components
- 2 RAC commands
- 2.1 Location of Oracle Local Registry configuration file (olr.loc)
- 2.2 Location of cluster config files
- 2.3 Is Oracle Restart enabled?
- 2.4 Is ASM autostart enabled?
- 2.5 Are diskgroups registered?
- 2.6 Is database registered and autostart enabled?
- 2.7 Set ASM diskgroups to be used by database
- 2.8 Stop and start the clusterware services
- 3 Prevent cluster services from starting up on boot
- 4 Re-enable cluster services
- 5 List the resources under cluster control
- 6 Find the ORACLE_HOME from a database cluster metadata file
- 7 Stop all the cluster resources for a particular ORACLE_HOME
- 7.1 General syntax for starting and stopping a RAC instance
- 7.2 Stop one instance of a RAC database
- 7.3 Start an ASM instance on a specific node
- 7.4 Stop all instances of a RAC database
- 7.5 Stop ASM on a RAC node
- 7.6 Start / Stop all node applications on a RAC node
- 7.7 Start / Stop a listener on a RAC node
- 7.8 Start / Stop services on a RAC node
- 7.9 Status of an ASM instance on a RAC node
- 7.10 How to tell if database is a RAC cluster
- 7.11 Show session distribution across the RAC nodes
RAC components
Virtual IP
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
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
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
A RAC cluster consists of the following daemons
- crsd – Cluster Resource Services Daemon
- cssd – Cluster Synchronisation Services Daemon
- evmd – Event Manager Daemon
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
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
/etc/oracle/scls_scr/$HOSTNAME
Is Oracle Restart enabled?
cat /etc/oracle/scls_scr/$HOSTNAME/oracle/ohasdstr crsctl disable has crsctl enable has
Is ASM autostart enabled?
crsctl stat res ora.asm
Are diskgroups registered?
srvctl status diskgroup -g DATA crsctl stat res ora.DATA.dg
Is database registered and autostart enabled?
srvctl config database -d <database>
if not...
srvctl add database <database> srvctl enable database <database>
Set ASM diskgroups to be used by database
srvctl modify database -d <database> -diskgroup "DATA,FRA"
Stop and start the clusterware services
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
$ORA_CRS_HOME/bin/crsctl disable crs
Re-enable cluster services
$ORA_CRS_HOME/bin/crsctl enable crs
List the resources under cluster control
$ORA_CRS_HOME/bin/crsctl status resource -t or $ORA_CRS_HOME/bin/crsctl stat res -t
Find the ORACLE_HOME from a database cluster metadata file
crsctl stat res ora.proddb11.db -p | grep ORACLE_HOME
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
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
General syntax for starting and stopping a RAC instance
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
srvctl stop instance –d <db_name> –i <instance_name>
Start an ASM instance on a specific node
srvctl start instance –n <node_name> e.g. srvctl start prodctl –n asmnode1
Stop all instances of a RAC database
srvctl stop instance –d <db_name>
Stop ASM on a RAC node
srvctl stop asm –n <rac node> e.g. srvctl stop asm –n asmnode1 -o immediate
Start / Stop all node applications on a RAC node
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
srvctl start|stop listener -n node_name [-l listener_name_list]
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
- 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
srvctl status asm -n oranode1 srvctl status asm -n oranode2
How to tell if database is a RAC cluster
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
select inst_id , count(*) sessions from gv$session where type = 'USER' group by inst_id /