Difference between revisions of "RAC"

From dbawiki
Jump to: navigation, search
(Status of an ASM instance on a RAC node)
(Start / Stop services on a RAC node)
Line 72: Line 72:
 
</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 />

Revision as of 12:25, 9 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.

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

Stop and start the clusterware services

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

export ORA_CRS_HOME=/u01/app/12.1.0.2/grid
$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/crs_stat -t

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

Stop all node applications on a RAC node

srvctl stop 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
/