Any Middleware admin can make their life easy with WLST, to play with Server Life Cycle we can use NodeManager WLST commands. WLST provides us
- start the NodeManager
- connect to the NodeManager, then we can use them to start or stop the WebLogic servers on the machine.
Start Node ManagerUsually, as part of configuring Node Manager, you create a Windows service or a daemon that automatically starts Node Manager when the host computer starts.
If Node Manager is not already running, you can logon to the host computer and use WLST to start it as shown:
c:\>java weblogic.WLST wls:/offline> startNodeManager()
nmConnect('weblogic', 'secret', 'localhost', '5556', 'mydomain','c:/bea/user_projects/domains/mydomain','ssl') Connecting to Node Manager ... Successfully connected.
BEA-090403 :Authentication for user deniedIf you are not configured the NodeManager running WebLogic domain then, You never know what is the nodemanager user, password for that domain. By default the WebLogic admin Console must works. One of my experiance that there could be multiple users access the WebLogic admin role in such situations we need to check the initial domain configuration made up with the user credential that will help you to start the Node Manager. If it doesn't works for you then update the Node Manager username and password in the WebLogic Console and then connect.
nmDisconnect() command will do, disconnect WLST from a Node Manager session.
nm() command - You may execute many WLST commands in between nmStart and nmDisconnect then, you wonder that is it connected to NodeManager or not. To check this at WLST Shell prompt we have nm command
wls:/offline> nm() Not connected to Node Manager
nmStart - Starts a server in the current domain using Node Manager, Conditionas applyed !! Java Node Managed will work here the Node Manager running on the different machine cannot execute this command.
wls:/nm/mydomain>nmStart('AdminServer') starting server AdminServer ... Server AdminServer started successfully
nmKill command - will kills the specified WebLogic server instance that was started with the Node Manager only.
wls:/nm/mydomain>nmKill('AdminServer') Killing server AdminServer Server AdminServer killed successfully
Best Practices with Nodemanager
- Use the nodemanager to start the admin server
- connect to the admin server
- start the managed servers with regular WLST lifecycle commands
- Don't kill the managed server with UNIX kill command when it is started with a Node Manager or with WLST nmStart command
WLST Life cycle commands will enables you to start all managed servers in the domain with single connection to the admin server, regardless of which machines host these Managed Servers.
My online buddy asked me to publish a WLST script for Node maneger that bounces WebLogic server. Its really wonderful thought having this idea with WLST.
Have it your way
This script you can customized as per your environment.
Here you need to do the following which are instructed by buddy because I don't have NodeManager environment test this script. But strongly confident that this will work for you,
* please change the AdminServer's Listen address, Listen port in connection module.
#=========================================== # This module will starts the NodeManager # Author: Sumanth Krishna #======================================== def startnm(): try: progress=startNodemanger() progress.printStatus() except: print 'FAILED TO START NODE MANAGER' print dumpStack() # The module NodeManager connects to the AdminServer def connectnm(): try: progress=nmConnect(user,passwd,WLHOST,NMPORT,domainname,domainpath,plain) progress.printStatus() except: print 'FAILED TO CONNECT NODE MANAGER' print dumpStack() # This module is for starting the AdminServer pass AdminServer name def startAdminServer(svrName): try: nmStart(svrName) except: print "Problem starting the Admin server "+svrName # This module for starting the managed server def startManagedServers(): try: mbeans = home.getMBeansByType("ServerLifeCycleRuntime") for i in mbeans: svrName = i.getName() if svrName != serverName: if i.getState() != "RUNNING": nmStart(svrName) except: print "Problem starting the managed server "+svrName #Main functaion i.e., all functions used to call from here if __name__== "main": startnm() connectnm() startAdminServer() startManagedServers() print 'DONE'
Review this script and write back comments and suggestions to me your trial outputs and issues... whatever you have with this
Good Reference Links:
1. James Bayer blog