Tuesday, August 30, 2011

WS Admin commands with example

Example: Configuring a shared library using wsadmin

The following example configures an application server to use a shared library.

  • Identify the server and assign it to the server variable.

set server [$AdminConfig getid /Cell:mycell/Node:mynode/Server:server1/]

Example output:

server1(cells/mycell/nodes/mynode/servers/server1:server.xml#Server_1)

  • Create the shared library in the server.

$AdminConfig create Library $server {{name mySharedLibrary} {classPath c:/mySharedLibraryClasspath}}

Example output:

MyshareLibrary(cells/mycell/nodes/mynode/servers/server1:libraries.xml#Library_1)

  • Identify the application server from the server and assign it to the appServer variable.

set appServer [$AdminConfig list ApplicationServer $server]

Example output:

server1(cells/mycell/nodes/mynode/servers/server1:server.xml#ApplicationServer_1

  • Identify the class loader in the application server and assign it to the classLoader variable.

To use the existing class loader associated with the server, the following commands use the first class loader:

set classLoaders [$AdminConfig showAttribute $appServer classloaders]

set classLoader [lindex $classLoaders 0]

Create a new class loader, by doing the following:

set clsssLoader [$AdminConfig create Classloader $appsev1 {{mode PARENT_FIRST}}]

Example output:

(cells/mycell/nodes/mynode/servers/server1:server.xml#Classloader_1)

  • Associate the created shared library with the application server through the class loader.

$AdminConfig create LibraryRef $classLoader {{libraryName MyshareLibrary} {sharedClassloader true}}

Example output:

(cells/mycell/nodes/mynode/servers/server1:server.xml#LibraryRef_1)

  • Save the changes with the following command:

$AdminConfig save



Example: Creating a cluster using wsadmin

An example creating a cluster using an existing server follows:

  • Identify the server to convert to a cluster and assign it to the server variable:

set server [$AdminConfig getid /Cell:mycell/Node:mynode/Server:server1]

  • Convert the existing server to a cluster by using the convertToCluster command passing in the existing server and the cluster name:

$AdminConfig convertToCluster $server myCluster1

This command converts a cluster named myCluster with server1 as its member.

An example of this output follows:

myCluster1(cells/mycell/cluster/myCluster1:cluster.xml#ClusterMember_1)

  • Save the changes with the following command:

$AdminConfig save

Example: Enabling and disabling Java 2 security using wsadmin

An example of enabling and disabling Java 2 security follows:

  • Identify the security configuration object and assign it to the security variable:

set security [$AdminConfig list Security]

An example of this output follows:

(cells/mycell:security.xml#Security_1)

  • Modify the enforceJava2Security attribute.

To enable Java 2 security:

$AdminConfig modify $security {{enforceJava2Security true}}

To disable Java 2 security:

$AdminConfig modify $security {{enforceJava2Security false}}

  • Save the changes with the following command:

$AdminConfig save

Example: Enabling and disabling global security with a profile

The default profile sets up procedures so that you can enable and disable global security based on LocalOS registry.

  • You can use the help command to find out the arguments that you need to provide with this call, for example:

securityon help

An example of this output follows:

Syntax: securityon user password

  • To enable global security based on the LocalOS registry, use the following procedure call and arguments:

securityon user1 password1

  • To disable global security based on the LocalOS registry, use the following procedure call:

securityoff

Example: Configuring for processes using wsadmin

The following example modifies the process definition of a server:

  • Identify the server and assign it to the server1 variable.

set server1 [$AdminConfig getid /Cell:mycell/Node:mynode/Server:server1/]

Example output:

server1(cells/mycell/nodes/mynode/servers/server1:server.xml#Server_1)

  • Identify the process definition belonging to this server and assign it to the processDef variable

· set processDef [$AdminConfig list JavaProcessDef $server1]

set processDef [$AdminConfig showAttribute $server1 processDefinition]

Example output:

(cells/mycell/nodes/mynode/servers/server1:server.xml#JavaProcessDef_1)

  • Change the attributes.
    • This example changes the working directory:

$AdminConfig modify $processDef {{workingDirectory c:/temp/user1}}

    • This example modifies the stderr file name:

o set errFile [list stderrFilename \${LOG_ROOT}/server1/new_stderr.log]

o set attr [list $errFile]

$AdminConfig modify $processDef [subst {{ioRedirect {$attr}}}]

    • This example modifies the process priority:

$AdminConfig modify $processDef {{execution {{processPriority 15}}}}

    • This example changes the maximum startup attempts:

$AdminConfig modify $processDef {{monitoringPolicy {{maximumStartupAttempts 1}}}}

You can modify this example to change other attributes in the process definition object.

  • Save the changes with the following command:

$AdminConfig save

Configuring name space bindings using wsadmin

This example configures name space binding on a cell.

  • Identify the cell and assign it to the cell variable.

set cell [$AdminConfig getid /Cell:mycell/]

Example output:

mycell(cells/mycell/cell.xml#Cell_1)

You can change this example to configure on a node or server here.

  • Add a new name space binding on the cell. There are four binding types to choose from when configuring a new name space binding. They are string, EJB, CORBA, and indirect.
    • To configure a string type name space binding:

$AdminConfig create StringNameSpaceBinding $cell {{name binding1} {nameInNameSpace myBindings/myString} {stringToBind "This is the String value that gets bound"}}

Example output:

binding1(cells/mycell:namebindings.xml#StringNameSpaceBinding_1)

    • To configure an enterprise bean type name space binding:

$AdminConfig create EjbNameSpaceBinding $cell {{name binding2} {nameInNameSpace myBindings/myEJB} {applicationNodeName mynode} {bindingLocation SINGLESERVER} {applicationServerName server1} {ejbJndiName ejb/myEJB}}

This example is for an EJB located in a server. For EJB in a cluster, change the configuration example to:

$AdminConfig create EjbNameSpaceBinding $cell {{name binding2} {nameInNameSpace myBindings/myEJB} {bindingLocation SERVERCLUSTER} {applicationServerName cluster1} {ejbJndiName ejb/myEJB}}

Example output:

binding2(cells/mycell:namebindings.xml#EjbNameSpaceBinding_1)

    • To configure a CORBA type name space binding:

$AdminConfig create CORBAObjectNameSpaceBinding $cell {{name binding3} {nmeInNameSpace myBindings/myCORBA} {corbanameUrl corbaname:iiop:somehost.somecompany.com:2809#stuff/MyCORBAOjbect} {federatedContext false}}

Example output:

binding3(cells/mycell:namebindings.xml#CORBAObjectNameSpaceBinding_1)

    • To configure an indirect type name space binding:

$AdminConfig create IndirectLookupNameSpaceBinding $cell {{name binding4} {nameInNameSpace myBindings/myIndirect} {providerURL corbaloc::myCompany.com:9809/NameServiceServerRoot} {jndiName jndi/name/for/EJB}}

Example output:

binding4(cells/mycell:namebindings.xml#IndirectLookupNameSpaceBinding_1)

  • Save the changes with the following command:

$AdminConfig save



Example: Modifying port numbers in the serverindex file

This topic provides reference information about modifying port numbers in the serverindex.xml file. The end points of theserverindex.xml file are part of different objects in the configuration.

Use the following attributes to modify the serverindex.xml file:

  • BOOTSTRAP_ADDRESS

An attribute of the NameServer object that exists inside the server. It is used by the naming client to specify the naming server to look up the initial context. To modify its end point, obtain the ID of the NameServer object and issue a modify command, for example:

set s [$AdminConfig getid /Server:server1/]

set ns [$AdminConfig list NameServer $s]

$AdminConfig modify $ns {{BOOTSTRAP_ADDRESS {{port 2810} {host myhost}}}

  • SOAP_CONNECTOR-ADDRESS

An attribute of the SOAPConnector object that exists inside the server. It is the port that is used by http transport for incoming SOAP requests. To modify its end point, obtain the ID of the SOAPConnector object and issue a modify command, for example:

set s [$AdminConfig getid /Server:server1/]

set soap [$AdminConfig list SOAPConnector $s]

$AdminConfig modify $soap {{SOAP_CONNECTOR_ADDRESS {{host myhost} {port 8881}}}}

  • DRS_CLIENT_ADDRESS

An attribute of the SystemMessageServer object that exists inside the server. It is the port used to configure the Data Replication Service (DRS) which is a JMS-based message broker system for dynamic caching. To modify its end point, obtain the ID of the SystemMessageServer object and issue a modify command, for example:

set s [$AdminConfig getid /Server:server1/]

set soap [$AdminConfig list SystemMessageServer $s]

$AdminConfig modify $soap {{DRS_CLIENT_ADDRESS {{host myhost} {port 7874}}}}

  • JMSSERVER_QUEUED_ADDRESS and JMSSERVER_DIRECT_ADDRESS

An attribute of the JMSServer object that exists inside the server. These are ports used to configure the WebSphere Application Server JMS provifder topic connection factory settings. To modify its end point, obtain the ID of the JMSServer object and issue a modifycommand, for example:

set s [$AdminConfig getid /Server:server1/]

set soap [$AdminConfig list JMSServer $s]

$AdminConfig modify $soap {{JMSSERVER_QUEUED_ADDRESS {{host myhost} {port 5560}}}}

$AdminConfig modify $soap {{JMSSERVER_DIRECT_ADDRESS {{host myhost} {port 5561}}}}

  • NODE_DISCOVERY_ADDRESS

An attribute of the NodeAgent object that exists inside the server. It is the port used to receive the incoming process discovery messages inside a node agent process. To modify its end point, obtain the ID of the NodeAgent object and issue a modify command, for example:

set nodeAgentServer [$AdminConfig getid /Server:myhost/]

set nodeAgent [$AdminConfig list NodeAgent $nodeAgentServer]

$AdminConfig modify $nodeAgent {{NODE_DISCOVERY_ADDRESS {{host myhost} {port 7272}}}}

· CELL_DISCOVERY_ADDRESS

An attribute of the deploymentManager object that exists inside the server. It is the port used to receive the incoming process discovery messages inside a deployment manager process. To modify its end point, obtain the ID of the deploymentManager object and issue amodify command, for example:

set netmgr [$AdminConfig getid /Server:netmgr/]

set deploymentManager [$AdminConfig list CellManager $netmgr]

$AdminConfig modify $deploymentManager {{CELL_MULTICAST_DISCOVERY_ADDRESS {{host myhost} {port 7272}}}}

$AdminConfig modify $deploymentManager {{CELL_DISCOVERY_ADDRESS {{host myhost} {port 7278}}}}



Configuring the Java virtual machine using wsadmin

An example modifying the Java virtual machine (JVM) of a server to turn on debug follows:

  • Identify the server and assign it to the server1 variable.

set server1 [$AdminConfig getid /Cell:mycell/Node:mynode/Server:server1/]

An example of this output follows:

server1(cells/mycell/nodes/mynode/servers/server1:server.xml#Server_1)

  • Identify the JVM belonging to this server and assign it to the jvm variable.

set jvm [$AdminConfig list JavaVirtualMachine $server1]

An example of this output follows:

(cells/mycell/nodes/mynode/servers/server1:server.xml#JavaVirtualMachine_1)

  • Modify the JVM to turn on debug.

$AdminConfig modify $jvm {{debugMode true} {debugArgs "-Djava.compiler=NONE -Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=7777"}}

  • Save the changes with the following command:

$AdminConfig save



Configuring HTTP transport using wsadmin

This example configures the Web container HTTP transport.

  • Identify the application server and assign it to the server variable.

set server [$AdminConfig getid /Cell:mycell/Node:mynode/Server:server1/]

An example of this output follows:

server1(cells/mycell/nodes/mynode/servers/server1:server.xml#Server_1)

  • Identify the Web container belonging to the server and assign it to the wc variable.

set wc [$AdminConfig list WebContainer $server]

An example of this output follows:

(cells/mycell/nodes/mynode/servers/server1:server.xml#WebContainer_1)

  • List all the transports belonging to the Web Container and assign it to the transports variable.

· set transportsAttr [$AdminConfig showAttribute $wc transports]

set transports [lindex $transportsAttr 0]

These commands return the transport objects from the transports attribute in a list format.

Example output:

(cells/mycell/nodes/mynode/servers/server1:server.xml#HTTPTransport_1)

(cells/mycell/nodes/mynode/servers/server1:server.xml#HTTPTransport_2)

  • Identify the transport to be modified and assign it to the transport variable.

set transport [$lindex $transports 0]

An example of this output follows:

(cells/mycell/nodes/mynode/servers/server1:server.xml#HTTPTransport_1)

  • Modify the address attribute to change the host and port.

$AdminConfig modify $transport {{address {{host {myHost}} {port 9081}}}}

  • Save the changes with the following command:

$AdminConfig save



Configuring for database session persistence using wsadmin

The following example configures the session management of a Web container for database session persistence.

Before performing this task you have to create a JDBC provider and create a data source that points to an existing database.

  • Identify the application server and assign it to the server variable:

set server [$AdminConfig getid /Cell:mycell/Node:mynode/Server:server1/]

Example output:

server1(cells/mycell/nodes/mynode/servers/server1:server.xml#Server_1)

  • Identify the session management belonging to the server and assign it to the smgr variable:

set smgr [$AdminConfig list SessionManager $server]

Example output:

(cells/mycell/nodes/mynode/servers/server1:server.xml#SessionManager_1)

  • Modify database session persistence:

$AdminConfig modify $smgr {{sessionDatabasePersistence {{datasourceJNDIName jdbc/mySession} {userId myUser} {password myPassword}}}}

This command sets the minimum set of attributes to configure database session persistence. You can optionally modify the db2RowSize and tableSpaceName attributes too.

  • Save the changes with the following command:

$AdminConfig save



Configuring for session tracking using wsadmin

The following example configures the session management of a Web container for session tracking:

  • Identify the application server and assign it to the server variable:

set server [$AdminConfig getid /Cell:mycell/Node:mynode/Server:server1/]

Example output:

server1(cells/mycell/nodes/mynode/servers/server1:server.xml#Server_1)

  • Identify the session management belonging to the server and assign it to the smgr variable:

set smgr [$AdminConfig list SessionManager $server]

Example output:

(cells/mycell/nodes/mynode/servers/server1:server.xml#SessionManager_1)

  • Modify attributes related to session tracking:
    • This example command enables cookies and modifies cookie setting:

$AdminConfig modify $smgr {{enableCookies true} {defaultCookieSettings {{maximumAge 10}}}}

    • This example command enables protocol switch rewriting:

$AdminConfig modify $smgr {{enableProtocolSwitchRewriting true} {enableUrlRewriting false} {enableSSLTracking false}}

    • This example command enables URL rewriting:

$AdminConfig modify $smgr {{enableUrlRewriting true} {enableProtocolSwitchRewriting false} {enableSSLTracking false}}

    • This example command enables SSL tracking:

$AdminConfig modify $smgr {{enableSSLTracking true} {enableProtocolSwitchRewriting false} {enableUrlRewriting false}}

  • Save the changes with the following command:

$AdminConfig save



Creating a cluster member using wsadmin

An example creating a cluster member to an existing cluster follow:

  • Identify the existing cluster and assign it to the cluster variable:

· set cluster [$AdminConfig getid /ServerCluster:mycluster1/]

An example of this output follows:

myCluster1(cells/mycell/cluster/myCluster1:cluster.xml#ServerCluster_1)

  • Identify the node to create the new server and assign it to the node variable:

· set node [$AdminConfig getid /Node:mynode/]

An example of this output follows:

mynode(cells/mycell/nodes/mynode:node.xml#Node_1)

  • (Optional) Identify the cluster member template and assign it to the clusterTemplate variable:

· set clusterTemplate [$AdminConfig listTemplates ClusterMember]

An example of this output follows:

(templates/default:cluster-components.xml#ClusterMember_1)

  • Create the new cluster member, by using the createClusterMember command.

The following example creates the new cluster member, passing in the existing cluster configuration ID, existing node configuration ID, and the new member attributes:

$AdminConfig createClusterMember $cluster $node {{memberName clusterMember1}}

The following example creates the new cluster member with a template, passing in the existing cluster configuration ID, existing node configuration ID, the new member attributes, and the template ID:

$AdminConfig createClusterMember $cluster $node {{memberName clusterMember1}} $clusterTemplate

An example of this output follows:

myCluster1{cells/mycell/clusters/myCluster1:cluster.xml$ClusterMember_2}}



No comments:

Post a Comment