==> This Method is very Useful in below Scenarios
When Physical/Virtual Linux Servers Crashed and You Brought Up Linux Server at the Same Time WebLogic Servers Also Started Without Manual Intervention.
During Maintenance of Linux Servers, If Your Restarting Linux Server in that case also WebLogic Application Servers will be Started Automatically by Using this Method.
If WebLogic Server Crashed Due to OOM(OutOfMemory) OR Due to any JVM BUG in that case also JVM will be restarted automatically.
Summary:
========
1) Create nodemanager Script
2) Save the Script Inside Directory /etc/init.d
3) Issue the Command chkconfig for Script nodemanager
4) Change Properties Values in nodemanager.properties File
5) Start the NodeManager, AdminServer & Managed Server Through NodeManager
6) For Testing Purpose Restart the Linux Server & Check WebLogic Application Server Status.
STEPS:-
=======
Step-1) Create nodemanager Script
Create nodemanager file with below content & Change highlighted things as per your environment standards .
#!/bin/sh
# chkconfig: 345 85 15
# description: Oracle Weblogic NodeManager service
. /etc/rc.d/init.d/functions
export export DOMAIN_HOME="/oracle/Middleware/user_projects/domains/base_domain"
export JAVA_HOME="/oracle/java/jdk1.8.0_112/bin/java"
export WL_HOME="/oracle/Middleware/Oracle_Home/wlserver"
DAEMON_USER="wlsuser"
PROCESS_STRING="^.*/oracle/Middleware/Oracle_Home/.*weblogic.NodeManager.*"
source $WL_HOME/server/bin/setWLSEnv.sh > /dev/null
export NodeManagerHome="$DOMAIN_HOME/nodemanager"
NodeManagerLockFile="$NodeManagerHome/nodemanager.log.lck"
PROGRAM="$DOMAIN_HOME/bin/startNodeManager.sh > $NodeManagerHome/nodemanager.out 2>&1"
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
Step-2) Save the Script Inside Directory /etc/init.d
mv nodemanager /etc/init.d/
Step-3) Issue the Command chkconfig for Script nodemanager
chkconfig --add nodemanager
Note:-
Default-Start: 3,4,5=on
Default-Stop: 0,1,2,6=off
Step-4) Change Properties Values in nodemanager.properties File
a) Navigate to NodeManager Home
cd /oracle/Middleware/user_projects/domains/base_domain/nodemanager
b) Open the file nodemanager.properties using the vi editor
c) Change the value of below parameters like below & Save and Exit
NativeVersionEnabled=true
CrashRecoveryEnabled=true
weblogic.StartScriptEnabled=true
Step-5) Start the NodeManager, AdminServer & Managed Server Through NodeManager
a) Starting NodeManager
nohup ./startNodeManager.sh &
b) Start AdminServer through NodeManager using WLST.
. ./setDomainEnv.sh
java weblogic.WLST
nmConnect('weblogic','welcome1','test.abs.com','5556','base_domain','/oracle/Middleware/user_projects/domains/base_domain','plain')
nmStart('AdminServer')
c) Start Managed Server using WebLogic Admin Console OR WLST.
Step-6) For Testing Purpose Restart the Linux Server & Check WebLogic Application Server Status.
With root user issue the below command for restarting linux server.
init 6
Post restart access the admin console & check weblogic servers status.
excellent document
ReplyDeletewell explained, thanks
ReplyDeletecan you provide a script to restart managed server when its health state changed
ReplyDelete