Wednesday, October 13, 2010

WLST -I : Weblogic Useful WLST Commands

WLST ( Weblogic Scripting Tool )


How to invoke WLST 


Go to your_domain/bin and run below command


D:\Oracle\Middleware\user_projects\domains\base_domain\bin>java weblogic.WLST

What if you are getting below error just after invoking WLST

Exception in thread "main" java.lang.NoClassDefFoundError: weblogic/WLST
Caused by: java.lang.ClassNotFoundException: weblogic.WLST

Run D:\Oracle\Middleware\user_projects\domains\base_domain\bin>setDomainEnv.cmd


Now you would able to connect with java weblogic.WLST command

Commands -


Node Manager Commands for WLST Configuration


Command Enables you to… Use with WLST...
nm Determine whether WLST is connected to Node Manager. Online
nmConnect Connect WLST to Node Manager to establish a session. Online or Offline
nmDisconnect Disconnect WLST from a Node Manager session. Online or Offline
nmEnroll Enables the Node Manager on the current computer to manage servers in a specified WebLogic domain. Online
nmGenBootStartupProps Generates the Node Manager property files, boot.properties and startup.properties, for the specified server. Online
nmKill Kill the specified server instance that was started with Node Manager. Online or Offline
nmLog Return the Node Manager log. Online or Offline
nmServerLog Return the server output log of the server that was started with Node Manager. Online or Offline
nmServerStatus Return the status of the server that was started with Node Manager. Online or Offline
nmStart Start a server in the current WebLogic domain using Node Manager. Online or Offline
nmVersion Return the Node Manager version. Online or Offline
startNodeManager Starts Node Manager on the same computer that is running WLST. Online or Offline
stopNodeManager Stops Node Manager. Online or Offline

wls:/offline>

Take help on online or offline commands 

help("online")
help("offline")


See my post "WLST Online and Offline Commands" for details on online & offline commands

Start Node Manager

startNodeManager(verbose="true",NodeManagerHome="D:/Oracle/Middleware/wlserver_10.3/common/nodemanager",ListenPort="5557",ListenAddress="localhost")
where -
Node Manager Home - D:/Oracle/Middleware/wlserver_10.3/common/nodemanager
Node Manager Host host - localhost
Node Manager port - 5557

Connect with node manager

nmConnect("weblogic","webl0gic","localhost","5557","base_domain","D:/Oracle/Middleware/user_projects/domains/base_domain","plain")


To check if you already connect with node manager or not

nm()

Output

wls:/JJTU_Domain1/serverConfig> nm()
Currently connected to Node Manager to monitor the domain JJTU_Domain1.

Start Admin server using node manager

nmStart("AdminServer")
where "AdminServer" is the name of your admin server.

Check Admin Server Status unsing nodemanager

nmServerStatus('AdminServer')

where "AdminServer" is the name of your admin server.

Connect to Admin Server

connect("weblogic","webl0gic","localhost:7001")
where -
admin user - weblogic
admin password=webl0gic
weblogic host - localhost
admin port - 7001


Start Managed Server using nodemanager

nmStart('server_name')


Output
wls:/JJTU_Domain1/serverConfig> nmStart('C_Server1')
Starting server C_Server1 ...
Successfully started server C_Server1 ...

Start Managed Server 

Start(“MS1”) 


Where MS1 is the name of your managed server

To kill server using node manager

nmKill('server_name')

Output

wls:/JJTU_Domain1/serverConfig> nmKill('C_Server1')
Killing server C_Server1 ...
Successfully killed server C_Server1 ...


To check node manager status

nmVersion()

Output

wls:/JJTU_Domain1/serverConfig> nmVersion()
The Node Manager version that you are currently connected to is 10.3.


Domain enrollment with nmEnroll()

nmEnroll()

NmEnroll is used to enroll a machine or you can say to enroll a domain with the node manager because if you have multiple domains ( of different installer ) running on a host then you can handle all with a single node manager but you have have to enroll each domain with the same node manager. 

This is applicable if you have domains from different oracle_home or you can say from different installer on same host ( means you have more than one installation of weblogic on same host with each installer having its different host ).

If you are creating multiple domains from single installer then no need to enroll because it will enroll automatically. 

So to enroll a machine or domain with a particular node manager, follow below steps

1. Start Admin server of domain which you want to enroll with node manager

2. Go to wlst prompt ( go to your_domain, run setDomainEnv and then "java weblogic.WLST")

3. Connect with admin server
    connect("user","password","host:admin_port")

4. Run nmEnroll command
    nmEnroll('C:/Oracle/Middleware/wlserver_12.1/common/nodemanager')

   Where "C:/Oracle/Middleware/wlserver_12.1/common/nodemanager" is the node manager    
   home of node manager with which you want to enroll your domain

5. Update nodemanager.domains under node manager home and add your domain path in     
    same format as earlier domains path there, like below i have added domain in red

     JJTU_Domain1=C\:\\Oracle\\Middleware2\\user_projects\\domains\\JJTU_Domain1
     base_domain=C\:\\Oracle\\Middleware2\\user_projects\\domains\\base_domain   

6. Update node manager password ( username also if not correct there ) from admin console
    ( login to admin console > click on your domain name on left hand side > click on security tab  
     on right hand side > click on Advance link > update node manager password ( username 
     also if not correct there )


Now you can able to connect with node manager


wls:/base_domain/serverConfig> nmConnect("weblogic","weblogic123","localhost","40046","base_domain","C:/Oracle/Middleware2/user_projects/domains/base_domain","plain")
Connecting to Node Manager ...
Successfully Connected to Node Manager.


Note 1 - 

If you are getting below error during connect with node manager, then it means you haven't changed username,password for nodemanager from admin console ( above step 6 )

WLSTException: Error occured while performing nmConnect : Cannot connect to Node Manager. : Access to domain 'base_domain' for user 'weblogic' denied

Note 2 - 

If you are getting below error during connect of node manager then it mean you haven't followed above defined steps OR haven't added your domain on nodemanager.domains


WLSTException: Error occured while performing nmConnect : Cannot connect to Node Manager. : Configuration error while reading domain directory



Disconnect from node manager

nmDisconnect()

Output()

wls:/JJTU_Domain1/serverConfig> nmDisconnect()
Successfully disconnected from Node Manager.


Stop Node Manager

stopNodeManager()

Output

wls:/JJTU_Domain1/serverConfig> stopNodeManager()
Stopped NodeManager successfully

Important Note :


In order to stop the Node Manager process, Node Manager must have been started with the property QuitEnabled=true. You can configure this property in $WLS_HOME/common/nodemanager.properties. This allows you to connect to the Node Manager to shut it down.



9 comments:

  1. This comment has been removed by a blog administrator.

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. Hi mukesh
    while i am runnning the commond SetDomainEnv.sh it showing the following error in linux "command not found" help me about this
    Mail id :sambasivasankar@gmail.com

    ReplyDelete
  4. use ./ in front of script like $./setDomainEnv.sh

    ReplyDelete
  5. This comment has been removed by the author.

    ReplyDelete
    Replies
    1. This comment has been removed by the author.

      Delete
  6. Hi mukesh when i use the ./setDomainEnv.sh it will not set the environment variables
    again it shows the [root@localhost bin] # path

    ReplyDelete
  7. hi samba try . ./setDomainEnv.sh

    ReplyDelete