Wednesday, July 31, 2013

11gR2 Clusterware and Grid Home - What You Need to Know

1050908.1 - troubleshoot grid startup issue
http://oracledbazone.wordpress.com/2012/07/17/useful-11gr2-rac-commands/
11gR2 Clusterware and Grid Home - What You Need to Know (Doc ID 1053147.1)


-- check  cluster name
   export GRID_HOME=/ora01/grid/11.2.0.2/grid
   export DB_HOME=/ora01/oracle/product/11.2.0.2/db
 
   $GRID_HOME/bin/cemutlo -n
 
--  Check Clusterware Resources status
   ps -ef |egrep "crsd.bin|ocssd.bin|evmd.bin|oprocd"
   ps -ef|grep d.bin
   ps -ef | egrep 'init|d.bin'
 
   cluvfy comp -list
 
   crsctl check crs
   $GRID_HOME/bin/crsctl stat res -t                 #all
   $GRID_HOME/bin/crsctl stat res -t -init           #only initialize
   $GRID_HOME/bin/crsctl stat res -p                 #long format
   $GRID_HOME/bin/crsctl query css votedisk
   $GRID_HOME/bin/ocrcheck
   $GRID_HOME/bin/oifcfg getif
   $GRID_HOME/bin/crsctl check crs
   crsctl check has
   crsctl query crs activeversion
   crsctl check cluster -all
   crs_stat -t -v


--  To find out config  information
     srvctl config network
     srvctl config nodeapps
     srvctl config asm
     srvctl config listener
     srvctl config scan
     srvctl config scan_listener
     $GRID_HOME/bin/srvctl config nodeapps -a
     $GRID_HOME/bin/srvctl config scan
     $GRID_HOME/bin/srvctl config network
     $GRID_HOME/bin/srvctl config asm -a
     $GRID_HOME/bin/srvctl config listener -l <listener-name> -a
     $DB_HOME/bin/srvctl config database -d <dbname> -a
     $DB_HOME/bin/srvctl config service -d <dbname> -s <service-name> -v

--  To find out non-grid status
     srvctl status nodeapps
     srvctl status asm
     srvctl status listener
     srvctl status scan
     srvctl status scan_listener
crs_stat -t -v
 
-- to start all resource (CRS, ASM , Listener and Databases)
   cd /ora01/grid/11.2.0.2/grid/bin
   ./crsctl start resource -all
   ./crsctl stop has ( will stop on node1 and move vip to node2)
   ./crs_stop -all ( will stop on both nodes)
   ./crsctl stop cluster -n node_name ( will stop asm, crs)
   ./crsctl stop crs ( will stop asm, crs)
 
   srvctl start cvu
   srvctl start oc4j
   srvctl status cvu
   alternate command
   crsctl start resource ora.cvu
   crsctl status resource ora.cvu



 -- start / stop non-rac
   # appsdbaworkshop.blogspot.com

    crsctl 11.2.0.2 to start/stop/check on standalone node

    crsctl config has
    crsctl stop has
    crsctl start has
    crsctl status resource
    crs_stop -all
    crs_start -all
 
   -- start resource manually
   crsctl start resource ora.cvu -n <nodename>
   crsctl start res ora.crsd -init
 
-- check network

  1. Find out Subnet ID from oifcfg from grid

    cd /ora01/grid/11.2.0.2/grid/bin
   
    oifcfg iflist -p -n
    1st col - network adapter name
    2nd col - subnet id
    3rd col - public/private
    4th col - netmask

  2. from root
     # ifconfig -a

  3. Subnet Info in Oracle Clusterware - OCR
     cd /ora01/grid/11.2.0.2/grid/bin
     oifcfg getif

-- check cluster nodes
   olsnodes -n
   olsnodes -c
   olsnodes -i  -s -n

-- OCR
   ocrcheck

-- Check voting disk
   crsctl query css votedisk

- check VIP
   srvctl status nodeapps
   srvctl start nodeapps
   crsctl stat res -t

-- check SCAN
   cluvfy comp scan -verbose
   srvctl config scan
   srvctl status scan

 
   srvctl config scan_listener
   srvctl status scan_listener
   lsnrctl status LISTENER_SCAN1
   lsnrctl service LISTENER_SCAN
   show parameter remote_listener
 
   crsctl stat res -w "TYPE = ora.scan_listener.type"
 
-- check listener
   srvctl status listener

-- check HAIP
   crsctl stat res -init -w "TYPE = ora.haip.type"
   oifcfg iflist -p -n
     will show   "bond1  169.254.0.0  UNKNOWN  255.255.0.0" for HAIP
 
   col host_name format a10
   sqlplus
     SELECT a.host_name, a.instance_name, b.name, b.ip_address
     FROM gv$cluster_interconnects b, gv$instance a
     WHERE a.inst_id=b.inst_id
     ORDER BY 1,2,3;
 
-- collect config
$GRID_HOME/bin/crsctl stat res -t
$GRID_HOME/bin/crsctl stat res -p
$GRID_HOME/bin/crsctl query css votedisk
$GRID_HOME/bin/ocrcheck
$GRID_HOME/bin/oifcfg getif
$GRID_HOME/bin/srvctl config nodeapps -a
$GRID_HOME/bin/srvctl config scan
$GRID_HOME/bin/srvctl config asm -a
$GRID_HOME/bin/srvctl config listener -l <listener-name> -a
$DB_HOME/bin/srvctl config database -d <dbname> -a
$DB_HOME/bin/srvctl config service -d <dbname> -s <service-name> -v

 
-- steps to  stop ( asm, instance, nodeapps, in 11gr2)
   $ srvctl stop instance -d RACDB -n racnode1
   $ srvctl stop vip -n racnode1 -f

--  check if the CRS/OHAS & services are enabled to autostart
   # $GRID_HOME/bin/crsctl config crs
   if not then enable
   # $GRID_HOME/bin/crsctl enable crs

--  shutdown crs services
   # $GRID_HOME/bin/crsctl stop crs
 
-- verify
   $GRID_HOME/bin/crsctl status resource -t

-- Change IP Interconnect address

-- Change VIP


-- get database name
   $ORACLE_HOME/bin/srvctl status home -o $ORACLE_HOME -s /tmp/oracle_home.stat

-- start databases using new command
   $ORACLE_HOME/bin/srvctl start home -o $ORACLE_HOME -s /tmp/oracle_home.stat

-- stop databases
   $ORACLE_HOME/bin/srvctl stop home -o $ORACLE_HOME -s /tmp/oracle_home.stat


  # http://surachartopun.com/2009/10/how-to-create-oracle-service-on-11gr2.html

  lnx20012@mzmd:/ora01/oracle $ cat /opt/oracle/admin/scripts/gridstat
     #!/usr/bin/ksh
     #
     # Check 11G RAC database Up/Down Status script
     #
     # Description:
     #    - Returns formatted version of crs_stat -t, in tabular
     #      format, with the complete rsc names and filtering keywords
     #   - The argument, $RSC_KEY, is optional and if passed to the script, will
     #     limit the output to HA resources whose names match $RSC_KEY.
     # Requirements:
     #   - $ORA_CRS_HOME should be set in your environment
     # Modifications
     #  RLM 5/2010 - use oraenv to set the environment, grid must be in oratab
     #             - check if search argument is null and substitute .* to create a valid syntax for Solaris
     ORACLE_SID=grid;ORAENV_ASK=NO;. oraenv;ORAENV_ASK=YES
     # If search argument is null, substitute .*, meaning match anything
     if [[ -z $1 ]]; then
       RSC_KEY='.*'
     else
       RSC_KEY=$1
     fi
     #QSTAT=-u
     QSTAT=-l
     AWK=/bin/awk
     $ORACLE_HOME/bin/crs_stat $QSTAT | $AWK \
       'BEGIN {printf "%-45s %-10s %-18s\n", "HA Resource", "Target", "State";
               printf "%-45s %-10s %-18s\n", "-----------", "------", "-----";
               FS="="; state = 0 }
       $1~/NAME/ && $2~/'$RSC_KEY'/ { appname=$2; state=1}
       state == 0 {next}
       $1~/TARGET/ && state == 1 {apptarget = $2; state=2}
       $1~/STATE/ && state == 2 {appstate = $2; state=3}
       state == 3 {printf "%-45s %-10s %-18s\n", appname, apptarget, appstate; state=0}'