WF3815V12_wsadmin & cmd

32
Welcome to: wsadmin and Command Line Tools

Transcript of WF3815V12_wsadmin & cmd

Page 1: WF3815V12_wsadmin & cmd

Welcome to:

wsadmin and Command Line Tools

Page 2: WF3815V12_wsadmin & cmd

Unit Objectives

After completing this unit, you should be able to:�Understand how wsadmin works�Understand the various options for invoking wsadmin�Understand JACL scripting and its appropriate use�Understand how wsadmin fits into the BSF�Describe the differences in managing applications, configurations and running objects�Demonstrate the differences between the AdminConfig, AdminApp and AdminControl objects�Understand the functionality of the command line tools available with the product

Page 3: WF3815V12_wsadmin & cmd

�Scripting interface for WebSphere Application Server V5.0

�Full support for all Tcl commands through Java Command Language (JACL), which is based on Tcl

�Available for all versions of WebSphere Application Server V5.0

�Based on Bean Scripting Framework (BSF)�Provides scripting and programming model similar to Java�JACL is currently the only supported language

wsadmin Overview

Page 4: WF3815V12_wsadmin & cmd

RepositoryRepository

Running Application Server

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

Page 5: WF3815V12_wsadmin & cmd

Script(s) Wsadmin

MBean

MBean

MBean

MBean

AdminApp

AdminConfig

AdminControl

Help

Resources

wsadmin - How does it work?

�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 four 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�Help - display information and details about which MBeans are

running

Page 6: WF3815V12_wsadmin & cmd

Three ways to invoke wsadmin:

Command option wsadmin [-c command]

Script file wsadmin [-f scriptfile]

Interactively wsadmin

Invoking wsadmin

Page 7: WF3815V12_wsadmin & cmd

�Configuration management scripts use the AdminConfigobject to access the repository where configuration information is stored�Example: Output

AdminConfig

AdminConfig � Managing Configurations

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

Page 8: WF3815V12_wsadmin & cmd

AdminApp � Managing Applications

�Application management scripts use the AdminApp object to manage applications in the application server configuration.

�Example:

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

Page 9: WF3815V12_wsadmin & cmd

�Operation management scripts use the AdminControl object to communicate with the MBeans that represent running objects. �Example:

AdminControl

Output

AdminControl � Managing Running Objects

�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

Page 10: WF3815V12_wsadmin & cmd

Scripting and JACL

�Very beneficial for production environments with multiple nodes

�Allows multiple configuration changes/updates to be applied to all targeted resources in an efficient manner

�JACL presents an initial learning curve to the administrator not familiar with Tcl or scripting

�JACL�s interpreter is written entirely in Java

�JACL can run on any Java Virtual Machine (JVM)

Page 11: WF3815V12_wsadmin & cmd

############################################## Use of set, variable and $ ##############################################set node [$AdminConfig list Node]$AdminConfig show $node

Variable

############################################## Use of foreach, puts and show ##############################################set serverlist [$AdminConfig list Server]foreach i $serverlist {puts "$i \n[$AdminConfig show $i]"}

Loop through a set of values

Output the details of each server

�Scripts can be saved to .jacl files

JACL 101

Loop variable

Page 12: WF3815V12_wsadmin & cmd

############################################## Create an application server ##############################################set node [$AdminConfig list Node]set server [$AdminConfig create Server [$AdminConfig getid /Node:$node/] {{name NewServer}}]$AdminConfig saveset sid [$AdminConfig getid /Node:$node/Server:$server/]############################################## Modify the JVM settings ##############################################set jvmid [$AdminConfig list JavaVirtualMachine $sid]$AdminConfig modify $jvmid {{initialHeapSize 128} {maximumHeapSize 256}}$AdminConfig save############################################## Start the server ##############################################$AdminControl startServer $server $node

�Changes are persisted when $AdminConfig save is called

JACL 101 - another example

Page 13: WF3815V12_wsadmin & cmd

�Commands are case-sensitive

�wsadmin -f "scriptfile" is much faster than wsadmin -c "command"�Better to run multiple commands in a file than individual

commands

�Saving configuration changes is a two step process:�first part validates the changes�second part performs the save but will throw an exception if

changes already made (example: creating two servers with the same name)

�Call $AdminConfig save periodically in the script file to persist configuration updates to existing objects

wsadmin - Important Points to Remember

Page 14: WF3815V12_wsadmin & cmd

Profiles

�Profiles allow you to customize the environment in which a script runs

�Profiles are stored in a jacl file

�Profiles run before any wsadmin commands

�Can be specified in two ways:�Using the �profile option

�wsadmin �profile c:\your_profile1.jacl�In the wsadmin.properties file

�com.ibm.ws.scripting.profiles=c:/your_profile1.jacl

�This could be used to:�Enable and disable global security�Enable and disable LTPA_LDAP security

Page 15: WF3815V12_wsadmin & cmd

Security

�There are two security profiles that allow you to manage security configuration�securityProcs.jacl

�Allows you to enable/disable global security�Sets the user ID/password for LocalOS security

�LTPA_LDAPSecurityProcs.jacl�Configures appropriate parameters for non-LocalOS security

Page 16: WF3815V12_wsadmin & cmd

Security (continued)

�If security is enabled, authentication information must be supplied for server communication�Userid and password can be supplied at the wsadmin command line or in sas.client.props file

Page 17: WF3815V12_wsadmin & cmd

Tracing

�Tracing can be enabled through the AdminControl object

�Trace command changes the trace settings for the current session only

�Enable tracing with the following command:� $AdminControl trace com.ibm.*=all=enable

�Disable tracing with the following command:� $AdminControl trace com.ibm.*=all=disable

Page 18: WF3815V12_wsadmin & cmd

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

�For details of tasks see Javadoc for package com.ibm.websphere.ant.tasks�For information about Ant see http://jakarta.apache.org/ant/index.html�To run Ant use command ws_ant

Page 19: WF3815V12_wsadmin & cmd

Command Line Tools

�There are a number command line tools that are useful for working with local nodes and servers�wsadmin is the best tool to use when administering remote

machines

�The available tools can help you to:�Start and stop servers �Configure nodes�Create and delete messaging components�Backup and restore configurations�Run deployment tools

Page 20: WF3815V12_wsadmin & cmd

Controlling Servers

�startServer�Launches a new JVM to run a server �Can also write the launch command to a file�Example: startServer server1

�stopServer�Stops the specified server

�serverStatus�Obtains the status of one or all the servers on a node�Example: serverStatus �all

�Also: �startNode / stopNode for the Node Agent�startManager / stopManager for the Deployment Manager

Page 21: WF3815V12_wsadmin & cmd

Configuring Nodes

�addNode�Adds a node to an existing cell�Connects to the JMS port on the deployment manager�Use -includeapps option to copy applications to cell config�Examples:

�addNode mydmgr 8879 �addNode mydmgr 8879 -includeapps

�removeNode�Removes a node from a cell�Returns the node to its previous standalone configuration

�cleanupNode�Deletes a node from the master configuration�Use on deployment manager to cleanup a failed node

�syncNode�Pulls configuration changes to the node�Useful if you have disabled automatic synchronization

Page 22: WF3815V12_wsadmin & cmd

Configuring Messaging

�createmq�Creates for the node:

�The messaging broker�Queue Manager�Supporting messaging objects

�deletemq�Deletes for the node:

�The messaging broker�Queue Manager�Supporting messaging objects

�This command does not uninstall the WebSphere MQ or broker products

Page 23: WF3815V12_wsadmin & cmd

Managing Configuration Data

�backupConfig�Backs up the configuration of the node to a zip file�All servers will be stopped first�Default file name is: WebSphereConfig_yyyy-mm-dd.zip in

the bin directory

�restoreConfig�Restores the configuration of the node from the zip file

created by the backupConfig command�Usage: restoreConfig backup_file

Page 24: WF3815V12_wsadmin & cmd

�assembly � Run Application Assembly Tool�clientConfig � Run Application Client Resource Configuration Tool�earconvert � Convert J2EE 1.2 ear file to 1.3�EARExpander � Expand ear file to directory or collapse to file�ejbdeploy � Deploy EJBs in an ear file�GenPluginCfg � Regenerate plug-in configuration�ikeyman � Run IBM Key Management Utility to create SSL keys�JspBatchCompiler � Compile JSPs in an installed application�PropFilePasswordEncoder � Encode passwords in properties files�SoapEarEnabler � Add SOAP administration tool to an ear file

Other Configuration and Deployment Tools

Page 25: WF3815V12_wsadmin & cmd

�Discussed the functionality of wsadmin�Discussed how to invoke wsadmin�Discussed JACL scripting and when to use it�Described the differences between managing�Applications�Configurations�Running objects

�Discussed the use of wsadmin objects�AdminApp�AdminConfig�AdminControl

�Discussed the use of profiles�Discussed tracing and security issues�Discussed the use of command line tools

Unit Summary

Page 26: WF3815V12_wsadmin & cmd

Additional Material

Page 27: WF3815V12_wsadmin & cmd

�All WebSphere Application Server V5.0 Admin client programs use JMX�Web Admin console�wsadmin scripting�Admin Client Java API

�Included in both �base� Application Server package and Network Deployment�Use the APIs to control WebSphere runtime�Extend the set of managed objects with custom JMX MBeans�Attach Admin clients to Cell Manager in order to access entire Admin domain�Node Agents start & monitor individual Application Servers

JMX - Why is it important?

Page 28: WF3815V12_wsadmin & cmd

�Framework oriented at the management of applications and resources�Your application or resources can be "exposed" to remote and local management tools�Framework allows a provider to implement functions such as:�listing configuration settings�editing of configuration settings

�Also allows management applications to monitor events such as:�startup of an application server�shutdown of an enterprise application

JMX - Java Management Extensions

Page 29: WF3815V12_wsadmin & cmd

�Bad news�no wscp wrapper�wscp scripts will have to change�no magic bullet to convert scripts

�Good news�InfoCenter provides lots of examples that will make

migration easier�Tcl still used in wsadmin, so learning curve should not be

too high for wscp script writers

wscp to wsadmin Migration Path

Page 30: WF3815V12_wsadmin & cmd

�High level migration steps�Identify the wscp commands in your scripts�Determine if each command is for configuration or operation�Locate the corresponding wsadmin object type for each configuration command.�Use AdminConfig create, list, modify, remove, show and showAttribute to perform equivalent operation in V5.0�Determine V5.0 attribute names�Convert application installation commands.�Convert operational commands. �Save configuration changes.

wscp to wsadmin Migration Path

Page 31: WF3815V12_wsadmin & cmd

Conversion Table 1: V4.0 Configuration Command to V5.0 Configuration Type

v4.0 wscp command v5.0 wsadmin configuration type

ApplicationServer serverContext N/ADataSource WAS40DataSource, DataSourceDomain N/AEnterpriseApp ApplicationDeployment: also use AdminAppGenericServer ServerJ2CConnectionFactory J2CConnectionFactoryJ2CResourceAdapter J2CResourceAdapterJDBCDriver JDBCProviderJMSConnectionFactory JMSConnectionFactoryJMSDestination JMSDestinationJMSProvider JMSProviderMailSession MailSessionModule ModuleDeployment: also use AdminAppNode NodeServerGroup ServerClusterURL URLURLProvider URLProviderVirtualHost VirtualHost

Page 32: WF3815V12_wsadmin & cmd

Conversion Table 2: V4.0 Action to V5.0 Operational Command

v4.0 wscp action v5.0 wsadmin Object and command Mbean Operation

server start AdminControl startServer

server stop AdminControl stopServer

servergroup start AdminControl invoke Cluster start

servergroup stop AdminControl invoke Cluster stop

application start AdminControl invoke ApplicationManager startApplication

application stop AdminControl invoke ApplicationManager stopApplication

node stop AdminControl invoke <nodeagent> stopNode

check run-time attribute AdminControl getAttribute <mbean> <attribute>

check run-time attributes AdminControl getAttributes <mbean> <list of attributes>

regenPluginCfg AdminControl invoke PluginCfgGenerator generate

testConnection AdminControl testConnection

enable security securityon command in securityProcs.jacl

disable security securityoff command in securityProcs.jacl