Sun Cluster 3.1 Data Service for Apache Tomcat Guide

How to Register and Configure Sun Cluster HA for Apache Tomcat as a scalable or multiple masters data service

Use this procedure to configure Sun Cluster HA for Apache Tomcat as a scalable or multiple masters data service. This procedure assumes that you installed the data service packages during your initial Sun Cluster installation.

You need to do that, to deploy Apache Tomcat in a scalable or a multiple masters configuration.

If you did not install the Sun Cluster HA for Apache Tomcat packages as part of your initial Sun Cluster installation, go to Installing the Sun Cluster HA for Apache Tomcat Packages.

Otherwise, use this procedure to configure the Sun Cluster HA for Apache Tomcat data service.

  1. Become superuser on one of the nodes in the cluster which will host Apache Tomcat.

  2. Register the SUNW.gds resource type.


    # scrgadm -a -t SUNW.gds
    
  3. Create a failover resource group for the SharedAddress resource.


    # scrgadm -a -g Apache-Tomcat-SharedAddress-resource-group
    
  4. Create the SharedAddress resource.


    # scrgadm -a -S -j Apache-Tomcat-SharedAddress-resource  \
    > -g Apache-Tomcat-SharedAddress-resource-group\
    > -l Apache-Tomcat-SharedAddress-hostname
    
  5. Enable the SharedAddress resource group.


    # scswitch -Z -g  Apache-Tomcat-SharedAddress-resource-group
    
  6. Prepare the parameter file, which is required by the Sun Cluster HA for Apache Tomcat.


    # cd /opt/SUNWsctomcat/bin
    cp pfile desired place
    

    Edit the parameter file pfile and follow the comments within that file, in example.


    #!/usr/bin/ksh 
    # Set the Apache Tomcat specific environment variables which the start, 
    # stop and check functions will use 
    #
    # EnvScript     Script to set runtime environment for tomcat
    # User          Apache Tomcat user name
    # Basepath      Absolute pathname to tomcat Home directory ie 4.x CATALINA_HOME
    #               or TOMCAT_HOME for 3.x
    # Host          Hostname to test Apache Tomcat 
    # Port          Port where Apache Tomcat is configured
    # TestCmd       Apache Tomcat test command
    # Startwait     Sleeping $Startwait seconds after completion of the 
    #               start command
    EnvScript=
    User=
    Basepath=
    Host=
    Port=8080
    TestCmd="get /index.jsp"
    ReturnString="CATALINA"
    Startwait=20

    The following is an example for Apache Tomcat 4.1.24.


    EnvScript=/tomcat/env.ksh
    User=tomcat
    Basepath=/tomcat/jakarta-tomca-4.1.24
    Host=localhost
    Port=8080
    TestCmd="get /index.jsp"
    ReturnString="CATALINA"
    Startwait=20
    

    This example is from an Apache Tomcat 4.1.24 configured as standalone webserver with the default startpage index.jsp. The startpage contains the string CATALINA.

    Be aware that the Host parameter depends on the location of the pfile.

    • If the pfile is stored on the shared storage, you need to use localhost.

    • If the pfile is stored on the local storage, it can be either localhost or the nodes hostname.

    Do not use the SharedAddress here.


    Caution – Caution –

    The parameter files need to be available on every node which can host the Apache Tomcat data service. For a scalable or a multiple masters configuration, store them on the local file system of every node, or on the shared storage. The parameter files must not differ for an instance of Apache Tomcat on the various nodes.


    Repeat this Step for every Apache Tomcat instance and every node you need.

  7. Create the resource group for the scalable service.


    # scrgadm -a -g Apache-Tomcat-Scalable-resource-group \
    > -y Maximum_primaries=2 \
    > -y Desired_primaries=2 \
    > -y RG_dependencies=Apache-Tomcat-SharedAddress-resource-group
    

    If you need more nodes, adjust Maximum_primaries and Desired_primaries to the appropriate value.

  8. Create a resource for the Apache Tomcat Disk Storage, if it is not in the root file system. Otherwise proceed to Step 10


    # scrgadm -a -j Apache-Tomcat-has-resource  \
    > -g Apache-Tomcat-failover-resource-group   \
    > -t SUNW.HAStoragePlus  \
    > -x FilesystemMountPoints=Apache Tomcat- instance-mount-points
    
  9. Enable the Apache-Tomcat-has-resource.


    # scstat 
    

    # scswitch -e -j Apache- Tomcat-has-resource
    
  10. Create and register each required Apache Tomcat component.


    # cd /opt/SUNWsctomcat/util
    # cp sctomcat_config desired place
    # cp sctomcat_register desired place
    

    Edit the sctomcat_config file and follow the comments within that file, in example.


    # These parameters can be customized in (key=value) form
    #
    # Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
    # Use is subject to license terms.
    # 
    # This file will be sourced in by sctomcat_register and the parameters
    # listed below will be used.
    #
    # These parameters can be customized in (key=value) form
    #
    #        RS - name of the resource for the application
    #        RG - name of the resource group containing RS
    #      PORT - name of the port number
    #        LH - name of the LogicalHostname SC resource
    #  SCALABLE - true or false for a scalable or failover resource
    #     PFILE - absolute pathname to the parameter file for the Tomcat resource
    #    HAS_RS - name of the HAStoragePlus SC resource 
    #             (it can be a , separated list for the dependencies)
    #
    
    RS=
    RG=
    PORT=8080
    LH=
    SCALABLE=false
    PFILE=
    HAS_RS=

    The following is an example for Apache Tomcat.


    RS=tomcat-res
    RG=tomcat-rg
    PORT=8080
    LH=tomcat-lh
    SCALABLE=true
    PFILE=/tomcat/pfile
    HAS_RS=Apache-Tomcat-has-resource

    The parameter LH need to be configured as the name of the shared address. The parameter HAS_RS needs only to be set when an other file system (GFS or local file system) is used and the appropriate Apache-Tomcat-has-resource is created.

  11. After editing sctomcat_config you now need to register the resource.


    # ./sctomcat_register
    

    Repeat the last three steps for every Apache Tomcat instance you need.

  12. Enable each Apache Tomcat resource.

    Repeat this step for each Apache Tomcat resource created in the previous step.


    # scstat 
    

    # scswitch -e -j Apache-Tomcat-resource