Script:
Owner:
Subdir: websphere-automation
Blog ID: 141645827
Group ID: User ID: 140678839

Leader Spotlight

Featured Video

    Web server plug-in routing to SAME application in DIFFERENT clusters

    Friday, November 11, 2011, 7:59 AM

    Question
    If I install the same Web application into more than one WebSphere Application Server cluster, is it possible to configure the Web server plug-in to properly route requests to the application in both clusters?

    Cause

    The most common use of the WebSphere Application Server Web server plug-in is to load balance requests for an application installed to a single cluster. For that environment you should not use the instructions in this technote.

    In some rare cases, you might want to install the exact same application into multiple clusters. The purpose of this technote is to describe how to configure the WebSphere Application Server Web server Plug-in to work properly in that specific case.

    Answer

    Note: The Web server plug-in does not support load balancing or fail-over between multiple clusters. Also the configuration described below requires manually changing the plugin-cfg.xml file, so you should turn off automatic propagation in the WebSphere Administrative Console so that the plugin-cfg.xml file does not get automatically overwritten.

    Yes, it is possible for a single Web server plug-in to properly route requests when the same application is installed into more than one WebSphere Application Server cluster. To make this work you will need to use different hostnames or port numbers for each of the clusters. You will also need to do some manual cut and paste of information in the plugin-cfg.xml file.

    The example below shows exactly how to accomplish this.

    * The IBM HTTP Server machine is called ihsbox.
    * cluster1 has two members c1_member1 and c1_member2.
    * cluster2 has two members c2_member1 and c2_member2.
    * Both of the member1 appservers are on a machine called was1.
    * Both of the member2 appservers are on a machine called was2.


    So, for this simple example, it would look like the following:

    ------ was1 --- cl1_member1
    / \--- cl2_member1
    /
    ihsbox
    \
    \------ was2 --- cl1_member2
    \--- cl2_member2

    If I install my snoop application (context-root /snoop) into both clusters, how is the plug-in supposed to distinguish which ServerCluster to use?

    In the plug-in, there are only 3 things that can distinguish between requests:

    * hostname
    * port number
    * URI


    For example, these URLs are unique requests that can be routed independently of each other:

    http://host1/snoop
    http://host1:83/snoop
    http://host2/snoop
    http://host2:81/snoop

    In each of these examples, the URI part /snoop remains the same. It is the hostname or port number that makes the difference.

    Back to the example, in Application Server admin, you would create a virtual host called "vhost1" which would have a host alias of host1:80. You would also need to include other host aliases for the internal ports used by appservers in cluster1 (for example: ports 9080, 9081, 9443, 9444). You would use this virtual host (vhost1) in all of the members of cluster1 (cl1_member1 and cl1_member2).

    In addition, you would create a virtual host called "vhost2" which would have a host alias of host2:80. You would need to include other host aliases for the internal ports used by appservers in cluster2. I would use this virtual host (vhost2) in all of the members of cluster2 (cl2_member1 and cl2_member2).

    In order to maintain session affinity it is essential to use different affinity cookie names for each different cluster. For example, the appservers in cluster1 can use the cookie name "JSESSIONIDC1". And the appservers in cluster2 can use the cookie name "JSESSIONIDC2". By using different cookie names for the different clusters, session affinity will be preserved within each cluster. For information about how to change the cookie names, see Cookie settings in the Information Center.

    You must map the application modules to the newly created virtual hosts. Since the same application is installed to both clusters, you will need to map the application modules to both vhosts. However, there currently is a limitation in the Application Server administrative console in that it only allows the application modules to be mapped to a single vhost. Consequently, you must use a trick to map the modules twice and manually copy and paste the configs into a single plugin-cfg.xml file.

    Here are the steps to use:

    1. Map the application modules to the first vhost (for example: vhost1).

    2. Generate the plug-in.

    3. From the plugin-cfg.xml file, manually copy the VirtualHostGroup and UriGroup and Route that correspond to vhost1.

    4. Map the application modules to the second vhost (for example: vhost2).

    5. Generate the plug-in.

    6. In the new plugin-cfg.xml file you will see that the VirtualHostGroup and UriGroup for vhost1 are gone, and there are new VirtualHostGroup and UriGroup for vhost2.

    7. Manually paste the VirtualHostGroup and UriGroup and Route for vhost1 back into the plugin-cfg.xml file.

    8. Save the plugin-cfg.xml file and propagate it to the Web server.


    The plugin-cfg.xml file should now have a VirtualHostGroup and UriGroup for vhost1 with a Route that points to cluster1. Also there should be a VirtualHostGroup and UriGroup for vhost2 with a Route that points to cluster2.

    You need to account for these new hostnames in my IBM HTTP Server config (httpd.conf). The ServerName for IBM HTTP Server is ihsbox. Create a VirtualHost in IBM HTTP Server to account for the other valid hostnames, like this:


    ServerName ihsbox
    ServerAlias host1
    ServerAlias host2


    Add host1 and host2 into my DNS config so that they resolve to the ip address of ihsbox.

    Now, this URL http://host1/snoop will go to the snoop application in cluster1.

    And, this URL http://host2/snoop will go to the snoop application in cluster2.

    If you want to use different port numbers instead of different hostnames, the same idea applies there as well.
    1.9 (1 Ratings)

    Jython Script to uninstall , install application and sync node

    Thursday, November 10, 2011, 9:16 AM

    import sys,java
    from java.util import Properties
    from java.io import FileInputStream
    from org.python.modules import time
    lineSep = java.lang.System.getProperty('line.separator')


    def appinstall(appfile,apppath,cluster,map_modules_cluster,map_modules_vh,mapresref):

    global AdminApp
    global AdminConfig
    global AdminControl

    print " Getting Cell Name .."
    cell = AdminControl.getCell()
    print " Cell name is --> "+ cell
    print " ----------------------------------------------------------------------------------------- "

    ###############################################################################################

    ## checking for the existence of application , is application exists then updating it and if it does not exists then installing it
    application = AdminConfig.getid("/Deployment:"+appfile+"/")
    if len(application) > 0:
    print " ----------------------------------------------------------------------------------------- "
    print " Application ---> " +appfile+ " is installed on cluster --> " + cluster
    print " ----------------------------------------------------------------------------------------- "
    print " uninstalling application --> " + appfile
    AdminApp.uninstall(appfile)
    print " ----------------------------------------------------------------------------------------- "
    print "application uninstalled .. "
    AdminConfig.save()
    print " ----------------------------------------------------------------------------------------- "
    print " Installing App on cluster --> " + cluster
    print AdminApp.install(apppath , '[-appname '+appfile+' -cell '+cell+' -cluster '+cluster+' -MapModulesToServers '+map_modules_cluster+' -MapWebModToVH '+map_modules_vh+']')
    print " ----------------------------------------------------------------------------- "
    print " Application --> " +appfile+ " installed on cluster--> " +cluster
    print " ----------------------------------------------------------------------------- "
    print " Saving Configuration "
    print " ----------------------------------------------------------------------------- "
    AdminConfig.save()
    print " ----------------------------------------------------------------------------- "
    application = AdminConfig.getid("/Deployment:"+appfile+"/")
    if len(application) > 0:
    print " ----------------------------------------------------------------------------------------- "
    print " Application ---> " +appfile+ " is successfully installed on cluster --> " + cluster
    print " ----------------------------------------------------------------------------------------- "

    #####################Waiting for the application to expand and then starting the server################
    print " Sleeping for 60 seconds after deploying application "
    time.sleep(60)
    app = AdminApp.isAppReady(appfile)
    while (app == 'false'):
    app = AdminApp.isAppReady(appfile)
    if (app == 'true'):
    print " Expansion of ear completed "


    ###########################Syncronizing Node######################
    nodelist = AdminTask.listManagedNodes().split(lineSep)
    for nodename in nodelist :
    print " Syncronizing node.......... "
    ####################Identifying the ConfigRepository MBean and assign it to variable######################
    repo = AdminControl.completeObjectName('type=ConfigRepository,process=nodeagent,node='+ nodename +',*')
    AdminControl.invoke(repo, 'refreshRepositoryEpoch')
    sync = AdminControl.completeObjectName('cell='+ cell +',node='+ nodename +',type=NodeSync,*')
    AdminControl.invoke(sync , 'sync')
    print " ----------------------------------------------------------------------------------------- "
    print " Full Resyncronization completed "
    print "



    arglen=len(sys.argv)
    num_exp_args=2
    if (arglen != num_exp_args):
    print "Three arguments are required. Two arguments should be a properties file."
    print " ----------------------------------------------------------------------------------------- "
    sys.exit(-1)
    propFile=sys.argv[1]
    properties=Properties();

    try:
    properties.load(FileInputStream(propFile))
    print " ----------------------------------------------------------------------------------------- "
    print "Succesfully read property file "+propFile
    print " ----------------------------------------------------------------------------------------- "
    except:
    print "Cannot read property file "+propFile
    sys.exit(-1)
    print " ----------------------------------------------------------------------------------------- "
    apppath = sys.argv[0]
    cluster = str(properties.getProperty("ENV_CLUSTER_NAME"))
    map_modules_cluster = str(properties.getProperty("ENV_PCS_MAP_MODULES_TO_SERVER"))
    map_modules_vh = str(properties.getProperty("PCS_MAP_MODULES_TO_VIRTUAL_HOST"))
    appfile = str(properties.getProperty("ENV_PCS_APP_NAME"))
    mapresref = str(properties.getProperty("MAP_RESOURCE_REF"))

    appinstall(appfile,apppath,cluster,map_modules_cluster,map_modules_vh,mapresref)
    1.9 (1 Ratings)

    Jython Script to stop Cluster

    Thursday, November 10, 2011, 7:48 AM

    import sys,java
    from java.util import Properties
    from java.io import FileInputStream
    from org.python.modules import time
    lineSep = java.lang.System.getProperty('line.separator')


    def stopcluster(cluster):

    global AdminApp
    global AdminConfig
    global AdminControl

    cell = AdminControl.getCell()

    print " Cell name is --> "+ cell

    Serverid = AdminConfig.getid('/Cell:'+ cell +'/ServerCluster:'+ cluster +'/')

    memberlist = AdminConfig.showAttribute(Serverid, "members" )

    members = memberlist[1:len(memberlist)-1]

    for member in members.split():

    node = AdminConfig.showAttribute(member, "nodeName" )

    server = AdminConfig.showAttribute(member, "memberName" )

    serverId = AdminConfig.getid("/Cell:"+cell+"/Node:"+node+"/Server:"+server+"/")

    s1 = AdminControl.completeObjectName('cell='+ cell +',node='+ node +',name='+ server +',type=Server,*')

    print " Checking for the running Mbean of server :"+ server

    if len(s1) > 0:

    print " Server : "+ server +" is running"

    print " Stopping Server :"+ server

    AdminControl.stopServer(server, node, 'immediate' )

    print " Server : "+ server +" stopped"

    else :

    print "Server : "+ server +" is stopped "

    arglen=len(sys.argv)

    num_exp_args=1

    if (arglen != num_exp_args):

    print "One argument is required. This argument should be a properties file."

    print " ----------------------------------------------------------------------------------------- "

    sys.exit(-1)

    cluster=sys.argv[0]

    stopcluster(cluster)
    1.9 (1 Ratings)

    Jython Script to check the status of listener ports of all servers of cluster

    Wednesday, November 9, 2011, 8:39 AM

    Jython Script to check the status of listener ports of all servers of cluster

    lineSeparator = java.lang.System.getProperty('line.separator')

    clusterName='CLUSTER_NAME'
    cId = AdminConfig.getid("/ServerCluster:"+ clusterName +"/" )
    cList = AdminConfig.list("ClusterMember", cId ).split(lineSeparator)
    for sId in cList:
    server = AdminConfig.showAttribute(sId, "memberName" )
    node = AdminConfig.showAttribute(sId, "nodeName" )
    cell = AdminControl.getCell()

    s1 = AdminControl.completeObjectName('cell='+ cell +',node='+node +',name='+ server +',type=Server,*')
    if len(s1) > 0:
    print server + " state is started"
    else:
    print server + " is down"

    print "Server " + server + " has the following Listener Ports"
    lPorts = AdminControl.queryNames('type=ListenerPort,cell='+ cell+',node='+ node +',process='+ server +',*')
    lPortsArray = lPorts.split(lineSeparator)
    for lPort in lPortsArray:
    lpcfgId = AdminControl.getConfigId(lPort)
    lpName = AdminConfig.showAttribute(lpcfgId, "name")
    lpstate = AdminControl.getAttribute(lPort, 'started')
    if lpstate == 'true':
    print lpName + " is started "
    else :
    print lpName + " is stopped "

    print ""

    1.9 (1 Ratings)

    Jython Script to Start Cluster

    Wednesday, November 9, 2011, 8:35 AM

    This Jython script starts cluster if it is stopped and ripple starts cluster if cluster is already running.

    import sys,java
    from java.util import Properties
    from java.io import FileInputStream
    from org.python.modules import time
    lineSep = java.lang.System.getProperty('line.separator')


    def startcluster(cluster):

    global AdminApp
    global AdminConfig
    global AdminControl

    cell = AdminControl.getCell()
    print " Cell name is --> "+ cell
    Cluster = AdminControl.completeObjectName('cell='+ cell +',type=Cluster,name='+ cluster +',*')
    state = AdminControl.getAttribute(Cluster, 'state')

    if (state == 'websphere.cluster.running'):
    print "Cluster --> " + cluster + " is running .......... "
    print "Ripple starting cluster ............."
    clusterMgr = AdminControl.completeObjectName('cell='+ cell +',type=ClusterMgr,*')
    print AdminControl.invoke(clusterMgr, 'retrieveClusters')
    Cluster = AdminControl.completeObjectName('cell='+ cell +',type=Cluster,name='+ cluster +',*')
    print AdminControl.invoke(Cluster ,'rippleStart')

    else:
    print "Cluster --> " + cluster + " is stopped "
    print "Starting cluster ............... "
    clusterMgr = AdminControl.completeObjectName('cell='+ cell +',type=ClusterMgr,*')
    AdminControl.invoke(clusterMgr, 'retrieveClusters')
    Cluster = AdminControl.completeObjectName('cell='+ cell +',type=Cluster,name='+ cluster +',*')
    print AdminControl.invoke(Cluster ,'start')
    print " ---------------------------------------------------------------------------------------------- "

    arglen=len(sys.argv)
    num_exp_args=1
    if (arglen != num_exp_args):
    print "One argument is required. This argument should be a properties file."
    print " ----------------------------------------------------------------------------------------- "
    sys.exit(-1)
    cluster = sys.argv[0]
    startcluster(cluster)
    1.9 (1 Ratings)

    I am currently http://websphere-automation.blogspot.com/2011/01/websphere-scripting.html

  • Celia Hamilton
    Celia Hamilton

  • Aribandi
    Aribandi

  • Yasmin
    Yasmin

  • David
    David

    Loading...