wsadmin lab

26
© Copyright IBM Corporation 2004 All rights reserved Oct 4 th – 8 th IBM Advance wsadmin System Administration – Lab Exercise Page 1 of 26 2004 WebSphere Technical Exchange IBM WEBSPHERE 5.1.1 wsadmin – LAB EXERCISE SWG Advance wsadmin System Administration for WebSphere Application Server What this exercise is about............................................................................................................................ 1 Lab Requirements ......................................................................................................................................... 1 What you should be able to do ...................................................................................................................... 1 Introduction .................................................................................................................................................... 2 Exercise Instructions ..................................................................................................................................... 2 Part 1: The wsadmin Help Management Object............................................................................................ 3 Part 2: EAR Install Script ............................................................................................................................... 5 Part 3: Configure a Performance Manager Infrastructure Service .............................................................. 11 Part 4: Federate the BASE Node with wsadmin.......................................................................................... 15 Part 5: Thread Dumps on Windows! ........................................................................................................... 18 What you did in this exercise ....................................................................................................................... 22 Appendix A: Resources ............................................................................................................................... 23 Appendix B: Other Challenge Exercise ....................................................................................................... 24 NOTE: Education materials and other documentation as applicable including programming manuals, operating guides, physical planning manuals and installation manuals related to the IBM Products may be early versions subject to change. Documents will be furnished solely for the purpose of and for the duration of WebSphere Application Server v5.1.1. What this exercise is about The objective of this lab is to provide you with a better understanding of wsadmin because this can be very confusing and complex. This hands-on session demonstrates and allows attendees to learn how to leverage the existing documentation provided by IBM to successfully implement wsadmin commands that will help administrate the entire WebSphere Application Server solution. The session explores how simple techniques using wsadmin and some public documentation can reach a complete administration solution solely with the wsadmin tool and commands. The lab exercise will also review how the WebSphere configuration files correlate to the wsadmin tool commands. Finally, the attendees will experience and learn how to easily migrate the admin console webui functions to a wsadmin script. Lab Requirements List of system and software required for the student to complete the lab. ÷! WebSphere Application Server ND and Base version 5.1.1

Upload: harshad27

Post on 08-Apr-2015

491 views

Category:

Documents


5 download

TRANSCRIPT

© Copyright IBM Corporation 2004 All rights reserved

Oct 4th – 8th IBM Advance wsadmin System Administration – Lab Exercise Page 1 of 26

2004 WebSphere Technical Exchange

IBM WEBSPHERE 5.1.1 wsadmin – LAB EXERCISE

SWG Advance wsadmin System Administration for WebSphere Application Server

What this exercise is about............................................................................................................................1

Lab Requirements .........................................................................................................................................1

What you should be able to do ......................................................................................................................1

Introduction ....................................................................................................................................................2

Exercise Instructions .....................................................................................................................................2

Part 1: The wsadmin Help Management Object............................................................................................3

Part 2: EAR Install Script ...............................................................................................................................5

Part 3: Configure a Performance Manager Infrastructure Service ..............................................................11

Part 4: Federate the BASE Node with wsadmin..........................................................................................15

Part 5: Thread Dumps on Windows! ...........................................................................................................18

What you did in this exercise.......................................................................................................................22

Appendix A: Resources ...............................................................................................................................23

Appendix B: Other Challenge Exercise .......................................................................................................24

NOTE: Education materials and other documentation as applicable including programming manuals, operating guides, physical planning manuals and installation manuals related to the IBM Products may be early versions subject to change. Documents will be furnished solely for the purpose of and for the duration of WebSphere Application Server v5.1.1.

What this exercise is about

The objective of this lab is to provide you with a better understanding of wsadmin because this can be very confusing and complex. This hands-on session demonstrates and allows attendees to learn how to leverage the existing documentation provided by IBM to successfully implement wsadmin commands that will help administrate the entire WebSphere Application Server solution. The session explores how simple techniques using wsadmin and some public documentation can reach a complete administration solution solely with the wsadmin tool and commands. The lab exercise will also review how the WebSphere configuration files correlate to the wsadmin tool commands. Finally, the attendees will experience and learn how to easily migrate the admin console webui functions to a wsadmin script.

Lab Requirements

List of system and software required for the student to complete the lab.

÷! WebSphere Application Server ND and Base version 5.1.1

© Copyright IBM Corporation 2004. All rights reserved

Oct 4th – 8th IBM Advance wsadmin System Administration – Lab Exercise Page 2 of 26

2004 WebSphere Technical Exchange

÷! XML viewer (Notepad, Ultra Edit, etc)

What you should be able to do

At the end of this lab you should be able to:

÷! Increase the user’s comfort level with wsadmin

÷! Advance the wsadmin skill levels with support tricks

÷! Understands the WebSphere configuration files

Introduction

System Administration in WebSphere Application Server v5.1.1 provides a complex commandline tool called wsadmin is fully capable to administrate a WebSphere Application Server cell. The wsadmin command tool can connect to a WebSphere Application Server process for administration of the configuration and processes or locally administrate the configuration. This tool breaks down into three major categories or objects that WebSphere Application Server administration commands are from: AdminApp, AdminConfig and AdminControl. The wsadmin help and IBM documentation, e.g. Information Center, will provide enough information to create the administrative commands.

Exercise Instructions

What you will do:

÷! View WebSphere Application Server configuration files

÷! Execute administrative commands in wsadmin

÷! Federate the node into the Deployment Manager

© Copyright IBM Corporation 2004. All rights reserved

Oct 4th – 8th IBM Advance wsadmin System Administration – Lab Exercise Page 3 of 26

2004 WebSphere Technical Exchange

Part 1: The wsadmin Help Management Object

____ 1. Start WebSphere Application Server v5.1.1 default application server, server1.

__ a. In a command prompt window, make C:\WebSphere\AppServer\bin the current directory and run the following command:

startServer server1

____ 2. Open a wsadmin command session to administrate the BASE application server.

__ a. In a command prompt window, make C:\WebSphere\AppServer\bin the current directory and run the following command:

wsadmin

c:\WebSphere\AppServer\bin>wsadmin WASX7209I: Connected to process "server1" on node WSTNT using SOAP connect or; The type of process is: UnManagedProcess WASX7029I: For help, enter: "$Help help" wsadmin>

NOTE: Starting with no input parameters does not mean wsadmin starts with zero options. The script by default uses a properties file, wsadmin.properties, located in <WAS_HOME>/properties directory.

____ 3. Learn more about the Help management Object.

__ a. In the wsadmin command session, execute the following command to learn from wsadmin about the Help management Object:

$Help help

wsadmin>$Help help WASX7028I: The Help object has two purposes: First, provide general help information for the objects supplied by wsadmin for scripting: Help, AdminApp, AdminConfig, and AdminControl. Second, provide a means to obtain interface information about MBeans running in the system. For this purpose, a variety of commands are available to get information about the operations, attributes, and other interface information about particular MBeans. The following commands are supported by Help; more detailed information about each of these commands is available by using the "help" command of Help and supplying the name of the command as an argument. attributes given an MBean, returns help for attributes ... wsadmin returns general help text for the wsadmin script launcher

© Copyright IBM Corporation 2004. All rights reserved

Oct 4th – 8th IBM Advance wsadmin System Administration – Lab Exercise Page 4 of 26

2004 WebSphere Technical Exchange

message given a message id, returns explanation and user action message

____ 4. Save command pushes wsadmin session configuration changes into the WebSphere Application Server environment. How can we use this in wsadmin?

__ a. From the previous step, wsadmin Help management object provides helpful information for the user to learn about the wsadmin objects. Lets review all the methods for the three major objects to administrate wsadmin. In the wsadmin command session, execute the following commands for each object:

$AdminApp help

$AdminConfig help

$AdminApp help

__ b. There is a “save” method for the $AdminConfig object commits changes to the WebSphere Application Server configuration. Executing the following command in the wsadmin command session:

$AdminConfig help save

wsadmin>$AdminConfig help save WASX7124I: Method: save Arguments: none Description: Commits unsaved changes to the configuration repository

____ 5. Exit the wsadmin session completing the exercise.

__ a. From the wsadmin session, execute the following command:

exit

© Copyright IBM Corporation 2004. All rights reserved

Oct 4th – 8th IBM Advance wsadmin System Administration – Lab Exercise Page 5 of 26

2004 WebSphere Technical Exchange

Part 2: EAR Install Script

Learn the tricks WebSphere Application Server support uses to create/valid complex install and edit wsadmin commands quickly and correctly.

NOTE: The WebSphere Application Server server1 should be running.

____ 1. Enable wsadmin tracing.

__ a. Open the wsadmin.properties file in a text editor.

1) Start Notepad program. Use the Windows main menu to start: Choose "Start" -> "Programs" -> "Accessories", then select "Notepad".

2) Inside Notepad, choose the "File" menu and select "Open..."

3) Inside the “Open” window change the "Files of type:" from "Text Documents (*.txt)" to "All Files"

4) Navigate though the directories to "C:\WebSphere\AppServer\properties" directory and select "wsadmin.properties" file

5) Press the "Open" button

__ b. Uncomment the “com.ibm.ws.scripting.traceString=com.ibm.*=all=enabled” line inside the properties file to enable tracing. Remove the pound sign, “#”, from the start of the line. Now the line change from:

#com.ibm.ws.scripting.traceString=com.ibm.*=all=enabled

to:

com.ibm.ws.scripting.traceString=com.ibm.*=all=enabled

__ c. Save changes to the file and close. Inside Notepad, choose the “File” menu and select “Save”. Then close the Notepad window.

____ 2. Open a wsadmin command session to administrate the BASE application server.

__ a. In a command prompt window, make C:\WebSphere\AppServer\bin the current directory and run the following command:

wsadmin

____ 3. Interactively install the ivtApp enterprise application changing the “IVT Application” web module virtual host mapping from “default_host” to “admin_host” and “IVT Application” ejb module JNDI name from “ivt/ivtEJBHome” to “test/jndi”:

__ a. Find the method to interactively install an ear file.

1) Use the help command on the AdminApp object to find the installInteractive method. Execute the following command in wsadmin session:

$AdminApp help

2) Verify and learn how to use the installInteractive method by executing the following command:

© Copyright IBM Corporation 2004. All rights reserved

Oct 4th – 8th IBM Advance wsadmin System Administration – Lab Exercise Page 6 of 26

2004 WebSphere Technical Exchange

$AdminApp help installInteractive

wsadmin>$AdminApp help installInteractive WASX7097I: Method: installInteractive Arguments: filename, options Description: Installs the application in the file specified by "filename" using the options specified by "options." The user is prompted for information about each relevant task. The AdminApp "options" command may be used to get a list of all possible options for a given ear file. The AdminApp "help" command may be used to get more information about each particular option. Method: installInteractive Arguments: filename Description: Installs the application specified by "filename" using default options. The user is prompted for information about each relevant task.

__ b. In wsadmin session, execute the following command to start install Interactive mode on the ivtApp.ear:

$AdminApp installInteractive C:/WebSphere/AppServer/installableApps/ivtApp.ear

NOTE: wsadmin is a java process and backslash, “\”, is an escape character. Therefore, Windows paths to files have to be modified to either change the backslash to a forwardslash, “/”, or use two backslashs.

__ c. Change the virtual host from “default_host” to “admin_host” and “IVT Application” ejb module JNDI name from “ivt/ivtEJBHome” to “test/jndi”.

1) Leave default settings for options by pressing the “Enter” key until we find “IVT Application” module “JNDI name” and “Virtual Host” options.

NOTE: The default setting for the installInteractive for the ear file can be found between the brackets, “[“ and “]”.

2) Once we get to “IVT Application” ejb module “JNDI name” option, change the setting by executing the following command inside the Interactive install command:

test/jndi <Enter>

Task[6]: Mapping EJB References to Enterprise Beans Each EJB reference defined in your application must be mapped to an Enterprise b ean. Module: IVT Application

© Copyright IBM Corporation 2004. All rights reserved

Oct 4th – 8th IBM Advance wsadmin System Administration – Lab Exercise Page 7 of 26

2004 WebSphere Technical Exchange

EJB: URI: ivt_app.war,WEB-INF/web.xml Reference Binding: ivt/ivtEJBObject Class: com.ibm.websphere.ivt.ivtEJB.ivtEJBObject JNDI Name: [ivt/ivtEJBHome]: test/jndi Setting "JNDI Name" to "test/jndi"

3) Once we get to the “IVT Application” web module “Virtual Host” option, this is the next option, change the default setting when executing the following command:

admin_host <Enter>

Task[13]: Selecting Virtual Hosts for Web Modules Specify the virtual host where you want to install the Web modules contained in your application. Web modules can be installed on the same virtual host or dispe rsed among several hosts. Web Module: IVT Application URI: ivt_app.war,WEB-INF/web.xml Virtual Host: [default_host]: admin_host Setting "Virtual Host" to "admin_host"

____ 4. Exit the wsadmin session without saving. This will cause wsasdmin to NOT push the configuration changes into the repository.

__ a. From the wsadmin session, execute the following command twice:

exit <enter>

exit

wsadmin>exit WASX7118I: Changes have been made to the configuration, but these changes have n ot been saved. Enter "quit" or "exit" if you want to terminate this session without saving your changes. To save the changes, invoke the "save" command on the AdminConfig object. wsadmin>exit WASX7341W: No "save" was performed before the interactive scripting session exit ed; configuration changes will not be saved. c:\WebSphere\AppServer\bin>

NOTE: The need to execute the exit command twice is because we don’t want to save changes, but wsadmin provides a warning about configuration changes NOT saved.

____ 5. Create a single wsadmin install command to complete the ivtApp enterprise application modifying the “IVT Application” module’s virtual host to admin_host and JNDI name as test/jndi.

© Copyright IBM Corporation 2004. All rights reserved

Oct 4th – 8th IBM Advance wsadmin System Administration – Lab Exercise Page 8 of 26

2004 WebSphere Technical Exchange

__ a. Review the wsadmin trace file, wsadmin.traceout located in the C:\WebSphere\AppServer\logs directory, searching for the “WASX7278I” inside the trace.

[8/10/04 0:05:02:234 EDT] 3c656700 AdminAppClien A WASX7278I: Generated command line: install C:/WebSphere/AppServer/installableApps/ivtApp.ear { -MapEJBRefToEJB {{"IVT Application" "" ivt_app.war,WEB-INF/web.xml ivt/ivtEJBObject com.ibm.websphere.ivt.ivtEJB.ivtEJBObject test/jndi}} -MapWebModToVH {{"IVT Application" ivt_app.war,WEB-INF/web.xml admin_host}}}

NOTE: Every time wsadmin session is started, the wsadmin output file will be overwritten.

__ b. Create the single wsadmin install command by copying the information starting at “install” until the end of the trace line and pre-append “$AdminApp” shown below:

$AdminApp install C:/WebSphere/AppServer/installableApps/ivtApp.ear { -MapEJBRefToEJB {{"IVT Application" "" ivt_app.war,WEB-INF/web.xml ivt/ivtEJBObject com.ibm.websphere.ivt.ivtEJB.ivtEJBObject test/jndi}} -MapWebModToVH {{"IVT Application" ivt_app.war,WEB-INF/web.xml admin_host}}}

____ 6. Create a script to install the “IVT Application” enterprise application into the BASE server.

__ a. Create the script file called “test.jacl” in a text editor. This script will contain the single command to install the ear file and then a save command.

1) Start Notepad program. Use the Windows main menu to start: Choose "Start" -> "Programs" -> "Accessories", then select "Notepad".

2) Inside Notepad, enter the single wsadmin command, created in step 5.b.

3) Inside Notepad, on the following line, save the command to the configuration by typing the following command:

$AdminConfig save

$AdminApp install C:/WebSphere/AppServer/installableApps/ivtApp.ear { -MapEJBRefToEJB {{"IVT Application" "" ivt_app.war,WEB-INF/web.xml ivt/ivtEJBObject com.ibm.websphere.ivt.ivtEJB.ivtEJBObject test/jndi}} -MapWebModToVH {{"IVT Application" ivt_app.war,WEB-INF/web.xml admin_host}}} $AdminConfig save

NOTE: You add the save command to the end of the script file because when executing a script, wsadmin does not assume to save the session information.

4) Inside Notepad, choose the "File" menu and select "Save"

5) Inside the “Save As” window change the "Save as type:" from "Text Documents (*.txt)" to "All Files"

© Copyright IBM Corporation 2004. All rights reserved

Oct 4th – 8th IBM Advance wsadmin System Administration – Lab Exercise Page 9 of 26

2004 WebSphere Technical Exchange

6) Navigate though the directories to "C:\WebSphere\AppServer\bin" directory and type in the “File name” the following:

test.jacl

7) Press the "Save" button

__ b. Execute the test.jacl script in wsadmin to install the “IVT Application” enterprise application. In a command prompt window, make C:\WebSphere\AppServer\bin the current directory and run the following command:

wsadmin –f test.jacl

C:\WebSphere\AppServer\bin>wsadmin -f test.jacl WASX7209I: Connected to process "server1" on node WSTNT using SOAP connector; The type of process is: UnManagedProcess ADMA0080W: A template policy file without any permission set is included in the … ADMA5011I: Cleanup of temp dir for app IVT Application done. ADMA5013I: Application IVT Application installed successfully. C:\WebSphere\AppServer\bin>

____ 7. Verify the “IVT Application” installed.

__ a. Open the admin console by opening a web browser and changing the address, url, to the following:

http://localhost:9091/admin

__ b. Log into the admin console and navigate through to left topology frame expanding the “Applications” and selecting “Enterprise Applications”. The main frame in the admin console will now list all the enterprise applications installed to the BASE cell.

© Copyright IBM Corporation 2004. All rights reserved

Oct 4th – 8th IBM Advance wsadmin System Administration – Lab Exercise Page 10 of 26

2004 WebSphere Technical Exchange

© Copyright IBM Corporation 2004. All rights reserved

Oct 4th – 8th IBM Advance wsadmin System Administration – Lab Exercise Page 11 of 26

2004 WebSphere Technical Exchange

Part 3: Configure a Performance Manager Infrastructure Service

The exercise is interested in configuring a Performance Manager Infrastructure (PMI) service on server1. The server collects PMI data that consists of counters such as servlet response time and data connection pool usage used to tune the server for better performance. You can set the level of monitor to N, L, M, H or X (none, low, medium, high and maximum) per component.

The first major step focuses on retrieving the config ID to the object. The second phase is modifying the PMI options. For this exercise we are going to enable PMI and set webAppModule to high. Then the last step will be saving the configuration changes to the repository.

____ 1. Start a local wsadmin session.

__ a. A wsadmin local session mean the command tool does not connect to a running WebSphere Application Server process. To start a wsadmin session changing the settings requires the use of “-conntype” option. Executing the following command will achieve a local wsadmin session:

wsadmin –conntype NONE

C:\WebSphere\AppServer\bin>wsadmin -conntype NONE WASX7357I: By request, this scripting client is not connected to any server proc ess. Certain configuration and application operations will be available in local mode. WASX7029I: For help, enter: "$Help help" wsadmin>

____ 2. Determine the Performance Manager Infrastructure object and the options.

__ a. All objects that are shown in the admin console or read in some documentation about WebSphere Application Server can be mapped to a WebSphere type. In the wsadmin session, review the WebSphere Application Server type by executing the following command:

$AdminConfig types

wsadmin>$AdminConfig types AdminService Agent AllAuthenticatedUsersExt … OutputRedirect PMIRMFilter PMIRMFilterValue PMIRequestMetrics PMIService ProcessDef … WebModuleDeployment WorkloadManagementServer wsadmin>

© Copyright IBM Corporation 2004. All rights reserved

Oct 4th – 8th IBM Advance wsadmin System Administration – Lab Exercise Page 12 of 26

2004 WebSphere Technical Exchange

__ b. From the previous command there are multiple types with PMI in the name. Review the attributes for these type and making an educated choice, it can be determined the “PMIService” type is correct object to modify. Executing the following command will show attributes for this object:

$AdminConfig attributes PMIService

wsadmin>$AdminConfig attributes PMIService "context ServiceContext@" "enable boolean" "initialSpecLevel String" "properties Property(TypedProperty)*" wsadmin>

NOTE: If you were to review the WebSphere Application Server configuration files, they are xml files allowing users to easily review, we can see the following entry in the server.xml file for server1 located in C:\WebSphere\AppServer\config\cells\WSTNT\nodes\WSTNT\servers\server1 directory:

<services xmi:type="pmiservice:PMIService" xmi:id="PMIService_1" enable="false" initialSpecLevel=""/>

The above entry shows the type PMIService, which validates the educated choice in the WebSphere Application Server type in step 2.b.

____ 3. Obtain the config ID for the PMI service for server1. There are many methods to retrieve a config ID in wsadmin. This step will show the two most popular methods used by clients.

NOTE: A config ID is a pointer to the specific object that wsadmin user's want to create, edit or view the configuration. Wsadmin represents these ids with the display name first, not all types have a display name, followed by the configuration data ID in parenthesis. Below is an example of a wsadmin config ID: server1(cells/WSTNTNetwork/nodes/WSTNT/servers/server1:server.xml#Server_1).

The exact outline for the config ID is “<display name>(config path:filename#id)”. This directly correlates to the configuration xml files in WebSphere located in the <WAS_HOME>/config directory. The “config path” and the “filename” are the specific location, the exact path based off the config directory, and file where the pointer associates to the WebSphere configuration. The “id” and “display name” are actually the “name=” and “xmi:id=” xml parameters found inside the referenced file. From the initial config id example, this represents the server.xml file for server1 located in C:\WebSphere\AppServer\config\cell\WSTNT\nodes\WSTNT\servers\server1 directory where the following entry is found inside this file:

<process:Server ...Other information... xmi:id="Server_1" name="server1">

__ a. First, we will retrieve the server1 config ID using the “getid” method. In the wsadmin session, execute the following command:

set server [$AdminConfig getid /Node: WSTNT/Server:server1/]

wsadmin>set server [$AdminConfig getid /Node: WSTNT/Server:server1/] server1(cells/WSTNT/nodes/WSTNT/servers/server1:server.xml#Server_1) wsadmin>

© Copyright IBM Corporation 2004. All rights reserved

Oct 4th – 8th IBM Advance wsadmin System Administration – Lab Exercise Page 13 of 26

2004 WebSphere Technical Exchange

NOTE: When executing this command, the return object is the WebSphere Application Server config ID. As initially noted, we can see the config ID, above, mapping to the actual XML config information in the server.xml file for server1 located in C:\WebSphere\AppServer\config\cells\WSTNT\nodes\WSTNT\servers\server1 directory:

<process:Server xmi:version="2.0" … xmi:id="Server_1" name="server1">

If nothing is returned after executing the getid command, then wsadmin cannot find a config ID for the specific containment path. Also the “set server” command is a jacl command to store variables to be used later.

__ b. Second, we will retrieve the PMIService config ID for server1 using the “list” method.

set pmi [$AdminConfig list PMIService $server]

wsadmin>set pmi [$AdminConfig list PMIService $server] (cells/WSTNT/nodes/WSTNT/servers/server1:server.xml#PMIService_1) wsadmin>

NOTE: The config ID for PMIService could have been retrieved in a single more complex containment path for the getid method, i.e. “$AdminConfig getid /Node:WSTNT/Server:server1/PMIService:/”.

____ 4. Modify the PMI service for server1 to enable and set webAppModule to high.

__ a. Use wsadmin Help management object to understand how to use the modify command to

$AdminConfig help modify

wsadmin>$AdminConfig help modify WASX7058I: Method: modify Arguments: config id, attributes Description: Changes the attributes specified by "attributes" for the configuration object named by "config id." wsadmin>

NOTE: Above is the output from wsadmin where the modify command only accepts two arguments, config ID and attributes. Remember wsadmin using the jacl language understands each argument ends when a space is found and the use of brackets around an object that requires a space will bypass the logic. Because each attribute requires spaces, the use of brackets around the object pair are needed, and then around the collection of attributes to represent the single attributes argument for the “modify” command.

__ b. The final command to execute allowing wsadmin to modify the PMI service is shown below:

$AdminConfig modify $pmi {{enable true} {initialSpecLevel webAppModule=H}}

© Copyright IBM Corporation 2004. All rights reserved

Oct 4th – 8th IBM Advance wsadmin System Administration – Lab Exercise Page 14 of 26

2004 WebSphere Technical Exchange

NOTE: This command does not return anything except errors if this fails to work. Common error message is an invalid attribute. The following error will be throw for this case:

WASX7080E: Invalid attributes specified for type "PMIService" --<bad attribute>

____ 5. Save the configuration change to the

__ a. In wsadmin session execute the following command:

$AdminConfig save

NOTE: The final results from this exercise can be seen in the repository. The following entry in the server.xml file for server1 located in C:\WebSphere\AppServer\config\cells\WSTNT\nodes\WSTNT\servers\server1 directory proves we enabled and set the webAppModule to high:

<services xmi:type="pmiservice:PMIService" xmi:id="PMIService_1" enable="true" initialSpecLevel="webAppModule=H"/>

© Copyright IBM Corporation 2004. All rights reserved

Oct 4th – 8th IBM Advance wsadmin System Administration – Lab Exercise Page 15 of 26

2004 WebSphere Technical Exchange

Part 4: Federate the BASE Node with wsadmin

____ 1. Start WebSphere Application Server v5.1.1 default application server, server1.

__ a. In a command prompt window, make C:\WebSphere\AppServer\bin the current directory and run the following command:

startServer server1

____ 2. Start WebSphere Application Server Network Deployment v5.1.1 manager server, dmgr.

__ a. In a command prompt window, make C:\WebSphere\DeploymentManager\bin the current directory and run the following command:

startManager

NOTE: You can use the startServer script to also start the dmgr process, i.e. startServer dmgr.

____ 3. Start wsadmin connected to BASE application server, server1, and determine the appropriate MBean to federate the BASE server.

__ a. Reviewing all the MBeans in WebSphere Application Server to determine the MBean type that will federate the BASE install. Opening the index.html file for the MBeans located in the WebSphere Application Server install mbeanDocs directory located in the C:\WebSphere\AppServer\ web directory.

© Copyright IBM Corporation 2004. All rights reserved

Oct 4th – 8th IBM Advance wsadmin System Administration – Lab Exercise Page 16 of 26

2004 WebSphere Technical Exchange

__ b. Set a variable, “adminMBean”, to the AdminOperations MBean with the following command:

set adminMBean [$AdminControl queryNames type=AdminOperations,*]

NOTE: You can use wsadmin Help management object to obtain the MBean information. Executing the following commands: $Help description $adminMBean $Help operations $adminMBean

____ 4. Federate the BASE install to the ND install and keep the enterprise applications.

__ a. Learn the syntax to invoke the MBean method using the help command. In the wsadmin session, execute the following command:

$AdminControl help invoke

wsadmin>$AdminControl help invoke WASX7047I: Method: invoke Arguments: object name, operation Description: Invoke the operation named by "operation" on the MBean described by "object name." No arguments are passed for the operation. Method: invoke Arguments: object name, operation, arguments Description: Invoke the operation named by "operation" on the MBean described by "object name" using the parameters described by "arguments." If no arguments are required for this operation, the "arguments" parameter may be omitted. Method: invoke Arguments: object name, operation, arguments, signature Description: Invoke the operation named by "operation" on the MBean described by "object name" using the parameters described by "arguments" and the signatures described by "signature."

__ b. Invoke the MBean’s “addNodeWithOptions” method with the “-includeapps” option. The “-includeapps” option is used because to retain the enterprise applications installed on the BASE install. If this option is not used and we want to use the ear file in the Network Deployment cell, this requires us to reinstall the ear files to application server on BASE. Execute the following command in the wsadmin session:

$AdminControl invoke $adminMBean addNodeWithOptions {{<host>} {8879} {-includeapps}}

____ 5. Exit the wsadmin session completing the exercise.

© Copyright IBM Corporation 2004. All rights reserved

Oct 4th – 8th IBM Advance wsadmin System Administration – Lab Exercise Page 17 of 26

2004 WebSphere Technical Exchange

__ a. From the wsadmin session, execute the following command:

exit

____ 6. Verify that the BASE install federated to the ND.

__ a. Open the admin console and view the list of “Nodes”. Navigate through to left topology frame expanding the “System Administration” and selecting “Nodes”. The main frame in the admin console will now list the nodes federated to the ND cell.

NOTE: You will see “WSTNTManager” listed as a node. This represents the Deployment manager node.

© Copyright IBM Corporation 2004. All rights reserved

Oct 4th – 8th IBM Advance wsadmin System Administration – Lab Exercise Page 18 of 26

2004 WebSphere Technical Exchange

Part 5: Thread Dumps on Windows!

Yes, we are going to create thread dumps on Windows operating system. WebSphere Application Server provided built-in capability to create thread dump files, javacore.<data>.<time>.<pid>.txt, that contain a single snapshot of the java information for a specific process. This allows us to create scripts, platform independent, to dump the thread running in the java process and debug java thread issues. The JMX MBean that provides us this ability is the JVM type. Review the MBean documents, located in C:\WebSphere\AppServer\web\mbeanDocs directory or Information Center, for the JVM type we see a method call “dumpThreads” that allows a WebSphere Application Server process to produce a thread dump. Note: not all operating systems create a separate file to contain the thread dumps, e.g. Solaris places thread dumps in the native log.

NOTE: The WebSphere Application Server dmgr and NodeAgent should be running.

____ 1. Create a script to dump the threads for a WebSphere Application Server NodeAgent process.

__ a. Create the script file called “test2.jacl” in a text editor. This script will retrieve the NodeAgent JVM MBean and execute a method called “dumpThreads”.

1) Start Notepad program. Use the Windows main menu to start: Choose "Start" -> "Programs" -> "Accessories", then select "Notepad".

2) Inside Notepad, enter a command setting variable “jvm” to the NodeAgent “JVM” MBean using the “completeObjectName” function to retrieve an MBean. The following command will do this:

set jvm [$AdminControl queryNames type=JVM,process=nodeagent,*]

3) Inside Notepad, on the following line, execute the “JVM” MBean “dumpThreads” method to create a thread dump for that java process by typing the following command:

$AdminControl invoke $jvm dumpThreads

set jvm [$AdminControl queryNames type=JVM,process=nodeagent,*] $AdminControl invoke $jvm dumpThreads

NOTE: The dumpThreads MBean does not require any parameters, therefore we don’t provide any other parameters for the wsadmin “invoke” function.

4) Inside Notepad, choose the "File" menu and select "Save"

5) Inside the “Save As” window change the "Save as type:" from "Text Documents (*.txt)" to "All Files"

6) Navigate though the directories to "C:\WebSphere\DeploymentManager\bin" directory and type in the “File name” the following:

test2.jacl

7) Press the "Save" button

© Copyright IBM Corporation 2004. All rights reserved

Oct 4th – 8th IBM Advance wsadmin System Administration – Lab Exercise Page 19 of 26

2004 WebSphere Technical Exchange

____ 2. Execute the test2.jacl script using the Deployment Manager wsadmin script connecting to the dmgr and then the NodeAgent process. Then review the resulting thread dumps.

__ a. Executing the “test2.jacl” connecting to the dmgr. In a command prompt window, make C:\WebSphere\DeploymentManager\bin the current directory and run the following command:

wsadmin –f test2.jacl

__ b. Executing the “test2.jacl” connecting to the NodeAgent. In a command prompt window, make C:\WebSphere\DeploymentManager\bin the current directory and run the following command:

wsadmin –port 8878 –f test2.jacl

NOTE: We add the “-port” option to overwrite the default wsadmin properties, connecting to the dmgr process, to change the port number for the NodeAgent SOAP port. We don’t need to provide the host option because the NodeAgent runs on the same machine as dmgr, using the same host name.

__ c. Review the results, look in the C:\WebSphere\AppServer directory, after we executed the wsadmin script connected to different processes. We find two javacore files for the NodeAgent process. We achieved the goal of creating NodeAgent thread dumps connecting to either dmgr or NodeAgent process.

____ 3. Why does the script have the “process=nodeagent” when we retrieve the NodeAgent JVM MBean? Lets remove the string from the script and execute step 2 again.

__ a. Open the test2.jacl file in a text editor and remove the “process=nodeagent” from the files.

1) Start Notepad program. Use the Windows main menu to start: Choose "Start" -> "Programs" -> "Accessories", then select "Notepad".

2) Inside Notepad, choose the "File" menu and select "Open..."

3) Inside the “Open” window change the "Files of type:" from "Text Documents (*.txt)" to "All Files"

4) Navigate though the directories to "C:\WebSphere\DeploymentManager\bin" directory and select "test2.jacl" file

5) Press the "Open" button

6) In Notepad, modify the “set jvm [$AdminControl queryNames type=JVM,process=nodeagent,*]” line to remove the “process=nodeagent” to leave the line as so:

set jvm [$AdminControl queryNames type=JVM,*]

set jvm [$AdminControl queryNames type=JVM,*] $AdminControl invoke $jvm dumpThreads

7) Inside Notepad, choose the "File" menu and select "Save"

__ b. Executing the “test2.jacl” connecting to the dmgr. In a command prompt window, make C:\WebSphere\DeploymentManager\bin the current directory and run the following command:

© Copyright IBM Corporation 2004. All rights reserved

Oct 4th – 8th IBM Advance wsadmin System Administration – Lab Exercise Page 20 of 26

2004 WebSphere Technical Exchange

wsadmin –f test2.jacl

C:\WebSphere\DeploymentManager\bin>wsadmin -f test.jacl WASX7209I: Connected to process "dmgr" on node WSTNTManager using SOAP connector; The type of process is: DeploymentManager WASX7017E: Exception received while running file "C:\WebSphere\AppServer\bin\te st.jacl"; exception information: com.ibm.ws.scripting.ScriptingException: WA SX7025E: Error found in String "WebSphere:platform=common,cell=WSTNTNetwork,versio n=5.0.1,name=JVM,mbeanIdentifier=JVM,type=JVM,node=WSTNT,process=node agent WebSphere:platform=common,cell=WSTNTNetwork,version=5.0.1,name=JVM,mbeanIden tifier=JVM,type=JVM,node=WSTNTManager,process=dmgr"; cannot create ObjectName. C:\WebSphere\DeploymentManager\bin>

NOTE: The WebSphere Application Server processes have a hierarchy, dmgr -> NodeAgent -> managed process, where the MBeans can only administrate themselves or processes below. All WebSphere Application Server processes are java processes, therefore, they have a JVM MBean. The new queryNames command retrieves two “JVM” MBeans, dmgr and NodeAgent, because both match the search string.

__ c. Executing the “test2.jacl” connecting to the NodeAgent. In a command prompt window, make C:\WebSphere\DeploymentManager\bin the current directory and run the following command:

wsadmin –port 8878 –f test2.jacl

__ d. Review the results, look in the C:\WebSphere\AppServer directory, after we executed the wsadmin script connecting to different processes. We find one new javacore file for the NodeAgent process. The wsadmin command connected to the dmgr process fails, WASX7017E, because there are two MBeans that are mapped to variable “jvm” and wsadmin “invoke” cannot execute against two MBeans.

____ 4. What happens if we change the wsadmin function queryNames to completeObjectName for the test2.jacl script. Lets change the function in the script and execute step 2 again.

__ a. Open the test2.jacl file in a text editor and remove the “process=nodeagent” from the files.

1) Start Notepad program. Use the Windows main menu to start: Choose "Start" -> "Programs" -> "Accessories", then select "Notepad".

2) Inside Notepad, choose the "File" menu and select "Open..."

3) Inside the “Open” window change the "Files of type:" from "Text Documents (*.txt)" to "All Files"

4) Navigate though the directories to "C:\WebSphere\DeploymentManager\bin" directory and select "test2.jacl" file

5) Press the "Open" button

© Copyright IBM Corporation 2004. All rights reserved

Oct 4th – 8th IBM Advance wsadmin System Administration – Lab Exercise Page 21 of 26

2004 WebSphere Technical Exchange

6) In Notepad, modify the “set jvm [$AdminControl queryNames type=JVM,process=nodeagent,*]” line to remove the “process=nodeagent” to leave the line as so:

set jvm [$AdminControl completeObjectName type=JVM,*]

set jvm [$AdminControl completeObjectName type=JVM,*] $AdminControl invoke $jvm dumpThreads

7) Inside Notepad, choose the "File" menu and select "Save"

__ b. Executing the “test2.jacl” connecting to the dmgr. In a command prompt window, make C:\WebSphere\DeploymentManager\bin the current directory and run the following command:

wsadmin –f test2.jacl

C:\WebSphere\DeploymentManager\bin>wsadmin -f test.jacl WASX7209I: Connected to process "dmgr" on node WSTNTManager using SOAP connector; The type of process is: DeploymentManager WASX7026W: String "type=JVM,*" corresponds to 2 different MBeans; returning firs t one. C:\WebSphere\DeploymentManager\bin>

__ c. Executing the “test2.jacl” connecting to the NodeAgent. In a command prompt window, make C:\WebSphere\DeploymentManager\bin the current directory and run the following command:

wsadmin –port 8878 –f test2.jacl

__ d. Review the results, look in the C:\WebSphere\AppServer directory, after we executed the wsadmin script connected to different processes. We find one new javacore file for the NodeAgent process. The wsadmin command connected to the dmgr process completed for this step, but with a warning, WASX7026W, that notes the two MBeans found and sets the “jvm” variable to the first MBean. What happened then? If we review the C:\WebSphere\DeploymentManager directory we will find a javacore file. This thread dump file is for the dmgr process. Therefore, the script works in both cases because the completeObjectName only sets the variable to a single MBean allowing the script to complete. Just the script is not predictable because the search string is too vague.

© Copyright IBM Corporation 2004. All rights reserved

Oct 4th – 8th IBM Advance wsadmin System Administration – Lab Exercise Page 22 of 26

2004 WebSphere Technical Exchange

What you did in this exercise

From part one, you learned about the wadmin built-in Help management object. You saw how to properly use the help commands to learn more about the different wsadmin methods. This shows a detailed description and how the method can be used, required arguments.

From part two, you learned how to form complex ear install and edit commands for wsadmin. You saw the tricks WebSphere Application Server support uses to verify the options and that the final command is valid. The wsadmin trace file, wsadmin.traceout, prints the valid single wsadmin command. Then you created a simple script file to automate the wsadmin install command. Note, you also learned how to start debugging problems with wsadmin by enabling the wsadmin tracing.

From part three, you learned about retrieving and modifying the WebSphere Application Server repository config files. The mapping between the wsadmin config ID and the actually xml tags in the config files was drawn out in this exercise. Now you can better convert more admin console clicks into commandline commands. You saw a glimpse of jacl commands and how the brackets are important to use properly. Also, you saw that wsadmin running in local mode, not connected to any WebSphere Application Server process, can still modify the local configuration. This allows the client to fix issues with the repository using an administrative tool if the server does not start.

From part four, you learned another way to federate a BASE install to a ND install. You saw how to invoke methods on public WebSphere Application Server JMX MBeans. Also you saw documentation IBM provides to help explain the JMX MBean running in the WebSphere Application Server processes.

From part five, you learned how to take platform independent java thread dumps for a WebSphere Application Server process. You saw how connecting to the different processes show can show different MBeans based on hierarchy. Last, if the search string it too general might work fine in one environment, but produce different/unpredictable results on others.

© Copyright IBM Corporation 2004. All rights reserved

Oct 4th – 8th IBM Advance wsadmin System Administration – Lab Exercise Page 23 of 26

2004 WebSphere Technical Exchange

Appendix A: Resources

General Links:

÷! Information Centers:

o WebSphere Application Server 5.0

http://publib.boulder.ibm.com/infocenter/wasinfo/index.jsp?deployment=ApplicationServer

o WebSphere Application Server 5.1

http://publib.boulder.ibm.com/infocenter/ws51help/index.jsp

÷! WebSphere Application Server Support Page:

http://www-306.ibm.com/software/webservers/appserv/was/support/

÷! Developer Domain:

http://www-136.ibm.com/developerworks/websphere/

Specific Links:

÷! Basic WebSphere Application Server V5.x Wsadmin Programmers Guide

http://www-1.ibm.com/support/docview.wss?rs=180&context=SSEQTP&uid=swg27005325

÷! Redbook - IBM WebSphere Application Server V5.1 System Management and Configuration WebSphere Handbook Series

http://www-1.ibm.com/support/docview.wss?rs=180&context=SSEQTP&uid=rdb1sg24619501

÷! Redbook - Migrating to WebSphere V5.0 An End-to-End Migration Guide

http://www-1.ibm.com/support/docview.wss?rs=180&context=SSEQTP&uid=rdb1sg24691001

÷! Tcl Developer Xchange

http://www.tcl.tk/

NOTE: The Redbooks and Developer Domain material are not support by IBM. Information inside these resources are extremely helpful, but can be incorrect. Please consult with the Information Center and WebSphere Application Server Support Site if you run into a problem using the other sites.

© Copyright IBM Corporation 2004. All rights reserved

Oct 4th – 8th IBM Advance wsadmin System Administration – Lab Exercise Page 24 of 26

2004 WebSphere Technical Exchange

Appendix B: Other Challenge Exercise

Changing the WAR classloader Settings

This challenge modifies the web module for the “IVT Application” enterprise application to set the classloader to “PARENT_LAST”.

NOTE: This challenge assumes that the “IVT Application” enterprise application from part two is installed. The final result for this challenge is to change the repository configuration for the Web Module to:

<modules xmi:type="appdeployment:WebModuleDeployment" xmi:id="WebModuleDeployment_1092167686656" deploymentId="1" startingWeight="10000" uri="ivt_app.war" classloaderMode="PARENT_LAST">

The following entry can be found in the deployment.xml file for “IVT Application” located in "C:\WebSphere\AppServer\config\cells\mother2211\applications\IVT Application.ear\deployments\IVT Application" directory.

____ 1. Start a local wsadmin session.

__ a. A wsadmin local session mean the command tool does not connect to a running WebSphere Application Server process. To start a wsadmin session changing the settings requires the use of “-conntype” option. Executing the following command will achieve a local wsadmin session:

wsadmin –conntype NONE

____ 2. Obtain the config ID for the “IVT Application” Web Module. This step is going to use a different method call to find the correct config ID.

__ a. In wsadmin session, execute the following command to get the config ID for the “IVT Application” enterprise application:

set a [$AdminConfig getid {/Deployment:IVT Application/}]

wsadmin>set a [$AdminConfig getid {/Deployment:IVT Application/}] "IVT Application(cells/WSTNT/applications/IVT Application.ear/deployments/I VT Application:deployment.xml#Deployment_1092167686656)" wsadmin>

NOTE: The brackets around the containment path are used because the application name has a space.

__ b. Execute the following command to zero in on the modules inside the “IVT Application”:

set b [$AdminConfig showAttribute $a deployedObject]

wsadmin>set b [$AdminConfig showAttribute $a deployedObject] "(cells/WSTNT/applications/IVT Application.ear/deployments/IVT Application: deployment.xml#ApplicationDeployment_1092167686656)" wsadmin>

© Copyright IBM Corporation 2004. All rights reserved

Oct 4th – 8th IBM Advance wsadmin System Administration – Lab Exercise Page 25 of 26

2004 WebSphere Technical Exchange

__ c. Execute the following command to list all the modules inside the application:

set modulelist [lindex [$AdminConfig showAttribute $b modules] 0]

wsadmin>set modulelist [lindex [$AdminConfig showAttribute $b modules] 0] "(cells/WSTNT/applications/IVT Application.ear/deployments/IVT Application: deployment.xml#WebModuleDeployment_1092167686656)" "(cells/WSTNT/applicatio ns/IVT Application.ear/deployments/IVT Application:deployment.xml#EJBModuleDeplo yment_1092167686656)" wsadmin>

NOTE: The “lindex” is a jacl command to properly create a variable “modulelist” as a list of module config IDs for the “IVT Application” enterprise application.

__ d. Execute the following command to get the config ID for “IVT Application” web module:

set d [lindex $modulelist 0]

wsadmin>set d [lindex $modulelist 0] (cells/WSTNT/applications/IVT Application.ear/deployments/IVT Application:d eployment.xml#WebModuleDeployment_1092167686656) wsadmin>

NOTE: This step is purely a jacl command to pull out the web module config ID from the jacl list.

____ 3. Modify the “IVT Application” web module to

__ a. In wsadmin

$AdminConfig modify $d {{classloaderMode PARENT_LAST}}

____ 4. Save the configuration change to the

__ a. In wsadmin session execute the following command:

$AdminConfig save

© Copyright IBM Corporation 2004. All rights reserved

Oct 4th – 8th IBM Advance wsadmin System Administration – Lab Exercise Page 26 of 26

2004 WebSphere Technical Exchange

This page is left intentionally blank.