Monday, November 02, 2009

SOA 11g; start and stop

Ever wondered why there are no start and stop scripts for your complete domain? So do I :-). There are scripts to stop a single admin server or a managed server, but there is no start and stop all your servers during shut-down or a reboot. You have to create your own. Here are my scripts.

They are straight forward, and split into 3 parts:
  1. Stop WLS servers
  2. Start WLS servers
  3. A script used during boot/shutdown
The start script
This script will start the admin server and the two managed servers; soa_server1 and bam_server1
#!/bin/bash

O=$WLS_HOME/domains/soadomain

echo Starting Admin Server
nohup $O/bin/startWebLogic.sh &

echo sleep 60
sleep 60

echo Starting SOA Server
nohup $O/bin/startManagedWebLogic.sh soa_server1 &

echo sleep 120
sleep 120

echo Starting BAM Server
nohup $O/bin/startManagedWebLogic.sh bam_server1 &

The stop script
This script will stop the servers in the descending order.
#!/bin/bash
O=$WLS_HOME/domains/soadomain

echo Stopping SOA Server
$O/bin/stopManagedWebLogic.sh soa_server1

echo Stopping BAM Server
$O/bin/stopManagedWebLogic.sh bam_server1

echo Stopping the Admin Server
$O/bin/stopWebLogic.sh

The oracle-wls script
This script is used within Linux/Unix environment during start-up or shutdown. You should copy this into /etc/init.d directory.

Then make symbolic links for each Unix run-level to start or to top the WLS environment.

These symbolic links will start the WLS environment.

ln -s /etc/init.d/oracle-wls /etc/rc2.d/S99oracle-wls
ln -s /etc/init.d/oracle-wls /etc/rc3.d/S99oracle-wls
ln -s /etc/init.d/oracle-wls /etc/rc4.d/S99oracle-wls
ln -s /etc/init.d/oracle-wls /etc/rc5.d/S99oracle-wls

These symbolic links will stop the WLS environment.

ln -s /etc/init.d/oracle-wls /etc/rc0.d/K10oracle-wls
ln -s /etc/init.d/oracle-wls /etc/rc1.d/K10oracle-wls

#!/bin/bash
#

# Source fuction library
if [ -f /lib/lsb/init-functions ]
then
. /lib/lsb/init-functions
elif [ -f /etc/init.d/functions ]
then
. /etc/init.d/functions
fi

# Set path if path not set (if called from /etc/rc)
case $PATH in
"") PATH=/bin:/usr/bin:/sbin:/etc
export PATH ;;
esac

RETVAL=0
ORACLE_START_SCRIPT=/home/oracle/bin/startSOA.sh
ORACLE_STOP_SCRIPT=/home/oracle/bin/stopSOA.sh
SU=/bin/su

if [ $(id -u) != "0" ]
then
echo "You must be root to run the configure script. Login as root and then run the
configure script."
exit 1
fi

start() {
echo "Starting Oracle WLS Instance."
$SU -s /bin/bash $ORACLE_OWNER -c "$ORACLE_START_SCRIPT" > /dev/null 2>&1
RETVAL=$?
if [ $RETVAL -eq 0 ]
then
echo
else
echo Failed to start Oracle WLS Instance.
RETVAL=1
fi
return $RETVAL
}

stop() {
echo Shutting down Oracle WLS Instance.
$SU -s /bin/bash $ORACLE_OWNER -c "$ORACLE_STOP_SCRIPT" > /dev/null 2>&1
RETVAL=$?
echo
if [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$LSNR
then
return $RETVAL
fi
}

# See how we were called
case "$1" in
start)
start
;;
stop)
stop
;;
restart|reload|force-reload)
stop
start
RETVAL=$?
;;
*)
echo $"Usage: $0 {start|stop|restart}"
exit 1
esac

Post a Comment