Wednesday 25 September 2013

Deployment of application through WSADMIN

Now let us learn how to install, start/stop and update or deployment tasks of applications using WSADMIN on to clusters and single servers.

Deploying Applications

You can install the application in batch mode, using the install command, or you can install the application in interactive mode using the installinteractive command. Interactive mode prompts you through a series of tasks to provide information.All the options available to use are listed here in the IBM documentation.

note: words in bold are command or options and in italic are your inputs

To find out the options available to install the EAR file, run:

AdminApp.options()

Installing EAR application:

Using Batch Mode:

If you are deploying on single servers….make sure that server is running before you execute the commands.

AdminApp.install(‘/home/joseph/applications/SampleApp.ear’, ‘[-server test_server1]‘)

If you are deploying it in network deployment/ Clusters, you must connect to WSADMIN of deployment manager.

AdminApp.install(‘/home/joseph/applications/SampleApp.ear’, ‘[-cluster sample_cluster]‘)

Using Interactive Mode:

AdminApp.installInteractive(‘/home/joseph/applications/SampleApp.ear’)

now it will take you through a series of questions before finishing the deployment.

After the deployment is done, you need to perform two more steps

step1. Save the changes by issuing

AdminConfig.save()

step2. Synchronize the changes across all nodes by using

Sync1 = AdminControl.completeObjectName(‘type=NodeSync,node=myNodeName,*’)

and then

AdminControl.invoke(Sync1, ‘sync’)

step2 is required only for network deployment models.

Starting Applications

this involves two steps.
step1: getting the handler of the application, means .. locating where the application is running. To do this we use a variable and use querynames option on admincontrol object

appHandle= AdminControl.queryNames ‘cell=SampleCell,node=virt_node1,type=ApplicationManager,process=test_server1,*’)
print appHandle

then you will get an output like the one below

WebSphere:cell=SampleCell,name=ApplicationManager,mbeanIdentifier=ApplicationManager,type=ApplicationManager,node=virt_node1,process=test_server1

step2: Now we execute the command to start the application

AdminControl.invoke(appHandle, ‘startApplication’, ‘Dynamic Cache Monitor’)

You can do both steps at once by using the below format

AdminControl.invoke(‘WebSphere:name=ApplicationManager,process=test_server1,node=virt_node1,type=ApplicationManager,mbeanIdentifier=ApplicationManager,cell=SampleCell, ‘startApplication‘, ‘["Dynamic Cache Monitor"]‘, ‘[java.lang.String]‘)

Stopping Application

The steps are same as starting the application except ‘startApplication’ should be renamed to ‘stopApplication’

But, if you want to stop all applications running on a server… after executing step1 of above
Step2: you need to first get the list of applications

# get line separator
import java.lang.System as sys
lineSeparator = sys.getProperty(‘line.separator’)
apps_list = AdminControl.queryNames(‘cell=SampleCell,node=virt_node1,type=Application,process=test_server1,*’).split(lineSeparator)
print apps_list

Step3: now we need to create a loop to stop the applications one by one

for app in apps_list:
appName = AdminControl.getAttribute(app, ‘name’)
AdminControl.invoke(appHandle, ‘stopApplication’, appName)

Updating Application

We have different options to update applications, like, full update, module update, single file update etc…Similar to the install, we do have both batch mode and interactive mode for updating [update and updateinteractive]. All the options available to use are listed here in the IBM documentation.

updating entire application
AdminApp.update(‘SampleApp’, ‘app’, ‘[-operation update -contents /home/joseph/applications/SampleAppv2.ear ]‘)

Adding a new module to EJB
AdminApp.update(‘SampleApp’, ‘modulefile’, ‘[-operation addupdate -contents /home/joseph/applications/Increment.jar -contenturi Increment.jar -nodeployejb
-BindJndiForEJBNonMessageBinding [["Increment Enterprise Java Bean" Increment Increment.jar,META-INF/ejb-jar.xml Inc]]]’)

Updating Single file
AdminApp.update(‘SampleApp’, ‘file’, ‘[-operation update -contents /home/joseph/applications/my.xml -contenturi SampleApp/my.xml]‘)

TIP: Use the taskInfo command of the AdminApp object to obtain information about the data that is needed for your application.

for example, you want to know what options you need to supply for mapping modules to servers…use the following taskinfo command

AdminApp taskInfo <ear file> MapModulesToServers




TO VIEW JVM settings:

w to enable the verbose gc logging on Websphere Application server

Wednesday, June 19, 2013, 5:41 AM
Posted By: Akhilesh

Hi Everyone,
Execute the following steps to enable the verbose:gc logging in your setup. Or you can use some steps to check the current status of your Java Virtual Machine configuration by using wsadmin tool 
1.Launch the wsadmin. Run these commands in a command prompt window:
:/IBM/WebSphere/AppServer/profiles/AppSrv01/bin
:/IBM/WebSphere/AppServer/profiles/AppSrv01/bin $ ./wsadmin.sh
This output will appear after running the command:
WASX7209I: Connected Node DefaultNode ?process "server1" by SOAP connector Process Type UnManagedProcess
wsadmin>
2. Set the server environment.
wsadmin>set server1 [$AdminConfig getid /Cell:mycell/Node:mynode/Server:server1/]
server1(cells/DefaultNode/nodes/DefaultNode/servers/server1|server.xml#Server_1214551833906)
3.Get the definition of JVM.
wsadmin>set jvm [$AdminConfig list JavaVirtualMachine $server1]
(cells/DefaultNode/nodes/DefaultNode/servers/server1|server.xml#JavaVirtualMachine_1214551833937)
4.Check the current JVM setting.
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 128}
{maximumHeapSize 256}
{runHProf false}
{systemProperties {}}
{verboseModeClass false}
{verboseModeGarbageCollection false}
{verboseModeJNI false}
5.Set the verboseModeGarbageCollection variable to true.
wsadmin>$AdminConfig modify $jvm {{verboseModeGarbageCollection true}}
6.Check the changed JVM setting.
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 128}
{maximumHeapSize 256}
{runHProf false}
{systemProperties {}}
{verboseModeClass false}
{verboseModeGarbageCollection true}
{verboseModeJNI false}
7.Save the JVM setting.
wsadmin>$AdminConfig save
8.Close the wsadmin console.
wsadmin>quit
9.Restart the Windows service IBM WebSphere Application Server.
10.Check the verbose:gc logs. By Default, the verbose:gc logs are located here:
/IBM/WebSphere/AppServer/profiles/AppSrv01/logs/server1 $ cat native_stdout.log
/IBM/WebSphere/AppServer/profiles/AppSrv01/logs/server1 $ cat native_stderr.log

No comments:

Post a Comment