You are on page 1of 17

WebLogic Scripting Tool (WLST)

WebLogic Scripting Tool (WLST)


Agenda
Introduction Advantages Other Utilities How does it work? Modes of Operation Example for Configuring a Cluster Navigating & Editing MBeans Managing Servers & Server Lifecycle Automating WLS Admin Tasks Commands

WebLogic Scripting Tool (WLST)


Introduction
What is WLST? Command Line Scripting Interface. Based on Java Scripting Interface - Jython.

WebLogic Scripting Tool (WLST)


Advantages
Configure, manage and persist changes to WLS instances and domains. Monitor and manage runtime events. Domain Generation. Navigate and interrogate MBeans. Edit Configuration MBeans. Manage Servers & Server Life Cycle Events. Automate WLS Admin Tasks.

WebLogic Scripting Tool (WLST)


Other Utilities
weblogic.Admin
Interrogate MBeans and configure server instance.

wlconfig / wldeploy
Ant Task for making changes in WLS configuration.

weblogic.Deployer
Deploying Applications.

WebLogic Scripting Tool (WLST)


How does it work?
Online Connecting to a running Admin or Managed Server. Offline Not Connected.

WebLogic Scripting Tool (WLST)


Modes of Operation
Interactive Mode
java weblogic.WLST

Script Mode
java weblogic.WLST scriptname.py Apply same configuration settings, iteratively across multiple nodes of a topology. Schedule scripts to run at various times for monitoring purposes. Automate Repetitive and Complex Tasks.

Embedded Mode
From Java Code.

WebLogic Scripting Tool (WLST)


Example
from java.util import * from javax.management import * import javax.management.Attribute print 'starting the script .... connect('username','password','t3://localhost:7001')

Import Statement

Connect To Server.

clusters = "cluster1","cluster2" ms1 = {'managed1':7701,'managed2':7702,'managed3':7703, 'managed4':7704, 'managed5':7705} ms2 = {'managed6':7706,'managed7':7707,'managed8':7708, 'managed9':7709, 'managed10':7710} clustHM = HashMap() edit() startEdit() for c in clusters: print 'creating cluster '+c clu = create(c,'Cluster') clustHM.put(c,clu)

Open in Edit Mode

Create Cluster

WebLogic Scripting Tool (WLST)


Example (Continued)
cd('..\..') clus1 = clustHM.get(clusters[0]) clus2 = clustHM.get(clusters[1]) for m, lp in ms1.items(): managedServer = create(m,'Server') print 'creating managed server '+m managedServer.setListenPort(lp) managedServer.setCluster(clus1) for m1, lp1 in ms2.items(): managedServer = create(m1,'Server') print 'creating managed server '+m1 managedServer.setListenPort(lp1) managedServer.setCluster(clus2) save() activate(block="true") disconnect() print 'End of script ...'

Create Servers

Save & Activate

WebLogic Scripting Tool (WLST)


Navigating MBeans
ls(), cd(), pwd() Configuration MBean Hierarchy
Domain MBean (root) |- - - MBean type (LogMBean) |- - - MBean instance (medrec) |- - - MBean attributes & operations (FileName) |- - - MBean type (RealmMBean) |- - - MBean type (ServerMBean) |- - - MBean instance (MedRecServer) |- - - MBean attributes & operations (StartupMode) |- - - MBean instance (ManagedServer1) |- - - MBean attributes & operations (AutoRestart)

WebLogic Scripting Tool (WLST)

cmo Current Management Object.


The cmo variable is set to the bean instance to which you navigate using WLST. You can use this variable to perform any get, set, or invoke method on the current bean instance.

wls:/mydomain/serverConfig> cmo [MBeanServerInvocationHandler]mydomain:Name=mydo main,Type=Domain wls:/mydomain/serverConfig> cd('Servers') wls:/mydomain/serverConfig/Servers> cmo [MBeanServerInvocationHandler]mydomain:Name=mydo main,Type=Domain wls:/mydomain/serverConfig/Servers> cd('myserver') wls:/mydomain/serverConfig/Servers/myserver> cmo [MBeanServerInvocationHandler]mydomain:Name=myser ver,Type=Server

WebLogic Scripting Tool (WLST)


Example Creating a Managed Server
connect("username","password") edit() startEdit() svr = cmo.createServer("managedServer") svr.setListenPort(8001) svr.setListenAddress("my-address") save() activate(block="true") startEdit()

Connect To Server Start Edit

Create Server Save & Activate Start Edit

WebLogic Scripting Tool (WLST)


Other capabilities
Start an Admin Server with or without Node Manager. Act as a client to Node Manager for starting, suspending and stopping servers remotely. Retrieve information of running WLS instances. Managing Server States

WebLogic Scripting Tool (WLST)


Managing Servers & Server Lifecycle
Admin Server Without Node Manager
Set Environment. startServer('adminServerName', 'domainName', 'url', 'username', 'password', 'domainDir')

Managed Server Without Node Manager


Start Admin Server. connect (username, password) start('managedServerName', 'Server', 'managedServerlistenAddress', managedServerlistenPort)

WebLogic Scripting Tool (WLST)


Managing Servers & Server Lifecycle
Using Node Manager to Manage Servers
java weblogic.WLST startNodeManager.cmd or startNodeManager.sh nmConnect("weblogic", "weblogic", "localhost", "5555", "BEA_DOMAIN,"c:/bea90_29/user_projects/domains/BEA_DOMAIN",s sl") nmStart('adminServerName') nmServerStatus('adminServerName') nmKill()

WebLogic Scripting Tool (WLST)


WLST Script Generator for Console
Generates WLST Scripts for all configuration edits done via console. Converts all calls to MBeans from console to WLST Commands.

WebLogic Scripting Tool (WLST)


Automating WLS Admin Tasks
Domain Creation in Offline Mode Deploying Applications Monitor Server State Monitor JVM Lab Session Configure Logging

You might also like