Friday, August 14, 2015

Automation of Node Manager startup script !!!

Node Manager is one of key component of WLS administration. It has to be setup separately while installing OFMW binaries. This helps to centrally manage the WLS Domain servers.  Node Manager helps an administrator to centrally manage all the WLS servers in domain from WLS Admin console. 

Node Manager also help to auto restart particular WLS managed server in case WLS server become crash due to some issues. 

However, all above listed functionality can only works when Node Manager Process is running on particular vServer or physical servers.  

By default, we have to start node manager process manually using shell script. Starting process of node manager can be slightly different from implementation to implementation depending up on how it has been setup. 

Since, starting node manager is manual process, sometime we forgot this and ended-up with problem why WLS admin console is not able to communicate with all Managed servers. 

Often infrastructure guys do Database Patching and OS patching etc. wherein Physical servers or vServers need to restarted and because of this restart node manager process get dies and we need to start it manually again. 

If we are maintaining large number of vServers then startup manually node manager process takes bit longer which can be avoided completely by setting up auto startup mode.  

In below post I will try to explain how we can automate the starting process of node manager. We can write a shell script which will act as node manager service and will be having start/stop/status/restart operations. 

Once node manager service is running we can automate startup of that service using OS command. 
So, there will two steps as state below –


1) Write a node manager service e.g. to support start/stop/status/restart operations

2) Use the ‘chkconfig’ command to automate startup of that service. 

Node Manager Service code

# export environment variable as per your environment e.g. 
export MW_HOME="/u01/app/oracle/product/fmw"
export JAVA_HOME="/u01/app/oracle/product/fmw/jdk"
export WL_HOME="/u01/app/oracle/product/fmw/wlserver_10.3"
export NodeManagerHome="/u01/app/oracle/product/fmw/wlserver_10.3/common/nodemanager"
export PROCESS_STRING="weblogic.NodeManager"

# setup temporary variable 
PROGRAM="/u01/app/oracle/admin/domain/cluster/scripts/nodeManager/ > 
$NodeManagerHome/nodemanager.out 2>&1"

# load wls environment variable by calling script
source $WL_HOME/server/bin/ > /dev/null

# start function definition 
start() {
        OLDPID=`/usr/bin/pgrep -f $PROCESS_STRING`
        if [ ! -z "$OLDPID" ]; then
   echo ""
            echo "Node Manager is already running (pid $OLDPID) !"
   echo ""
echo ""
        echo "Starting Node Manager Process now :"
/bin/su $DAEMON_USER -c "$PROGRAM"

# stop function definition 
stop() {
        echo ""
echo "Checking Node Manager Process running Status";
echo ""
        OLDPID=`/usr/bin/pgrep -f $PROCESS_STRING`
        if [ "$OLDPID" != "" ]; then
            /bin/kill -TERM $OLDPID
   /bin/echo "Node Manager process id $OLDPID has been killed";
   echo ""
            /bin/echo "Node Manager process is not running";
   echo ""

# restart function definition 
restart() {
        sleep 10

#  status function definition 
status() {
OLDPID=`/usr/bin/pgrep -f $PROCESS_STRING`
        if [ "$OLDPID" != "" ]; then
        echo ""    
/bin/echo "Node Manager is running (pid: $OLDPID)"
echo ""
echo ""
            /bin/echo "Node Manager is not running"
echo ""

# Snap when node manager not running

# Snap when node manager is running

# switch case to decide which action has to be performed 
case "$1" in
        echo $"Usage: $0 {start|stop|status|restart}"
        exit 1

Use the ‘chkconfig’ command to automate startup of service 

In earlier section we have created script. Now, next steps to configure this script for auto startup, so in the event of vServers reboot node manager process will always be up and running. 

Execute the below steps to achieve the same-

Copy to this location /etc/init.d 

Note: Most Linux distributions have one thing in common. That being, all the start-up scripts are stored in the /etc/init.d/ directory.

Change access rights and ownership

chmod 755  /etc/init.d/
chown root:root /etc/init.d/

Run the below command to configure auto startup of this script

chkconfig --levels 345 on

Note:  Above command must need to run via root user.

If interested to know more about levels 235 then please refer below link



In some linux chkconfig mostly used for demean program, not for custom shell script. So, the other way to do auto startup of script is to create manual link this script using below command.

cd /etc/rc3.d
ln -s  ../init.d/  ;  ln -s  ../init.d/
cd /etc/rc4.d
ln -s  ../init.d/   ; ln -s  ../init.d/
cd /etc/rc5.d
ln -s  ../init.d/  ;   ln -s  ../init.d/

Even, chkconfig command does the same thing, it create symbolic link inside rc3.d, rc4.d and rc5.d depending up run level specified in chkconfig command. While server start its looks inside these folder and start the process which resides here. There are always two process gets created for one specific process. E.g. has created two sub process and which will be used start and shutting down respectively while server reboot process. 

Reboot the server

After reboot, verify whether node manager process is up and running or not.

ps -ef | /bin/grep -w weblogic.NodeManager


No comments:

Post a Comment