Sometimes servers need to reboot and then it’s nice to have certain services to start automatically. Oracle Weblogic’s Node Manager is one of them and in order to have Node Manager start automatically it must be configured as a daemon. Unfortunately Oracle doesn’t provide init scripts to run it as a Linux service but it’s pretty simple to create your own startup scripts. Just create a new nodemgr script under /etc/init.d/, add it as a service and you’re done, as Oracle Fusion Middleware -blog writes.
For example on Red Hat Enterprise Linux Server 5.6 with Oracle Weblogic Server 10.3.5 the /etc/init.d/nodemgr looks like this (edit the script to reflect your Weblogic installation path):
#!/bin/sh
#
# nodemgr Oracle Weblogic NodeManager service
#
# chkconfig: 345 85 15
# description: Oracle Weblogic NodeManager service
### BEGIN INIT INFO
# Provides: nodemgr
# Required-Start: $network $local_fs
# Required-Stop:
# Should-Start:
# Should-Stop:
# Default-Start: 3 4 5
# Default-Stop: 0 1 2 6
# Short-Description: Oracle Weblogic NodeManager service.
# Description: Starts and stops Oracle Weblogic NodeManager.
### END INIT INFO
. /etc/rc.d/init.d/functions
# Your WLS home directory (where wlserver_10.3 is)
export MW_HOME="/oracle/product/mw11g"
export JAVA_HOME="/oracle/java/jdk1.6.0_29"
DAEMON_USER="oracle"
PROCESS_STRING="^.*/oracle/product/mw11g/.*weblogic.NodeManager.*"
source $MW_HOME/wlserver_10.3/server/bin/setWLSEnv.sh > /dev/null
export NodeManagerHome="$WL_HOME/common/nodemanager"
NodeManagerLockFile="$NodeManagerHome/nodemanager.log.lck"
PROGRAM="$MW_HOME/wlserver_10.3/server/bin/startNodeManager.sh"
SERVICE_NAME=`/bin/basename $0`
LOCKFILE="/var/lock/subsys/$SERVICE_NAME"
RETVAL=0
start() {
OLDPID=`/usr/bin/pgrep -f $PROCESS_STRING`
if [ ! -z "$OLDPID" ]; then
echo "$SERVICE_NAME is already running (pid $OLDPID) !"
exit
fi
echo -n $"Starting $SERVICE_NAME: "
/bin/su $DAEMON_USER -c "$PROGRAM &"
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch $LOCKFILE
}
stop() {
echo -n $"Stopping $SERVICE_NAME: "
OLDPID=`/usr/bin/pgrep -f $PROCESS_STRING`
if [ "$OLDPID" != "" ]; then
/bin/kill -TERM $OLDPID
else
/bin/echo "$SERVICE_NAME is stopped"
fi
echo
/bin/rm -f $NodeManagerLockFile
[ $RETVAL -eq 0 ] && rm -f $LOCKFILE
}
restart() {
stop
sleep 10
start
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart|force-reload|reload)
restart
;;
condrestart|try-restart)
[ -f $LOCKFILE ] && restart
;;
status)
OLDPID=`/usr/bin/pgrep -f $PROCESS_STRING`
if [ "$OLDPID" != "" ]; then
/bin/echo "$SERVICE_NAME is running (pid: $OLDPID)"
else
/bin/echo "$SERVICE_NAME is stopped"
fi
RETVAL=$?
;;
*)
echo $"Usage: $0 {start|stop|status|restart|reload|force-reload|condrestart}"
exit 1
esac
exit $RETVAL
Add the Node Manager to start after server reboot:
# chmod +x /etc/init.d/nodemgr # chkconfig --add nodemgr # chkconfig --list nodemgr 0:off 1:off 2:off 3:on 4:on 5:on 6:off
Also now the Node Manager can be controlled via the service command (e.g. service nodemgr restart).
When you have the Node Manager restarting automatically after a system reboot, you can also have Weblogic managed servers automatically restarted by Node Manager. Managed servers will be restarted only if they were running at the time the shutdown was issued. Just activate the Auto Restart option in the Administration Console (Environment > Servers > selected server > Health Monitoring) and you might also need to set the CrashRecoveryEnabled to “true” in $WL_HOME/wlserver_10.3/common/nodemanager/nodemanager.properties.
With little scripting and configuration your sysadmin tasks have now become a little easier.
Leave a Reply