RAC_patch_instance_stop_start


#!/bin/ksh
#
# Script:    RAC_patch_shutdown_startup.ksh
# Purpose:   just a much easier mechanism for shutting down RAC
#            instances when doing a rolling patch
# Usage:     none really, just call from the command line… you’ll need
#            to change the CASE statement for your environment… then
#            the script will loop through the instances and shutdown then
#            startup, one node at a time and only when you give it the
#            green light to do so….
#            You’ll also need to change the NUM test “< 5” to fit the
#            number of nodes you have in your RAC installation.
# Created:   CWMack, 6 Nov 2012
# Modified:
#
#######################################################################
#
SD=/s01/shared_scripts
#
#
echo “”
echo “”
echo “1) FS”
echo “3) HC”
echo “5) CS”
echo “”
print -n “Select the home to patch (1, 3, or 5): “
#
read answer
case “$answer” in
1)   echo “FS it is…”
     echo “”
     DB1=”FT”
     ;;
3)   echo “HC it is…”
     echo “”
     DB1=”HT”
     ;;
5)   echo “CS it is…”
     echo “”
     DB1=”CT”
     ;;
*)   echo “Please select 1, 3, or 5”
     echo “”
     ;;
esac
#
DB=`ps -ef | grep “ora_smon” | egrep -v grep | grep $DB1 | awk -F_ ‘{print $3}’ | sed -e ‘s/90./90/’ | tr ‘[a-z]’ ‘[A-Z]’`
#
integer NUM SEQ_TMP
NUM=1
IN_SHUT=/tmp/inst_shut
IN_START=/tmp/inst_start
#
rm ${IN_SHUT}* ${IN_START}*
#
while (( NUM < 5 ))
do
   for i in `echo $DB`
   do
      INST_MAIN=`echo $i${NUM}`
      echo “srvctl stop instance -d $i -i $INST_MAIN” >> $IN_SHUT${NUM}.tmp
      echo “srvctl start instance -d $i -i $INST_MAIN” >> $IN_START${NUM}.tmp
   done
   (( NUM=NUM + 1 ))
done
#
#
SEQ_TMP=1
NUM=1
#
while (( SEQ_TMP < 5 ))
do
   print -n “Ready to shutdown the instance on node [${SEQ_TMP}]?: “
   read answer
   if [[ $answer == [yY] ]]
   then
      echo “”
      echo “running the following…”
      cat $IN_SHUT${NUM}.tmp
      #$IN_SHUT${NUM}.tmp
   else
      echo “”
      echo “Let me know when you’re ready to dance….”
      echo “”
      exit
   fi
   echo “”
   echo “”
   print -n “Ready to restart the instance on node [${SEQ_TMP}]?: “
   read answer
   if [[ $answer == [yY] ]]
   then
      echo “”
      echo “running the following…”
      cat $IN_START${NUM}.tmp
      #$IN_START${NUM}.tmp
   else
      echo “”
      echo “Let me know when you’re ready to dance….”
      echo “”
      exit
   fi
   echo “”
   echo “”
   (( SEQ_TMP=SEQ_TMP + 1 ))
done
#
echo “All done…..”
echo “”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s