Friday, 28 March 2014

Weblogic WLST : Basics


Weblogic WLST : Basics of WLST ( Weblogic Scripting Tool )


First run setDomainEnv to set classpath

E:\Oracle\WLS1036\user_projects\domains\base_domain\bin>setDomainEnv.cmd

Now run below commands to connect with WLST prompt

E:\Oracle\WLS1036\user_projects\domains\base_domain>java weblogic.WLST
Exception in thread "Main Thread" java.lang.NoClassDefFoundError: weblogic/WLST
Caused by: java.lang.ClassNotFoundException: weblogic.WLST
        at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Could not find the main class: weblogic.WLST.  Program will exit.

if you get above error then use -cp with java with full weblogic.jar in path

E:\Oracle\WLS1036\user_projects\domains\base_domain>java -cp E:\Oracle\WLS1036\wlserver_10.3\server\lib\weblogic.jar weblogic.WLST

Initializing WebLogic Scripting Tool (WLST) ...

Welcome to WebLogic Server Administration Scripting Shell

Type help() for help on available commands

wls:/offline>

Now, at WLST prompt, use below command to connect with admin server

wls:/offline> connect('weblogic','webl0gic','t3://localhost:7001')
Connecting to t3://localhost:7001 with userid weblogic ...
Successfully connected to Admin Server 'AdminServer' that belongs to domain 'base_domain'.

Warning: An insecure protocol was used to connect to the
server. To ensure on-the-wire security, the SSL port or
Admin port should be used instead.

wls:/base_domain/serverConfig>

use below command to connect with node manager

wls:/offline> nmConnect('weblogic','webl0gic','localhost','5556','base_domain','E:/Oracle/WLS1036/user_projects/domains/base_domain','plain')

Connecting to Node Manager ...
Traceback (innermost last):
  File "<console>", line 1, in ?
  File "<iostream>", line 1408, in nmConnect
  File "<iostream>", line 1847, in raiseWLSTException
WLSTException: Error occured while performing nmConnect : Cannot connect to Node Manager. : Access to domain 'base_domain' for user 'weblogic' denie
Use dumpStack() to view the full stacktrace

if you get above error then


1. change node manager username and password as you have mentioned in nmConnect command from admin console => admin console > domain > security > under advance option ( NodeManager Username & NodeManager Password )

2. if still getting error, the update nm_password.properties under domain/config/nodemanager as below

username=weblogic
password=webl0gic

and restart nodemanager

wls:/offline> nmConnect('weblogic','webl0gic','localhost','5556','base_domain','E:/Oracle/WLS1036/user_projects/domains/base_domain','plain')
Connecting to Node Manager ...
Successfully Connected to Node Manager.
wls:/nm/base_domain>

To check status of server using node manager

wls:/nm/base_domain> nmServerStatus('MS1')

RUNNING

To start a server using node manager

wls:/nm/base_domain> nmStart('MS2')
Starting server MS2 ...
Successfully started server MS2 ...
wls:/nm/base_domain>

To disconnect fron node manager

wls:/nm/base_domain> nmDisconnect()
Successfully disconnected from Node Manager.

wls:/offline>

For further WST commands see below post

http://weblogicserveradministration.blogspot.in/2010/10/wlst-iii-online-and-offline-command.html

If you want to run few command via script then add all lines in a .py file in sequence and execute as below


java -cp E:\Oracle\WLS1036\wlserver_10.3\server\lib\weblogic.jar weblogic.WLST your_script.py

your_script.py as below to connect and start managed server MS1 with node manager

---------------------------------------------------------------------------------------------------------------------------------
nmConnect('weblogic','webl0gic','localhost','5556','base_domain','E:/Oracle/WLS1036/user_projects/domains/base_domain','plain')
nmStart('MS1')
nmServerStatus('MS1')
nmDisconnect()
--------------------------------------------------------------------------------------------------------------------------------





No comments:

Post a Comment