CAA Script

From: Vimal Upreti (Vimal@ohitelecom.com)
Date: Sun May 19 2002 - 10:37:56 EDT


Dear all,
 
I have installed Oracle 9i (without RAC) in two Node Cluster(Alphaserver 8200) with TruCluster5.1A.
Oracle 9i is installed in Cluster_usr#oracle partition. We have here 23 Databases, 22 Databases has to run in One Node and 1 in other Node.
As per Sample Template and Best Practice on Compaq Web Site, I could customize my CAA Script (attached below).
Now with this Script I can START all 22 Databases automatically but the script goes into a loop and doesn't come out, which in turn shows this service on UNKNOWN host & doesn't show UP STATUS.
While the STOP Script works OK.
Can somebody identify the error in this script or suggest some alternative:

Thanks & regards.
Vimal Upreti
***********************************************************************************************
#!/usr/bin/ksh -p
# oramamg.scr
#
# *****************************************************************
# * *
# * Copyright (c) Digital Equipment Corporation, 1991, 1999 *
# * *
# * All Rights Reserved. Unpublished rights reserved under *
# * the copyright laws of the United States. *
# * *
# * The software contained on this media is proprietary to *
# * and embodies the confidential technology of Digital *
# * Equipment Corporation. Possession, use, duplication or *
# * dissemination of the software and media is authorized only *
# * pursuant to a valid written license from Digital Equipment *
# * Corporation. *
# * *
# * RESTRICTED RIGHTS LEGEND Use, duplication, or disclosure *
# * by the U.S. Government is subject to restrictions as set *
# * forth in Subparagraph (c)(1)(ii) of DFARS 252.227-7013, *
# * or in FAR 52.227-19, as applicable. *
# * *
# * *
# *****************************************************************
#
# @(#)$RCSfile: template.scr,v $ $Revision: 1.1.8.2 $ (DEC) $Date:
# 2000/04/14 17:42:58 $
#
#
# TruCluster V5 sample CAA script for ORACLE
#
#
###################################################################
#
# The following section contains variables that can be set to best
# suit your application.
#
# Please review each variable and set as needed.
#
# Set CAA_SCRIPT_DEBUG when invoking the script from command line
# for testing. This will cause all output events to go to the terminal,
# rather than being sent to EVM.
#
###################################################################
#
# Application name - set this variable to a name that describes this
# (mandatory) application. Enclose the name in double quotes.
# Examples: "apache", "netscape"
SERVICE_NAME="ORAMAMG"
# Associated Processes - the application configured may consist of
# (mandatory single or multiple processes. Specifying the names
# of the processes here allows CAA to monitor that they
# are running and allows CAA to completely clean up when
# stopping the application.
# Ex: "proc1 proc2"
#
#
ORATAB=/etc/oratab9i
PROBE_PROCS=""
export PROBE_PROCS
cat $ORATAB | while read LINE
do
    case $LINE in
        \#*) ;; #comment-line in oratab
        *)
# Proceed only if third field is 'Y'.
        if [ "`echo $LINE | awk -F: '{print $3}' -`" = "Y" ] ; then
            ORACLE_SID=`echo $LINE | awk -F: '{print $1}' -`
            if [ "$ORACLE_SID" = '*' ] ; then
                ORACLE_SID=""
            fi
            export ORACLE_SID
           PROBE_PROCS="
                         $PROBE_PROCS \
                         ora_pmon_${ORACLE_SID} \
                         ora_dbw0_${ORACLE_SID} \
                         ora_lgwr_${ORACLE_SID} \
                         ora_reco_${ORACLE_SID} \
                         ora_ckpt_${ORACLE_SID} \
                         ora_smon_${ORACLE_SID} \
                      "
           export PROBE_PROCS
           fi
           ;;
     esac
export PROBE_PROCS
done
# Following 8 lines are commented ...by OHI
#PROBE_PROCS="\
#ora_pmon_${ORA_INST} \
#ora_dbw0_${ORA_INST} \
#ora_lgwr_${ORA_INST} \
#ora_ckpt_${ORA_INST} \
#ora_smon_${ORA_INST} \
#ora_reco_${ORA_INST}\
#"
#
# Application Startup Command - CAA will invoke this command when starting
# (mandatory) the application. Include the command to execute along
# with any flags and arguments needed. Use this
# variable along with START_APPCMD2 (see below) when
# dealing with a simple application start procedure.
#
# If the start procedure is complicated and/or involves
# many commands, you may find it easier to disregard
# this variable and manually code the commands needed
# in the "Start" section of this script (see below).
#
# Another alternative for a complicated start procedure
# is to create a separate script containing those
# commands and specifying that script in this variable.
#
# Ex: "/cludemo/avs/avsetup -s"
#
# NOTE: if not set, you must manually code the commands
# to start the application in the "Start" section of
# this script.
START_APPCMD="su - oracle9i -c /oracle/app/oracle9i/product/o9i/bin/dbstartohi"
#
# Secondary Application Startup Command - used in conjunction with the
# (optional) Application Startup Command just described above. Use
# if desired to implement a two-step startup process for
# your application, if needed.
#START_APPCMD2="su - oadb -c 'date'"
# Application Stop Command - CAA will invoke this command when stopping
# (optional) the application. Include the command to execute along
# with any flags and arguments needed. Use this
# variable along with STOP_APPCMD2 (see below) when
# dealing with a simple application stop procedure.
#
# If the stop procedure is complicated and/or involves
# many commands, you may find it easier to disregard
# this variable and manually code the commands needed
# in the "Stop" section of this script (see below).
# Another alternative for a complicated stop procedure
# is to create a separate script containing those
# commands and specifying that script in this variable.
#
# Ex: "/cludemo/avs/avsetup -k"
#
# NOTE: if not set, you should manually code the commands
# to stop the application in the "Stop" section of
# this script. Otherwise, this script will not stop the
# application in a graceful manner.
STOP_APPCMD="su - oracle9i -c /oracle/app/oracle9i/product/o9i/bin/dbshutimohi"
# Secondary Application Stop Command - used in conjunction with the
# (optional) Application Stop Command just described above. Use
# if desired to implement a two-step stop process for
# your application, if needed.
#STOP_APPCMD2="su - oadb -c date"
# Application Directory - If set, this script will change to this directory
# (optional) prior to executing the start process. This may allow
# you to not have to specify full path names for
# commands or files in this directory.
#
# Ex: "/var/opt/product1"

export SERVICE_NAME START_APPCMD
#export APPDIR PROBE_PROCS STOP_APPCMD
export STOP_APPCMD
################################################################
#
# The following section contains variables used by CAA. We recommend
# leaving them defined as is.
#
################################################################
DEBUG_PRIORITY=100
INFO_PRIORITY=200
ERROR_PRIORITY=500
SCRIPT=$0
ACTION=$1 # Action (start, stop or check)
EVMPOST="/usr/bin/evmpost" # EVM command to post events
DEBUG=0
if [ "$CAA_SCRIPT_DEBUG" != "" ]; then
DEBUG=1
EVMPOST="/usr/bin/evmpost -r | /usr/bin/evmshow -d"
fi
export EVMPOST ACTION SCRIPT
##################################################################
#
# The following section contains procedures that are available to
# be used from the start, stop, and check portions of this script.
#
##################################################################
#
# postevent - Posts EVM event with specified parameters
#
# Argument: $1 - priority (optional)
# $2 - message (optional)
#
#
postevent () {
typeset pri=$1
typeset msg=${2:-failed}
typeset evt='event { name sys.unix.clu.caa.action_script '
if [ ! -z "$pri" ]; then
evt="$evt priority $pri "
fi
evt="$evt var {name name value \\\"$SERVICE_NAME\\\" } "
evt="$evt var {name script value \\\"$SCRIPT\\\" } "
evt="$evt var {name action value \\\"$ACTION\\\" } "
evt="$evt var {name message value \\\"$msg\\\" }"
evt="$evt }"
evt="echo $evt | $EVMPOST"
eval $evt
}
#
# getpid - list PIDs of all processes with supplied name
#
# Modified /sbin/init.d/bin/getpid to list all matches
#
# Arguments: process name
#
getpid () {
if [ -n "$1" ]; then
GETMYPID=$1
shift
/bin/ps -e -o pid,command $* | while read mypid command args
do
if [ "$command" = "$GETMYPID" ]; then
echo "$mypid"
fi
done
fi
}
#
# checkdaemon - return the number of instances of a daemon
#
# Argument: process name
# Return: number of instances of the named daemon currently running
#
checkdaemon () {
R=`getpid $1 | wc -l`
return $R
}
#
# zapdaemon - kill a given process using brutal force (i.e. -9)
#
# Argument: list of processes to kill
# Return: 1 - failed to kill some process
# 0 - killed all processes
#
zapdaemon () {
typeset ret=0
for i in ${1}
do
checkdaemon ${i}
if [ $? -ne 0 ]; then
kill `getpid ${i}`
checkdaemon ${i}
if [ $? -ne 0 ]; then
kill -9 `getpid ${i}`
checkdaemon ${i}
if [ $? -ne 0 ]; then
postevent $ERROR_PRIORITY "${i}: stuck - could not kill -KILL"
ret=1
else
postevent $ERROR_PRIORITY "${i}: killed with -KILL"
fi
else
postevent "" "${i}: killed"
fi
fi
done
return $ret
}
#
# probeapp - Probe process to see if in process list.
#
# This simple form of process probing searches the process list for an
# entry corresponding to the specified process. If found, all is assumed
# to be well.
#
# More accurate process probing may be available depending upon the nature
# of your application. For instance, you might invoke a test command that
# the process should respond to and check the returned results. You should
# consider adding this type of probing to this script, if possible.
#
# Argument: process name
#
# Return: 1 - process not running
# 0 - process running
#
probeapp () {
checkdaemon $1
if [ $? -ne 0 ]; then
postevent $DEBUG_PRIORITY "$1 check OK"
return 0
else
postevent $DEBUG_PRIORITY "$1 check failed"
return 1
fi
}
########################################################################
#
# Main section of Action Script - starts, stops, or checks an application
#
# This script is invoked by CAA when managing the application associated
# with this script.
#
# Argument: $1 - start | stop | check
#
# Returns: 0 - successful start, stop, or check
# 1 - error
#
########################################################################
#
# Start section - start the process and report results
#
# If the Application Startup Commands (see description above) were used,
# little, if any modifications are needed in this section. If not used,
# you may replace most of the contents in this section with your own
# start procedure code.
#
# For improved serviceability, preserve the commands below that log
# messages or posts events.
#
case $1 in
'start')
postevent $DEBUG_PRIORITY "trying to start"
# /usr/sbin/cluamgr -a alias=mamit,rpri=10,selp=10,selw=1,join,virtual=f
#
if [ "$START_APPCMD" != "" ]; then
out=`$START_APPCMD`
status=$?
if [ $status -ne 0 ]; then
postevent $ERROR_PRIORITY "start($status): $out"
exit 1
fi
fi
/usr/sbin/cluamgr -a alias=mamit,rpri=10,selp=10,selw=1,join,virtual=f
# if [ "$START_APPCMD2" != "" ]; then
# out=`$START_APPCMD2`
# status=$?
# if [ $status -ne 0 ]; then
# postevent $ERROR_PRIORITY "start 2($status): $out"
# exit 1
#fi
#fi
;;
#
# Stop section - stop the process and report results
#
# If the Application Stop Commands or Associated Processes (see descriptions
# above) were used, little, if any modifications are needed in this section.
# If not used, you may replace most of the contents in this section with
# your own stop procedure code.
#
# For improved serviceability, preserve the commands below that log
# messages or posts events.
#
'stop')
postevent $DEBUG_PRIORITY "trying to stop"
#
# Not using $APPDIR OHI ....
#cd $APPDIR
if [ "$STOP_APPCMD" != "" ]; then
out=`$STOP_APPCMD`
status=$?
if [ $status -ne 0 ]; then
postevent $ERROR_PRIORITY "stop($status): $out"
exit 1
fi
fi
/usr/sbin/cluamgr -a alias=mamit,rpri=1,selp=1,selw=1,join,virtual=f
# if [ $STOP_APPCMD2 != "" ]; then
# out=`$STOP_APPCMD2`
# status=$?
# if [ $status -ne 0 ]; then
# postevent $ERROR_PRIORITY "stop 2($status): $out"
# exit 1
#fi
#fi
#
# Kill stubborn processes and applications that don't have a stop command
#
for i in ${PROBE_PROCS}; do
zapdaemon ${i}
done
;;
#
# Check section - check the process and report results
#
# If you specified $PROBE_PROCS (see earlier description), very little,
# if any, changes are needed to have simple process checking.
#
# Your application might allow you to implement more accurate process
# checking. If so, you may choose to implement that code here. See the
# description for the probeapp function earlier in this script.
#
'check')
for i in ${PROBE_PROCS}; do
postevent $DEBUG_PRIORITY "trying to check $i"
probeapp $i
if [ $? -ne 0 ]; then
postevent "" "check failed for $i"
exit 1
fi
done
;;
*)
postevent $ERROR_PRIORITY "usage: $0 {start|stop|check}"
exit 1
;;
esac
postevent "" success
exit 0

 



This archive was generated by hypermail 2.1.7 : Sat Apr 12 2008 - 10:48:42 EDT