Pages

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 startNodeManager.sh 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. nodeMgrAutoStartSrv.sh to support start/stop/status/restart operations

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

Node Manager nodeMgrAutoStartSrv.sh 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 
DAEMON_USER="oracle"
PROGRAM="/u01/app/oracle/admin/domain/cluster/scripts/nodeManager/startNodeManager.sh > 
$NodeManagerHome/nodemanager.out 2>&1"

# load wls environment variable by calling setWLSEnv.sh script
source $WL_HOME/server/bin/setWLSEnv.sh > /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 ""
            exit
        fi
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 ""
        else
            /bin/echo "Node Manager process is not running";
   echo ""
        fi
}




# restart function definition 
restart() {
        stop
        sleep 10
        start
}



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

# 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
  start)
        start
        ;;
  stop)
        stop
        ;;
  status)
status
;;
  restart)
        restart
        ;;
 *)
        echo $"Usage: $0 {start|stop|status|restart}"
        exit 1
esac
exit 

Use the ‘chkconfig’ command to automate startup of nodeMgrAutoStartSrv.sh service 


In earlier section we have created nodeMgrAutoStartSrv.sh 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-

Step1: 
Copy nodeMgrAutoStartSrv.sh 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.

Step2:
Change access rights and ownership

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

Step3:
Run the below command to configure auto startup of this script

chkconfig --levels 345 nodeMgrAutoStartSrv.sh on

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

If interested to know more about levels 235 then please refer below link
http://serverfault.com/questions/356984/explanation-of-chkconfig-levels

Or

Step3a:

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

cd /etc/rc3.d
ln -s  ../init.d/nodeMgrAutoStartSrv.sh   S99nodeMgrAutoStartSrv.sh  ;  ln -s  ../init.d/nodeMgrAutoStartSrv.sh   K99nodeMgrAutoStartSrv.sh
cd /etc/rc4.d
ln -s  ../init.d/nodeMgrAutoStartSrv.sh   S99nodeMgrAutoStartSrv.sh   ; ln -s  ../init.d/nodeMgrAutoStartSrv.sh   K99nodeMgrAutoStartSrv.sh
cd /etc/rc5.d
ln -s  ../init.d/nodeMgrAutoStartSrv.sh   S99nodeMgrAutoStartSrv.sh  ;   ln -s  ../init.d/nodeMgrAutoStartSrv.sh   K99nodeMgrAutoStartSrv.sh

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. nodeMgrAutoStartSrv.sh has created two sub process S99nodeMgrAutoStartSrv.sh and K99nodeMgrAutoStartSrv.sh which will be used start and shutting down respectively while server reboot process. 

Step4: 
Reboot the server

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

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


Or



No comments:

Post a Comment