Vous êtes sur la page 1sur 47

IBM Software Group

WebSphere Application Server


Command Line Administration

Tom Alcott
alcott@us.ibm.com
IBM Software Group

Agenda

Introduction
wsadmin Overview
wsadmin with Security
AdminApp
AdminConfig
AdminControl
AdminTask
Controlling MBeans
IBM Software Group

Introduction

ą Why Script?
– To Provide a Repeatable Process
ą
The Same Rationale As W riting a Business Application
IBM Software Group

Agenda

Introduction
wsadmin Overview
wsadmin with Security
AdminApp
AdminConfig
AdminControl
AdminTask
Controlling MBeans
IBM Software Group

wsadmin Overview
"wsadmin" - Scripting interface for WebSphere Application Server since v5.0
wsadmin offers a number of Advantages
Same scripting tool for all versions of WebSphere
Based on the Bean Scripting Framework (BSF)
Current supported languages for Wsadmin
jacl - Java Command Language based on Tcl scripting
JPython - Java implementation of the Python programming language
Robust scripting features and programming model very similar to Java
Utilize existing programming and scripting skills and technology
BSF Overview
Architecture for easily incorporating scripting into Java applications and applets
Scripting language are commonly used to augment an application function or to
script together a set of application components to form an application
Applications independent and not bound to a single scripting language
Different language scripts can access Java objects (wsadmin)
Java programs can evaluate and access results from scripts in other languages
BSF supports interoperability between Java and BML, JScript, Netscape Rhino
(JavaScript), NetRexx, PerlScript, VBScript, Jacl, JPython, and LotusXSL
IBM Software Group

Working With wsadmin

Run wsadmin.bat or wsadmin.sh


Located in <WAS_ROOT>\<ProfileName>\bin
wsadmin [-c command | -f scriptfile]
[-p propertiesfile]
[-profile scriptfile]
[-h(elp)]
[-?]
[-lang lang]
[-conntype SOAP [-host host_name] [-port port_number] | RMI [-
host host_name] [-port port_number] NONE ]
Specify no parameters for interactive prompt
Script language for prompt based on value in property file
Profile can customize scripting environment with predefined or
helper commands or available for use by main script
Default Language is jacl, use “lang” command for jython
wsadmin -lang jython
IBM Software Group

wsadmin - How Does It Work?


wsadmin Acts as an Iinterface to Java objects for Access by Scripts
Objects communicate with MBeans (JMX management objects)
Objects perform different operations
AdminConfig
Create or change the WebSphere configuration
AdminApp
Install, modify, or administer applications
AdminControl
Work with live running objects and perform traces and data type conversion
AdminTask
Runs administrative commands
Help
Display general help information and details about which MBeans are running
MBean
Separation Between Configuration and Control pp
i n A
m
Ad AdminConfig MBean
Script wsadmin AdminCont
rol
Admi MBean
He

nTas
k
pl

MBean
MBean
IBM Software Group

wsadmin Operations and Functions


AdminConfig AdminApp AdminControl AdminTask Help
Commands Commands Commands Commands commands
createObject install getHost A very long list !! attributes
create install getPort operations
remove interactive getType constructors
list options reconnect description
show taskinfo isAlive notifications
modify list queryNames classname
getid move getMBeanCount all
contents uninstall getDomainName help
parents modify getDefaultDomain AdminControl
attributes show getMBeanInfo AdminConfig
types listmodules isInstanceOf
save export isRegistered
reset help getAttribute
hasChanges setAttribute
queryChanges invoke
setSaveMode makeObjectName
help trace
help
IBM Software Group

wsadmin - Connection Types

wsadmin -conntype <conntype>


SOAP
The Default
Firewall Friendly
RMI
Can Add Complexity to Firewall Configurations
None (also known as "local mode")
Allows Configuration Updates with no Server Process Running
WAS61\AppServer\profiles\Dmgr01\bin>wsadmin -conntype NONE
WASX7357I: By request, this scripting client is not connected to any server process. Certain
configuration and application operations will be available in local mode. WASX7029I: For
help, enter: "$Help help"
IBM Software Group

wsadmin help
ą Using Jacl

– $AdminConfig help
– $AdminControl help
– $AdminApp help
– $AdminTask help
ą
$AdminTask help -commands
ą Using Jython
– print AdminConfig.help()
– print AdminControl.help()
– print AdminApp.help()
– print AdminTask.help()
ą
print AdminTask.help('-commands')
IBM Software Group

Administration Scripting Assistance

ą Command Assist in Adminconsole


IBM Software Group

Administration Scripting Assistance

ą Enable command assist logging


– System Administration -> Console Preferences
– . This file is saved to ${LOG_ROOT}/server/
commandAssistanceJythonCommands_user name.log
IBM Software Group

Administration Scripting Tools

ą V6.1 Application Server Toolkit and V7.0 RAD A&D provide tools
for the creation and maintenance of wsadmin Jython files
– Includes an editor with an outline view, color syntax highlighting
and context sensitive code completion
– Integration with the new "command assist" function
available in the admin console
– Intercepts generated commands for easy insertion into Jython Script
ą Jython debug support provides an
integrated debugger for stepping
through the execution of a wsadmin
Jython script
IBM Software Group

Administration scripting choices


ą JACL or Jython?
ą JACL is currently used more often
ą Jython is the preferred direction
– More industry support
– Better performance
– Priority in future deliverables
ą No need to convert JACL
– No longer deprecated!
– It is now “Stabilized” – meaning it will not be removed but it will not have further investment
– Conversion tool included since v6.1 and available in RAD Assembly and Deploy tool or via
download (see references)
ą Suggest an evolution
– Create new scripts using Jython
IBM Software Group

wsadmin - JACL and JPython


JACL JPython
#--------------------------------------------------------- #---------------------------------------------------------
# Get the apps # Get the apps
#--------------------------------------------------------- #---------------------------------------------------------
puts print "----------------------------------------------------"
"----------------------------------------------------" print ""
puts "" apps = AdminApp.list()
set apps [$AdminApp list] if len(apps) == 0:
puts "Number of applications: [llength print "There is no application"
$apps]" else:
puts "" appsList = apps.split(lineSeparator)
puts $apps print "Number of applications: %s" % (len(appsLis
print ""
if {$configonly} { for app in appsList:
return print app
}
if configOnly == 1:
return
IBM Software Group

wsadmin Hints and Tips (1/2)


Commands are case-sensitive
e.g Node name of AVALONNode01 is not the same as AvalonNode01!!
Configuration changes not persisted until "save" call
If multiple scripts or clients (Administrative Console) are saving configuration
changes at the same time, exception thrown on Save call
Console Allows for Overwrite or Discard
wsadmin Throws com.ibm.websphere.management.exception.ConfigServiceException
Upon "save" call, validation procedure verifies updates
Create two servers with the same name throws exception
Faster than Administration Console
wsadmin -f "xxxxx" much faster than wsadmin -c "xxxxx"
Better to run multiple commands in a file than individual commands
Call "save" in file periodically to persist configurations updates
Avoids no changes being persisted should an exception occur
IBM Software Group

wsadmin Hints and Tips (2/2)


ą Use “interactive “ to create sample scripts

wsadmin>AdminTask.createApplicationServer('-interactive')
Create Server

<input omitted for brevity>

Select [S, N, F, C, H]: [F]


W ASX7278I: Generated command line: AdminTask.createApplicationServer
('AVALONNode01', '[-name server2 -genUniquePorts true ]')
'server2(cells/AVALONCell01/nodes/AVALONNode01/servers/server2|
server.xml#Server_1259786255578)'
wsadmin>
IBM Software Group

Agenda

Introduction
wsadmin Overview
wsadmin with Security
AdminApp
AdminConfig
AdminControl
AdminTask
Controlling MBeans
IBM Software Group

wsadmin with Security


SOAP Connection (default)

V6.1 and V7.0 will prompt automatically based on client type

Supply User and Password on Command Line


C:\WAS61\AppServer\profiles\Dmgr01\bin>wsadmin -user jdoe1 -password mypassword
WASX7209I: Connected to process "dmgr" on node alcottManager using SOAP connector; The type of process
is: DeploymentManager
WASX7029I: For help, enter: "$Help help"
wsadmin>

Modify soap.client.props
# JMX SOAP connector identity
com.ibm.SOAP.loginUserid=jdoe1
com.ibm.SOAP.loginPassword=mypassword
IBM Software Group

wsadmin with Security


RMI Connection
Supply User and Password on Command Line
C:\WAS61\AppServer\profiles\Dmgr01\bin>wsadmin -conntype RMI -port 9809 -user jdoe1 -password
mypassword
WASX7209I: Connected to process "dmgr" on node alcottManager using RMIconnector; The type of process is:
DeploymentManager
WASX7029I: For help, enter: "$Help help"
wsadmin>

Modify sas.client.props
Rely on Client Prompt
C:WAS61\AppServer\profiles\Dmgr01\bin>wsadmin -conntype RMI -port 9809
WASX7209I: Connected to process "dmgr" on node alcottManager using RMIconnector; The type of process is:
DeploymentManager
WASX7029I: For help, enter: "$Help help"
wsadmin>
IBM Software Group

Agenda

wsadmin Overview
wsadmin with Security
AdminApp
AdminConfig
AdminControl
AdminTask
Controlling MBeans
IBM Software Group

AdminApp

AdminApp Installs, Modifies, and Administers Applications


Supports Application Inquiries and Changes
Installing and Uninstalling Applications
Listing Modules,
Exporting, etc.
Available in Local Mode
IBM Software Group

AdminApp

List Installed Applications


wsadmin>$AdminApp list
wsadmin> print AdminApp.list()
Application Install Options
Default
wsadmin>$AdminApp install c:/WAS61/AppServer/installableApps/DefaultApplication.ear
Interactive
wsadmin>$AdminApp installInteractive c:/WAS61/AppServer/installableAppsDefaultApplication.ear
wsadmin> print AdminApp.installInteractive('C:/WAS61/AppServer/installableApps/De
faultApplication.ear')
Application Uninstall
wsadmin>$AdminApp uninstall DefaultApplication
wsadmin AdminApp.uninstall('DefaultApplication')
IBM Software Group

Agenda

Introduction
wsadmin Overview
wsadmin with Security
AdminApp
AdminConfig
AdminControl
AdminTask
Controlling MBeans
IBM Software Group

AdminConfig

Run Configuration Commands


List, Create or Change WAS Configuration.
Available in Local Mode
IBM Software Group

AdminConfig

List Configuration Objects


wsadmin>$AdminConfig types
Application Object Attributes
wsadmin>$AdminConfig attributes <type>

wsadmin>$AdminConfig attributes Server

Application Object Required Attributes


wsadmin>$AdminConfig required <type>
Application Object Default Attributes
wsadmin>$AdminConfig defaults <type>
List Configured Objects
wsadmin>$AdminConfig list <type>
IBM Software Group

AdminConfig

List Object Hierarchy


wsadmin>$AdminConfig parents <type>

wsadmin>$AdminConfig parents JDBCProvider


Cell
Node
Server
wsadmin>

Get Configuration Identifier


wsadmin> set $var [$AdminConfig getid <type:name> ]

wsadmin>set cellName [$AdminControl getCell]


wsadmin>set cellID [$AdminConfig getid /Cell:$cellName/]
alcottNetwork(cells/alcottNetwork:cell.xml#Cell_1)
wsadmin>
IBM Software Group

AdminConfig - sample task

Change JVM Heap Size


wsadmin>set server [$AdminConfig getid /Node:alcott/Server:server1/]
wsadmin>set jvm [$AdminConfig list JavaVirtualMachine $server]
wsadmin >$AdminConfig show $jvm

{bootClasspath {}}
{classpath {}}
{debugArgs "-Djava.compiler=NONE -Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket
,server=y,suspend=n,address=7777"}
{debugMode false}
{disableJIT false}
{genericJvmArguments {}}
{hprofArguments {}}
{initialHeapSize 0}
{maximumHeapSize 256}
{runHProf false}
{systemProperties {}}
{verboseModeClass false}
{verboseModeGarbageCollection false}
{verboseModeJNI false}

wsadmin >$AdminConfig modify $jvm {{ initialHeapSize 64 } {maximumHeapSize 320}}


wsadmin>$AdminConfig save
IBM Software Group

Agenda

Introduction
wsadmin Overview
wsadmin with Security
AdminApp
AdminConfig
AdminControl
AdminTask
Controlling MBeans
IBM Software Group

AdminControl

AdminControl Invokes Operational Commands on Running Objects in WAS


Not Available in "Local" Mode
AdminControl Methods Have Multiple Signatures
Invoke in a raw mode using Parameters: specified by JMX
getAttribute_jmx
Input name -- ObjectName
Returns - javax.management.AttributeList
Using strings for Parameters
getAttribute
Input name - String
Returns - String
AdminControl Also Supports
Utility Methods for Tracing
Reconnecting with a Server
Converting DataTypes
IBM Software Group

AdminControl

Start Server
wsadmin>$AdminControl startServer <servername> <nodename>
wsadmin>$AdminControl startServer server1 alcott
Stop Server
wsadmin>$AdminControl stopServer <servername> <nodename>
List Applications Running on a Server
set apps [$AdminControl queryNames type=Application,cell=$cname,node=$nname,process=$sname,*]
puts " Number of applications running on $sname: [llength $apps]"
foreach app $apps {
set aname [$AdminControl getAttribute $app name]
puts " $aname"
}
puts "----------------------------------------------------"
puts ""
IBM Software Group

AdminControl

Stop/Start Applications
List the Applications for a Server ($AdminApp list will also work)
wsadmin>set apps [$AdminControl queryNames cell=<cellname>,node=<nodename>,type=Application,process=<servername>,*]

Specify the Application Manger (Server)


wsadmin>set appManager [$AdminControl queryNames cell=<cellname>,node=<nodename>,type=ApplicationManager,process=<servername>,*]

Stop/Start the Application


wsadmin>$AdminControl invoke $appManager stopApplication <appname>

wsadmin>$AdminControl invoke $appManager startApplication <appname>

wsadmin>set appManager [$AdminControl queryNames cell=alcottNetwork,node=alcott, type=ApplicationManager,process=server1,*]

wsadmin>set apps [$AdminControl queryNames cell=alcottNetwork,node=alcott,type=Application,process=server1,*]

wsadmin>$AdminControl invoke $appManager stopApplication DefaultApplication

wsadmin>$AdminControl invoke $appManager startApplication DefaultApplication

wsadmin>
IBM Software Group

AdminControl

Stop ServerMBean (Doesn't Wait for Stop to Return Control)


set serverMBeans [$AdminControl queryNames cell=$cellName,node=
$nodeName,type=Server,processType=ManagedProcess,*]

# Remove those servers from the serverMBeans list that should not be stopped
# .... For this example assume that two particular servers were removed from serverMBeans
set numOtherBeans 2

# Stop the servers

foreach server $serverMBeans { $AdminControl invoke $server stop }

# Wait for servers to finish stopping

while {1} {
after 5000 # Wait 5 seconds for stop
set serverMBeans [$AdminControl queryNames cell=$cellName,node=
$nodeName,type=Server,processType=ManagedProcess,*]
if {[llength $serverMBeans] == $numOtherBeans} {
break
}
}
IBM Software Group

AdminControl

Getting the Node Name


wsadmin > wsadmin>set nodeName [$AdminControl getNode]
alcottManager

Then You Run Some Command

[1/7/04 0:26:59:725 EST] 4d87bd86 AbstractShell E WASX7120E: Diagnostic information from exception with text
"com.ibm.websphere.management.exception.ConfigServiceException
javax.management.InstanceNotFoundException: *:*,node=alcottManager,type=NodeAgent

wsadmin>$AdminConfig list Node


alcott(cells/alcottNetwork/nodes/alcott:node.xml#Node_1)
alcottManager(cells/alcottNetwork/nodes/alcottManager:node.xml#Node_1)
wsadmin>

wsadmin>$AdminConfig showAttribute [lindex $node 0 ] name


alcott

Or Set via Property or Command Line


IBM Software Group

AdminControl

Enabling Trace

Obtain the Object Name


wsadmin>set ts [$AdminControl completeObjectName type=TraceService,process=server1,*]

Turn on Trace
wsadmin>$AdminControl setAttribute $ts traceSpecification com.ibm.*=all=enabled

Don't Forget to Save


wsadmin>$AdminConfig save
IBM Software Group

Agenda

Introduction
wsadmin Overview
wsadmin with Security
AdminApp
AdminConfig
AdminControl
AdminTask
Controlling MBeans
IBM Software Group

AdminTask

ą Consolidates discrete commands


– “Old School”
– server1 = AdminConfig.getid('/Cell:mycell/Node:mynode/Server:server1/')
– jvm = AdminConfig.list('JavaVirtualMachine', server1)
– AdminConfig.modify(jvm, [['debugMode', 'true'], ['debugArgs', "-
Djava.compiler=NONE -Xdebug -Xnoagent -
Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=7777"]])

– Using AdminTask
– AdminTask.setJVMDebugMode (['-serverName', 'server1', '-nodeName',
'node1', '-debugMode', 'true'])
IBM Software Group

Agenda

Introduction
wsadmin Overview
wsadmin with Security
AdminApp
AdminConfig
AdminControl
AdminTask
Controlling MBeans
IBM Software Group

Controlling MBeans (1/4)


Obtain Reference to MBean

Example Obtain Reference to Messaging Engine MBean


wsadmin>set sibme [$AdminControl queryNames *:*,node=AVALONNode01,type=SIBMessagingEngine,process=server3]
IBM Software Group

Controlling MBeans (2/4)


List Attributes (1/2)
wsadmin>$Help all $sibme
Name:WebSphere:name=AVALONNode01.server3sibws,process=server3,platform=dynamicproxy,node=AVALONNode01,version=6.1.0.23,type=SIBMessag
ingEngine,mbeanIdentifier=com.ibm.websphere.models.config.sibresources.impl.SIBMessagingEngineImpl,cell=AVALONCell01,spec=1.0
Description: Management interface for the SIB Messaging Engine component
Class name: javax.management.modelmbean.RequiredModelMBean
Attribute T ype Access
eventT ypes [Ljava.lang.String; RO
stats javax.management.j2ee.statistics.Stats RO

Operation
boolean isStarted()
java.lang.String state()
java.lang.String stateExtended()
void start()
void start(java.lang.String)
void stop()
void stop(java.lang.String)
[Lcom.ibm.websphere.sib.admin.SIBQueuePoint; listQueuePoints()
com.ibm.websphere.sib.admin.SIBQueuePoint getQ ueuePoint(java.lang.String)
[Lcom.ibm.websphere.sib.admin.SIBQueuedMessage; getQueuePointMessages(java.lang.String)
com.ibm.websphere.sib.admin.SIBQueuedMessage getQueuePointMessage(java.lang.String, java.lang.String)
com.ibm.websphere.sib.admin.SIBQueuedMessageDetail getQ ueuePointMessageDetail(java.lang.String, java.lang.String)
com.ibm.websphere.sib.admin.SIBQueuedMessageDetail getQ ueuePointMessageDetail(java.lang.String, java.lang.String, java.util.Locale)
[B getQ ueuePointMessageData(java.lang.String, java.lang.String, java.lang.Integer)
com.ibm.wsspi.hamanager.G roupName getHAG roupName()
java.lang.String getHealth()
void injectF ault(java.lang.String)
void dump(java.lang.String)
java.util.Collection getPreparedT ransactions()
void commitPreparedT ransaction(java.lang.String)
void rollbackPreparedT ransaction(java.lang.String)
void resetDestination(java.lang.String)
[Ljava.lang.String; getEventT ypes()
javax.management.j2ee.statistics.Stats getStats()
IBM Software Group

Controlling MBeans (3/4)


List Attributes (2/2)

Notifications
SIB.messaging.engine.start
SIB.messaging.engine.stop
SIB.security.not.authenticated
SIB.security.not.authorized
SIB.communications.connection.start
SIB.communications.connection.stop
SIB.message.exceptioned
SIB.client.connection.start
SIB.client.connection.stop
j2ee.state.starting
j2ee.state.running
j2ee.state.stopping
j2ee.state.stopped
j2ee.state.failed
j2ee.attribute.changed
jmx.attribute.changed

Constructors
IBM Software Group

Controlling MBeans (4/4)


Messaging Engine Example Operations
wsadmin>$AdminControl invoke $sibme state
Started
wsadmin>$AdminControl invoke $sibme stop

wsadmin>$AdminControl invoke $sibme state


Stopped
wsadmin>$AdminControl invoke $sibme start

wsadmin>$AdminControl invoke $sibme state


Started
wsadmin>$AdminControl invoke $sibme listQueuePoints
com.ibm.ws.sib.admin.impl.SIBQueuePointImpl@3dce3dce
com.ibm.ws.sib.admin.impl.SIBQueuePointImpl@3eb83eb8
com.ibm.ws.sib.admin.impl.SIBQueuePointImpl@3f783f78
com.ibm.ws.sib.admin.impl.SIBQueuePointImpl@3ff03ff0
wsadmin>
IBM Software Group

Summary

WebSphere wsadmin BSF command line tool


jacl
jPython
SOAP and RMI Connectors
Five Administation Objects
AdminApp
AdminConfig
AdminControl
AdminTask
Help
Provides Secure and Repeatable Process for Administration
IBM Software Group

Additional Resources

Beginning Tcl
http://mini.net/tcl/298.html
More Information on jacl (The Java version of Tcl)
http://mini.net/tcl/jacl
The Tcl/Jacl Project
http://tcljava.sourceforge.net/docs/website/index.html
The JPython Projct
http://sourceforge.net/projects/jpython/
http://www.jython.org
V6.0/V6.1/V7.0 Info Center
http://publib.boulder.ibm.com/infocenter/wasinfo/v6r0/index.jsp
http://publib.boulder.ibm.com/infocenter/wasinfo/v6r1/index.jsp
http://publib.boulder.ibm.com/infocenter/wasinfo/v7r0/index.jsp

Jacl to Jython Conversion Assistant


http://www-01.ibm.com/support/docview.wss?rs=180&uid=swg24012144
IBM Software Group

Additional Resources

ą
WebSphere Application Server
Administration Using Jython
– by Robert A. Gibson, Arthur Kevin
McGrath, Noel J. Bergman
IBM Software Group

Combining AdminApp and AdminConfig in WAS V5.x

Script to Disable All Installed Applications (except adminconsole)


set appList [$AdminApp list]
foreach {appName} $appList { if [ string compare $appName "adminconsole" ] {
puts "disabling $appName"
set deployments [$AdminConfig getid /Deployment:$appName/]
set deploymentObject [$AdminConfig showAttribute $deployments deployedObject]
set targetMappings [lindex [$AdminConfig showAttribute $deploymentObject targetMappings] 0]
$AdminConfig modify $targetMappings {{enable false}}
$AdminConfig save
}
}
IBM Software Group

wsadmin - wscp Comparison/Contrast Example

wscp
wscp> EnterpriseApp install /Node:mynode/ c:\temp\myapp.ear -
defappserver /Node:mynode/ApplicationServer:Default_Server/
wsadmin
wsadmin>$AdminApp Install c:/temp/myapp.ear -conntype NONE
Multiple ways to execute the command
wsadmin -c "$AdminApp Install c:/temp/myapp.ear -conntype
NONE"
wsadmin -lang jacl -f mycommand.jacl

Vous aimerez peut-être aussi