RAC Crib Sheet

Some quick notes on RAC cluster commands.

Also see: http://www.dba-oracle.com/real_application_clusters_rac_grid/srvctl.htm

[grid@PRSODB01 ~]$ crsctl check cluster -all
**************************************************************
prsodb01:
CRS-4537: Cluster Ready Services is online
CRS-4529: Cluster Synchronization Services is online
CRS-4533: Event Manager is online
**************************************************************
prsodb02:
CRS-4537: Cluster Ready Services is online
CRS-4529: Cluster Synchronization Services is online
CRS-4533: Event Manager is online
**************************************************************


Example of RAC Cluster


[grid@PRSODB01 ~]$ crsctl status resource -t
--------------------------------------------------------------------------------
Name Target State Server State details
-------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.DATA.dg
ONLINE ONLINE prsodb01 STABLE
ONLINE ONLINE prsodb02 STABLE
ora.FRA.dg
ONLINE ONLINE prsodb01 STABLE
ONLINE ONLINE prsodb02 STABLE
ora.LISTENER.lsnr
ONLINE ONLINE prsodb01 STABLE
ONLINE ONLINE prsodb02 STABLE
ora.asm
ONLINE ONLINE prsodb01 Started,STABLE
ONLINE ONLINE prsodb02 Started,STABLE
ora.net1.network
ONLINE ONLINE prsodb01 STABLE
ONLINE ONLINE prsodb02 STABLE
ora.ons
ONLINE ONLINE prsodb01 STABLE
ONLINE ONLINE prsodb02 STABLE
--------------------------------------------------------------------------------

Cluster Resources
--------------------------------------------------------------------------------
ora.LISTENER_SCAN1.lsnr
1 ONLINE ONLINE prsodb01 STABLE
ora.prsodb01.vip
1 ONLINE ONLINE prsodb01 STABLE
ora.prsodb02.vip
1 ONLINE ONLINE prsodb02 STABLE
ora.cvu
1 ONLINE ONLINE prsodb02 STABLE
ora.oc4j
1 OFFLINE OFFLINE STABLE
ora.patches.db
1 OFFLINE OFFLINE Instance Shutdown,ST
ABLE
2 OFFLINE OFFLINE Instance Shutdown,ST
ABLE
ora.preprod.db
1 ONLINE ONLINE prsodb01 Open,STABLE
2 ONLINE ONLINE prsodb02 Open,STABLE
ora.preprod.preprod_lmsstp.scc.local.svc
1 ONLINE ONLINE prsodb01 STABLE
2 ONLINE ONLINE prsodb02 STABLE
ora.rpap_gdc2.db
1 OFFLINE OFFLINE Instance Shutdown,ST
ABLE
2 OFFLINE OFFLINE Instance Shutdown,ST
ABLE
ora.scan1.vip
1 ONLINE ONLINE prsodb01 STABLE
ora.sit.db
1 ONLINE ONLINE prsodb01 Open,STABLE
2 ONLINE OFFLINE STABLE
ora.sit.osmm.scc.local.svc
1 ONLINE ONLINE prsodb01 STABLE
--------------------------------------------------------------------------------

[grid@PRSODB01 ~]$ crsctl status server
NAME=prsodb01
STATE=ONLINE
NAME=prsodb02
STATE=ONLINE

[grid@PRSODB01 ~]$ crsctl check cluster
CRS-4537: Cluster Ready Services is online
CRS-4529: Cluster Synchronization Services is online
CRS-4533: Event Manager is online

[grid@PRSODB01 ~]$ crsctl check crs
CRS-4638: Oracle High Availability Services is online
CRS-4537: Cluster Ready Services is online
CRS-4529: Cluster Synchronization Services is online
CRS-4533: Event Manager is online

[grid@PRSODB01 ~]$ crsctl query crs softwareversion
Oracle Clusterware version on node [prsodb01] is [12.1.0.1.0]

[oracle@PRSODB01 ~]$ srvctl status database -db SIT
Instance sit1 is running on node prsodb01
Instance sit2 is not running on node prsodb02

[oracle@PRSODB01 ~]$ srvctl status database -db PREPROD
Instance preprod1 is running on node prsodb01
Instance preprod2 is running on node prsodb02

[oracle@PRSODB01 ~]$ srvctl config nodeapps
Network 1 exists
Subnet IPv4: 192.168.98.0/255.255.255.192/eth0, static
Subnet IPv6:
VIP exists: network number 1, hosting node prsodb01
VIP Name: prsodb01-vip.scc.local
VIP IPv4 Address: 192.168.98.31
VIP IPv6 Address:
VIP exists: network number 1, hosting node prsodb02
VIP Name: prsodb02-vip.scc.local
VIP IPv4 Address: 192.168.98.32
VIP IPv6 Address:
ONS exists: Local port 6100, remote port 6200, EM port 2016

[oracle@PRSODB01 ~]$ srvctl config listener
Name: LISTENER
Network: 1, Owner: grid
Home:
End points: TCP:1800

[oracle@PRSODB01 ~]$ srvctl config asm
ASM home: /u01/app/12.1.0.1/grid
Password file: +DATA/orapwASM
ASM listener: LISTENER

[oracle@PRSODB01 ~]$ srvctl status asm
ASM is running on prsodb01,prsodb02

[oracle@PRSODB01 ~]$ srvctl –help

 -output removed for brevity but for reference included the command.

Check RAC related service status.
srvctl status -d DATABASE_UNIQUE_NAME
srvctl status nodeapps
srvctl status diskgroup -g DISKGROUP_NAME -a
srvctl status listener
srvctl status asm
Use config option can configure the related service. However, if we don’t provide any parameters, it would show the detail for the service.
srvctl config -d DATABASE_UNIQUE_NAME
srvctl config nodeapps
srvctl config listener
srvctl config asm
crsctl status resource -t
crsctl status server
crsctl check cluster
crsctl check crs
crsctl query css votedisk
crsctl querry crs activeversion
crsctl query crs releaseversion
crsctl query crs softwareversion
Read more at :



MobaXTerm download feature

Although I mainly use Putty as a terminal emulator (very small footprint), MobaXTerm is  very handy: https://mobaxterm.mobatek.net/download.html

One thing that can be very useful is the download option; saves using the likes of WinSCP or Filezilla. Thought I would stick this on here as easy to forget about this feature.


Just right click on the file you need and download; you can cut & paste the directory you require into the small box (i.e replace /home/oracle with whatever you need).

Rebuild indexes / partitions current user

--rebuild any indexes or index partitions for the current user
set serveroutput on
declare
  procedure ddl (str in varchar2) is
  begin
    execute immediate (str);
    dbms_output.put_line (str);
  end ddl;
begin
  for t in (select table_name from user_tables order by table_name) loop 
    for i in (
        select index_name, partition_name, 'partition' ddl_type
        from user_ind_partitions
        where (index_name) in
           ( select index_name
             from   user_indexes
             where  table_name  = t.table_name
           )
        and status = 'UNUSABLE'
        union all
        select index_name, subpartition_name, 'subpartition' ddl_type
        from user_ind_subpartitions
        where (index_name) in
           ( select index_name
             from   user_indexes
             where  table_name  = t.table_name
           )
        and status = 'UNUSABLE'
        union all
        select index_name, null, null
        from user_indexes
        where table_name  = t.table_name
        and status = 'UNUSABLE'
    )
    loop
      if i.ddl_type is null then
        ddl('alter index '||i.index_name||' rebuild');
      else
        ddl('alter index '||i.index_name||' rebuild '||i.ddl_type||' '||i.partition_name);
      end if;
    end loop;
  end loop;
end;
/