maldito.orco Blogo

Wednesday, August 20, 2008

Script to Shutdown a OAS instance with status info

This pair of scripts (shutdown/startup) of Oracle Application Server (OAS) realize the task together. The shutdown script store the OC4Js status prior shutdown opmn.

The startup script, start opmn and each OC4J stored on shutdown. (plus OHS).

Its really simply, to give us a framework where initial start our work.

enjoy!.


shutdown_OAS.sh
===============
#!/bin/bash
#

if [ "_${1}" = "_" ]; then
echo "Error: el script necesita de un ORACLE_HOME de un OAS como parametro de entrada"
exit 1
fi

OH=$1
ORACLE_HOME=$1
PATH=$OH/bin:$OH/opmn/bin:$OH/dcm/bin:$OH/OPatch:$OH/jdk/bin:$PATH

if [ ! -d $OH ]; then
echo "Error: el ORACLE_HOME=$OH no es un directorio valido"
exit 1
fi

if [ ! -x $OH/opmn/bin/opmnctl ]; then
echo "Error: no se encontro el ejecutable ORACLE_HOME/opmn/bin/opmnctl"
exit 1
fi

##
## seteo instance name
INAME=`opmnctl status | grep "Processes in Instance:" | awk '{print $4}' | awk -F. '{print $1}'`
##
## obtengo lista de oc4js activos
OC4J_ACTIVE_LIST=`grep "process-type" $ORACLE_HOME/opmn/conf/opmn.xml | grep OC4J | grep --invert-match "disabled" | awk '{ print $2 }' | awk -F= '{ print $2 }' | awk -F\" '{ print $2 }'`
##
## vaciar archivo
$INAME.oc4jalive.txt
##
## iterar cada uno de la lista de enableds del opmn.xml viendo si esta Active en el status
for i in $OC4J_ACTIVE_LIST; do
STATUS=`opmnctl status -fmt %prt%sta | grep -e "\(OC4J:\)\?$i " | uniq | awk '{print $3}'`
echo ST=$i[$STATUS]
if [ "$STATUS" = "Alive" ]; then
echo $i >> $INAME.oc4jalive.txt
fi
done
##
## bajo OAS
opmnctl shutdown
##
## si es un R2 y esta el comando emctl bajo aparte la consola
if [ -x $OH/bin/emctl ]; then
emctl stop iasconsole
fi

startup_OAS.sh
==============
#!/bin/bash
#

if [ "_${1}" = "_" ]; then
echo "Error: el script necesita de un ORACLE_HOME de un OAS como parametro de entrada"
exit 1
fi

OH=$1
ORACLE_HOME=$1
PATH=$OH/bin:$OH/opmn/bin:$OH/dcm/bin:$OH/OPatch:$OH/jdk/bin:$PATH

if [ ! -d $OH ]; then
echo "Error: el ORACLE_HOME=$OH no es un directorio valido"
exit 1
fi

if [ ! -x $OH/opmn/bin/opmnctl ]; then
echo "Error: no se encontro el ejecutable ORACLE_HOME/opmn/bin/opmnctl"
exit 1
fi

##
## start opmn process
opmnctl start
##
## seteo instance name
INAME=`opmnctl status | grep "Processes in Instance:" | awk '{print $4}' | awk -F. '{print $1}'`
##
## iterar cada componente levantandolo
for i in `cat $INAME.oc4jalive.txt`; do
opmnctl startproc process-type=$i
done
##
## carga del OHS
opmnctl startproc process-type=HTTP_Server
##
## carga del dcm-daemon (solo para R2, en R3 da error)
opmnctl startproc ias-component=dcm-daemon
##
## si es un R2 y esta el comando emctl bajo aparte la consola
if [ -x $OH/bin/emctl ]; then
emctl start iasconsole
fi









Labels: , , , ,

2 Comments:

  • People should read this.

    By Anonymous Anonymous, at 12:32 AM  

  • Thx Maxine for your comment. Sorry for Spanish code comments, this is because this script was writed to very Junior operation people without english skills. If you want I can fix that.

    By Blogger Maldito Orco, at 4:21 AM  

Post a Comment

<< Home