wsadmin

•Allows multiple configuration changes/updates to be applied to all targeted resources in an efficient manner. •Allows for automating of routine administration ...
284KB taille 89 téléchargements 201 vues
wsadmin

IBM Confidential

Unit Objectives •After completing this unit, you should be able to discuss: –The purpose of wsadmin –Overview of wsadmin MBeans –How to obtain help for wsadmin and its commands help –Profile scripts –Simple scripting with Jacl and Jython

wsadmin - Introduction •Provides scripting capabilities •Provides command line administration •Common operational and configurational tasks can be performed from scripts and command line instead of through the administrative console •Examples: –Start and stop (deployment manager, nodes, application servers, enterprise applications and clusters) –Configure virtual hosts, JDBC providers –Create application servers –Create clusters and add members to a cluster

wsadmin Overview •wsadmin modes –Interactive –Script file •Support for: –Tcl commands through Java Command Language (Jacl) –Python commands through jython •Jacl versus Jython –Use comes down to a personal choice –Jython syntax seems more natural to programmers used to Java or C –Jacl system can be more familiar to administrators with familiarity with Tcl –Each language has its own style and syntax, but they end up being able to do the same things

Scripting using Jacl or Jython •Very beneficial for production environments with multiple nodes •Allows multiple configuration changes/updates to be applied to all targeted resources in an efficient manner •Allows for automating of routine administration tasks without having to rely on an operator running the administrative console •Scripts can be scheduled to run at times that it might be inconvenient to have an operator at the administrative console

wsadmin Administrative Functions •WebSphere Application Server system management separates administrative functions into two categories:

–Configuration of WebSphere Application Server installations (repository) –Running objects in WebSphere Application Server installations Running Application Server Repository

wsadmin MBeans •wsadmin acts as an interface to Java objects for access by scripts •wsadmin uses the same interface (through JMX) as the administrative console to make configuration changes and control servers •There are five Java objects that perform different operations –AdminConfig - create/change WebSphere Application Server static configuration –AdminApp - install, modify or administer applications –AdminControl - work with live running objects, perform traces and data type conversion –AdminTask - access administrative commands to provide alternate way to access configuration commands –Help – provides help p inA

p

m Ad Config Admin

Script(s)

Wsadmin

AdminControl

Ad mi nT

as

k

MBean

MBean MBean MBean

Resources

Invoking wsadmin Three ways to invoke wsadmin: •Interactively

wsadmin

•Command option

wsadmin [-c command]

•Script file

wsadmin [-f scriptfile]

wsadmin Command Line •Use wsdamin –help to get command line options •wsadmin defaults to using Jacl scripting language –To use jython: wsadmin –lang jython •Use wsadmin to start a shell –Make sure to run from the appropriate profile directory –Brings up a JVM

AdminConfig – Managing Configurations •Configuration management scripts use the AdminConfig object to access the repository where configuration information is stored •Example: Jacl

Jython

•Use the AdminConfig object to: –List configuration objects and their attributes –Create configuration objects –Modify configuration objects –Remove configuration objects –Obtain help

AdminApp – Managing Applications •Application management scripts use the AdminApp object to manage applications in the application server configuration

•Example: Jacl

Jython

•Use the AdminApp object to: –Install and uninstall applications –List installed applications –Edit application configurations –Obtain help

AdminControl – Managing Running Objects •Operation management scripts use the AdminControl object to communicate with the MBeans that represent running objects •Example: Jacl

Jython

•Use the AdminControl object to: –List running objects and their attributes –Invoke actions on running objects –Obtain dynamic information about Mbeans that represent running objects –Obtain help

AdminTask – Accessing Admin Functions •Used to access set of administrative commands to provide alternate way to access configuration commands •Runs simple and complex commands •Grouped based on their function – Example: Commands related to security are grouped into a security management command group •Can be run in batch or interactive mode •Can be run in connected or local mode – If run in local mode not all commands available

Jacl Jython

Help within wsadmin •In order to get help within wsadmin with Jacl $Help help $AdminConfig help $AdminTask help $AdminControl help $AdminApp help •In order to get help within wsadmin with Jython print Help.help() print Help.AdminConfig() print Help.AdminTask() print Help.AdminControl() print Help.AdminApp()

Help on Specific Commands •Help can be obtained on specific commands within the MBeans

Jacl

Jython

wsadmin with Connection Type •wsadmin –conntype [SOAP | RMI | NONE ] –The –conntype specifies the protocol type –Default is SOAP –NONE allows wsadmin to read/write directly to configuration files without going through an application server •wsadmin –profile –Allows wsadmin to preload a profile script

Profile Scripts •Profile scripts can be used to preload wsadmin with predefined settings and functions – Are run during wsadmin startup – Called by either: •Using the –profileName parameter on the command line •Defined in wsadmin.properties com.ibm.ws.scripting.profiles=

– Could be used to create a standard wsadmin environment for all WebSphere administrators – Profile scripts can be written in Jacl or Jython

wsadmin Properties •Certain default behaviors for wsadmin can be changed by editing \\properties\wsadmin.properties

•Properties include: – com.ibm.ws.scripting.connectionType=SOAP – com.ibm.ws.scripting.port=8880 – com.ibm.ws.scripting.host=localhost – com.ibm.ws.scripting.defaultLang=jacl – com.ibm.ws.scripting.traceFile= – com.ibm.ws.scripting.validationOutput= – com.ibm.ws.scripting.traceString=com.ibm.*=all=enabled – com.ibm.ws.scripting.profiles= – com.ibm.ws.scripting.emitWarningForCustomSecurityPolicy=true – com.ibm.ws.scripting.tempdir= – com.ibm.ws.scripting.validationLevel= – com.ibm.ws.scripting.crossDocumentValidationEnabled= – com.ibm.ws.scripting.classpath=

wsadmin - Important Points to Remember •Commands are case-sensitive •wsadmin -f "scriptfile" faster than wsadmin -c "command" –Better to run multiple commands in a script file than individual commands with wsadmin –c •Saving configuration changes is a two step process: –First part validates the changes –Second part performs the save but throws an exception if changes conflict (example: creating two servers with the same name) •Save periodically in the script file or interactive mode to persist configuration updates to existing objects –$AdminConfig save (Jacl) –AdminConfig.save() (Jython)

Scripting – Simple Script

Jacl

Jython

Scripting - Looping

Jacl

Jython

Security •If security is enabled, authentication information must be supplied for server communication •Userid and password can be supplied in one of three ways: – Command line parameters – sas.client.props file for connecting with RMI – soap.client.props file for connecting with SOAP

Ant •Apache Ant is a Java-based build tool –Similar to Make –Uses Java classes instead of shell commands –Uses XML file to specify build tasks •WebSphere Application Server includes Ant tasks to: –Install and uninstall applications –Run EJB deployment and JSP pre-compilation tools –Start and stop servers –Run administrative scripts or commands •To run Ant use command ws_ant

Unit Summary •Having completed this unit, you should be able to discuss: –The purpose of wsadmin –Overview of wsadmin MBeans –How to obtain help for wsadmin and its commands help –Profile scripts –Simple scripting with Jacl and Jython

Lab Exercise

Exercise 7: wsadmin