Saturday, January 23, 2010

Node Manager as a UNIX Startup Process

Configuring WebLogic Server (WLS) as a startup process was a common administrative process in the past. But after Node Manager (NM) was introduced as an agent to start, stop, restart and monitor WebLogic Server it is now recommended that you start WebLogic Server using NM. But NM has to configured as a startup process on the respective OS so that it is always running to manage the respective WLS instances on that machine. NM can either be Java based NM or Script based NM. Script based NM uses OS services like SSH or RSH to execute the NM script. But Java based NM is a Java process that should be started. So setting up NM as a service will ensure that NM is always running. There is a lot of information in the WebLogic Server documentation about setting up NM. But there is very less or no information about setting NM as a service on a non-Windows environment. For Windows environment there are pre-packged scripts that you can use. These scripts exists under WL_HOME/server/bin folder (installNodeMgrSvc.cmd, uninstallNodeMgrSvc.cmd). But for UNIX based environment you should do this manually or with the help of OS specific utilities like chkconfig etc.

For *nix environment NM should be configured as startup process using rc scripts. Creating rc scripts for configuring NM as a service is even simpler than configuring WebLogic Server as a service. This is mainly because NM doesn't have to be shutdown gracefully. All you have to do is write a simple shell script that starts the NM and create the symbolic link to that script from the right run level folder. The following illustrates the steps to confiure NM as service under LINUX environment. It should be very similar on other *nix environments. You need root permission to peform the following steps.


1. Create a shell script (wlsnmd) under /etc/init.d/ folder:


#! /bin/bash
case "$1" in
start)
WL_HOME = /usr/middleware/11.1.0/wlserver_10.3
$WL_HOME/server/bin/startNodeManager.sh
;;

*)
echo "Usage: $0 {start}"
exit 1
esac

exit_status



2. Assuming that we are going to start NM at run level 5, create a sysmbolic link in /etc/rc.d/rc5.d/ folder. Since it a startup script we should start the symbolic link with "S" and followed by a number which decide the order in which services will be called. As we are fine to start NM after all the other application/services are start let us choose 99 which is the highest number.



ln -s /etc/init.d/wlsnmd S99weblogic



If you don't want to do these manually you can also use utilities like chkconfig (included in Red Hat distributions) for managing your startup scripts. For configuring WebLogic Server as a startup process there are pre-packaged scripts (installSvc.cmd, uninstallSvc.cmd). But you have to create rc scripts similarly for WLS as well in UNIX based environments. Here is an example rc script for configuring a WebLogic Server as a startup process. But here we also need to implement the kill/stop to gracefully shutdown the server.



#! /bin/bash

case "$1" in
start|reload)
DOMAIN_HOME = /usr/middleware/domains/med_analysis
$DOMAIN_HOME/bin/startWebLogic.sh
;;
stop)
$DOMAIN_HOME/bin/stopWebLogic.sh
;;
restart|force-reload)
$0 stop
$0 start
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
esac

exit_status

10 comments:

  1. The node manager is one of the finest software to help anyone with the server start up process. I myself have tried it and am pretty satisfied with the outcomes.

    ReplyDelete
  2. RC-Skripts are becoming a thing of the past. Self-healing services like Solaris 10's SMF-Services are the future.
    First we create a XML containing the scripts location and its dependencies (basically we can take the example template which comes with Solaris 10 and edit a few lines since all NM requires is a mounted filesystem, network and multiuser run-level). Lets call it weblogic_nm.xml and place it under /var/svc/manifest/application/management/ .

    The we take your Shellscript (with a little extension since we need to be able to stop this service as well):

    #! /bin/bash

    case "$1" in
    start)
    WL_HOME = /usr/middleware/11.1.0/wlserver_10.3
    $WL_HOME/server/bin/startNodeManager.sh
    ;;
    stop)
    $WL_HOME/server/bin/stopNodeManager.sh
    ;;
    *)
    echo "Usage: $0 {start|stop}"
    exit 1
    esac

    exit_status

    We now place this skript under
    /lib/svc/method/ so it can be imported in our service database.

    Now, lets import it and activate:
    #svccfg import /var/svc/manifest/application/management/weblogic_nm
    #svcadm enable svc:/application/management/weblogic_nm:default

    And voila, we have a self-restarting Nodemanager.

    ReplyDelete
  3. Hey Bala , your blogs are pretty intresting and lotta useful, thanks alot for your info :)

    ReplyDelete
  4. Hi Bala,

    Good job... You are right, is very difficult to find information about how to setup NM as a service on a non-Windows environments.

    What you explain above is exactly what I did in my environment, but I have 2 quick questions:

    1. Weblogic scripts must be executed using the same owner used during the installation. If you call the script from the rcX.d at start up, it will be running as root, right? Is this a problem? I'm using "su - oracle -c <command>" to be sure the scripts will be running with oracle user.

    2. I create 2 links within the rcX.d dir, one for the nodemanager script and other to weblogic script, exactly as you show above, but only the fist one is running at start up. Seems that the other one is not being called. Do you know if exists any dependency between them or an appropriate order to execute them?

    Thanks,
    Rafael

    ReplyDelete
  5. Hi Bala, this is very useful and learning lot form it.

    Thanks for sharing.

    -Gopal

    ReplyDelete
  6. Run level five? I'd say you want all critical services to start at init 3.

    Run level 5 is all about starting xorg and friends for the desktop gui environment.

    ReplyDelete
  7. #! /bin/bash

    case "$1" in
    start|reload)

    DOMAIN_HOME=${DOMAIN_HOME:-"/home/weblogic/bea/user_projects/domains/ENTSERVER"}
    $DOMAIN_HOME/bin/startWebLogic.sh >> wlup.txt
    ;;
    stop)
    DOMAIN_HOME=${DOMAIN_HOME:-"/home/weblogic/bea/user_projects/domains/ENTSERVER"}
    $DOMAIN_HOME/bin/stopWebLogic.sh >> wldown.txt
    ;;
    restart|force-reload)
    $0 stop
    $0 start
    ;;
    *)
    echo "Usage: $0 {start|stop|restart}"
    exit 1
    esac

    ReplyDelete
  8. NodeManager process is started as root. It would be a problem. How can I statup NodeManager using "weblogic" account?

    ReplyDelete
  9. Great information, I really like all your post. I will keep visiting this blog very often. It’s good to visit your website. And also please Read link bvba Woodstone which provide information monitoring software & monitoring tools

    ReplyDelete
  10. Its really a nice post, the content of this blog is really awesome and extraordinary.And also please Read link bvba Woodstone which provide information server monitoring software & server monitoring tools

    ReplyDelete