Wednesday, April 20, 2011

Easy way to start your WebLogic Servers with the NodeManager in the background

When you work with Fusion Middleware you probably know you need to start the WebLogic Servers with the scripts located in the bin folder of your WebLogic domain and you need to start these servers in the background else these processes will be killed when you log out. On unix you can start these scripts in the background and on Windows you can try to make some Windows services with the service utility of WebLogic, but you need to update the path, classpath and java parameters of this service ( in the registry)  so it matches with the startup script. ( easy to make mistakes and memory changes can't be done from the WebLogic Console )

In this blogpost I will show you how you can start a WebLogic server from WLST in combination with a NodeManager which is started in the background of the server.

The first step is starting the Nodemanager once so the nodemanager.properties file is created. After this you can stop the nodemanager by killing the process
Go to XXX\wlserver_10.3\server\bin and start startNodeManager.cmd

Open the nodemanager.properties in a editor ( located in XXX\wlserver_10.3\common\nodemanager )
For FMW you need to change the StopScriptEnabled property to true, do the same for StartScriptEnabled 


On windows there is a utility to make a service for this nodemanager.
Go to XXX\wlserver_10.3\server\bin and start installNodeMgrSvc.cmd


Start the service

To automatically start a WebLogic Server and not prompted for a username / password  you need to create a boot.properties with username and password and put this in every server folder.

Start startWebLogic.cmd , located in the bin folder of your domain and when it is started then you can shut it down. Do the same for all the Managed Servers. start startManagedWebLogic.cmd xxxx, where xxxx is the name of the managed servers.

Go to XXX\domains\soa_domain\servers and create in every server folder a new folder called security
and create a boot.properties file and with the following content
username=weblogic
password=yourpassword

put this file in every security folder.

Next step is to set the nodemanager username and password
Start your WebLogic AdminServer
Go to the WebLogic Console, Domain and then open the Security tab

 Click on the Advanced link and set the nodemanager username and password

Activate the changes and shutdown the AdminServer

Now you try to start the AdminServer with WLST which connects to the NodeManager


Start XXX\wlserver_10.3\common\bin\wlst.cmd
you will see wls:/offline>

Connect to the NodeManager by using nmConnect
nmConnect('weblogic','yourpassword','localhost','5556','your_domain','C:/XXX/user_projects/domains/your_domain','ssl')
You need to see the  following Successfully Connected to Node Manager.

start the AdminServer
nmStart('AdminServer')

Ask the status of the AdminServer
nmServerStatus('AdminServer')

Stop the AdminServer
nmKill('AdminServer')

disconnect from the nodemanager
nmDisconnect()

Now you can make some cmd and WLST scripts

first create a start WLST script, called startDomain.wlst with the following content
nmConnect('weblogic','yourpassword','localhost','5556','wls_domain','C:/XXX/user_projects/domains/wls_domain','ssl')
nmStart('AdminServer')

nmStart('soa_server1')
nmDisconnect()


and a cmd script startDomain.cmd
call XXX\wlserver_10.3\common\bin\wlst.cmd startDomain.wlst


Now you have a script what you can add to windows task schedular or an other utility

7 comments:

  1. 2 points:

    1) setting StartScriptEnabled and StopScriptEnabled to true are not mandatory here. they are supposed to be used to run some scripts before weblogic's started/after weblogic's shut down.

    SOA might need it but it's not required here.

    2)nmEnroll() is required to register the domain before nmConnect() can be called. Dynamic domain registration is not supported.

    ReplyDelete
  2. Hi,

    You are right for plain java weblogic servers, in that case you can also make a windows service with the utility provided by wls
    But nowadays for FMW , everything is put in the start scripts and fmw is big

    NmEnroll is not required , when you create a new domain in the same middleware home as the nodemanager then you only need to restart the nodemanager and the new domain is detected

    Thanks

    ReplyDelete
  3. Hi Edwin,
    nmConnect('weblogic','yourpassword','localhost','5556','wls_domain','C:/XXX/user_projects/domains/wls_domain','ssl')
    Here what is wls_domain ,actually I have soadomain1 under user_projects/domains.I did as it is you mentioned but I skip the above line and I successfully started the AdminServer using nmStart('AdminServer') but I can't able to start the soa_server1 using nmStart('soa_server1') and I got the following error:
    Error Starting server soa_server1: weblogic.nodemanager.NMException: Exception w
    hile starting server 'soa_server1'
    can you give me the solution please.
    Regards,
    Prasad.

    ReplyDelete
  4. Hi,

    I think you got an error while starting, can you check the log files of the soa_server1.

    Probably you didn't create a boot.properties file in the security folder.
    and then its waiting for your input.

    or you didn't set stop and startScriptEnabled on true in the nodemanager.properties and restart the nodemanager.

    thanks

    ReplyDelete
  5. I was searching on google and directed to this blog. I found it very informative. There are some very useful examples. Great work, Keep it up.

    ReplyDelete
  6. Hi,
    good information. but it's not working for me. Could you help please? I tried start managed server osb_server1. got error after nmStart('osb_server1')
    Error Starting server osb_server1: weblogic.nodemanager.NMException: Exception w
    hile starting server 'osb_server1'.
    nodemanager.log is:
    <9/12/2011 12:26:53 PM>
    <9/12/2011 12:26:53 PM>
    <9/12/2011 12:26:53 PM>
    <9/12/2011 12:26:53 PM>
    <9/12/2011 12:26:53 PM>
    <9/12/2011 12:26:53 PM>
    <9/12/2011 12:26:53 PM>
    <9/12/2011 12:26:54 PM>
    <9/12/2011 12:26:54 PM>
    java.io.IOException: Server failed to start up. See server output log for more details.
    at weblogic.nodemanager.server.AbstractServerManager.start(AbstractServerManager.java:200)
    at weblogic.nodemanager.server.ServerManager.start(ServerManager.java:23)
    at weblogic.nodemanager.server.Handler.handleStart(Handler.java:604)
    at weblogic.nodemanager.server.Handler.handleCommand(Handler.java:119)
    at weblogic.nodemanager.server.Handler.run(Handler.java:71)
    at java.lang.Thread.run(Thread.java:662)

    any idea? thanks

    Kevin

    ReplyDelete
  7. Hi,

    Can you check the following.

    Can you start it with startManaged script.
    Set the boot.properties and set the stop and script enabled in the nodemanager.properties.

    First start it once from the weblogic console.
    and maybe enroll the domain again.

    thanks

    ReplyDelete