WSADMIN Tutorial – Part3


In the first part of this WSADMIN tutorial, we learned the basics of WSADMIN and different objects and their use. In the second part, we saw how it can be used for deployment and adminapp object details. In this third and final part, let us learn how to do configuration related tasks and few operations. As a wrap up of this tutorial, next post will be the exercise/lab on what we have learned so far.

  • Adding an application server

    There are 3 steps involved in creating a new application server

      first we need to get the node on which we want to create the application server. Obtain the configuration ID of the object and assign it to the

node

    variable

node = AdminConfig.getid(‘/Node:mynode/’)

Then, create the application server using admintask

AdminTask.createApplicationServer(node, [‘-name’, ‘test1’, ‘-templateName’, ‘default’])

where test1 is the name of the server you want to create and mynode is the node on which this server will be created.

Then, save the changes using admintask.save ()

  • create a new cluster

    This involves 3 steps

    1A. using existing server
    1Aa. Choose the server you want to convert into server and assign it to a variable

server = AdminConfig.getid(‘/Cell:mycell/Node:mynode/Server:server1/’)

1Ab. Convert that existing server into cluster

print AdminConfig.convertToCluster(server, ‘myCluster1’)

1B. creating new cluster without members

1Ba. Identify the cell configuration ID and assign it to a variable

C1 = AdminConfig.getid(‘/Cell:mycell/’)

1Bb. Create a new cluster without a cluster member

print AdminConfig.create(‘ServerCluster’, C1, ‘[[name ClusterName]]’)

2. Adding new members:

2a. get the ncluster configuration ID and assign it to a variable

cluster = AdminConfig.getid(‘/ServerCluster:myCluster1/’)
print cluster

2b. get the ncluster configuration ID and assign it to a variable

node = AdminConfig.getid(‘/Node:mynode/’)
print node

2c. get the ncluster configuration ID and assign it to a variable

serverTemplate = AdminConfig.listTemplates(‘Server’)
print serverTemplate

2d. Create the cluster member

AdminConfig.createClusterMember(cluster, node, [[‘memberName’, ‘clusterMember1’]])

3. save the changes and synchronize them.

  • start/stop application servers

    Starting

print AdminControl.startServer(‘server1’, ‘mynode’)

Output:

WASX7319I: The serverStartupSyncEnabled attribute is set to false. A start will be attempted for server “server1” but the configuration information for node “mynode” may not be current.
WASX7262I: Start completed for server “server1” on node “mynode”

Stopping

print AdminControl.stopServer(‘serverName’, ‘mynode’)

    this command will stop the server named servername on node named mynode. Since we used print, we can see the following output on the console
    Output

WASX7337I: Invoked stop for server “serverName” Waiting for stop completion.
WASX7264I: Stop completed for server “serverName” on node “mynode”

Exit codes for stop/starting of the servers

Server state Return code
Server initialization failed -1
Server initialization timed out -2
Server start in progress 1
Server is initializing the applications that are present 2
Server initialization is complete (successful) 0
Server stop failed -10
Server stop timed out -11
Server stop operation started 1000
Server successfully stopped 0
  • Checking the status of the servers

    first get the server MBean and assign it to a variable

server = AdminControl.completeObjectName(‘cell=mycell,node=mynode,name=server1,type=Server,*’)

print server

you can see out put similar to the below:

WebSphere:cell=mycell,name=server1,mbeanIdentifier=server.xml#Server_1,type=Server,node=mynode,process=server1,processType=ManagedProcess

The execute the following command

print AdminControl.getAttribute(server, ‘state’)

This will return the state of the server on the command line, something like STARTED/STOPPED etc.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s