Sun Cluster Data Service for Apache Tomcat Guide for Solaris OS

Appendix B Deployment Example: Installing Apache Tomcat in a Failover Zone

This appendix presents a complete example of how to install and configure the Apache Tomcat application and data service in a non — global failover zone. It presents a simple two-node cluster configuration. If you need to install the application in any other configuration, refer to the general-purpose procedures presented elsewhere in this manual. For an example of Apache Tomcat installation in a global zone, see Appendix A, Deployment Example: Installing Apache Tomcat in the Global Zone or for an installation in a zone see Appendix C, Deployment Example: Installing Apache Tomcat in a Non-Global Zone according to your zone type.

Target Cluster Configuration

This example uses a two-node cluster with the following node names:

This configuration also uses the logical host name ha-host-1.

Software Configuration

This deployment example uses the following software products and versions:

This example assumes that you have already installed and established your cluster. It illustrates installation and configuration of the data service application only.

Assumptions

The instructions in this example were developed with the following assumptions:

Installing and Configuring Apache Tomcat on Global Storage in the Failover Zone

The tasks you must perform to install and configure Apache Tomcat in the failover zone are as follows:

ProcedureExample: Preparing the Cluster for Apache Tomcat

    Install and configure the cluster as instructed in Sun Cluster Software Installation Guide for Solaris OS.

    Install the following cluster software components on both nodes.

    • Sun Cluster core software

    • Sun Cluster data service for Apache Tomcat

    • Sun Cluster data service for Solaris Containers

ProcedureExample: Configuring Cluster Resources for Apache Tomcat

  1. Register the necessary data types on both nodes.


    phys-schost-1# clresourcetype register SUNW.gds SUNW.HAStoragePlus
    
  2. Create the Apache Tomcat resource group.


    phys-schost-1# clresourcegroup create RG-TOM
    
  3. Create the HAStoragePlus resource in the RG-TOM resource group.


    phys-schost-1# clresource create -g RG-TOM -t SUNW.HAStoragePlus -p AffinityOn=TRUE \
    -p FilesystemMountPoints=/global/mnt3,/global/mnt4 RS-TOM-HAS
    
  4. Enable the resource group.


    phys-schost-1# clresourcegroup online -M RG-TOM
    

ProcedureExample: Configuring the Failover Zone

  1. On shared cluster storage, create a directory for the failover zone root path.

    This example presents a sparse root zone. You can use a whole root zone if that type better suits your configuration.


    phys-schost-1# mkdir /global/mnt3/zones
    
  2. Create a temporary file, for example /tmp/x, and include the following entries:


    create -b
    set zonepath=/global/mnt3/zones/clu1
    set autoboot=false
    set pool=pool_default
    add inherit-pkg-dir
    set dir=/lib
    end
    add inherit-pkg-dir
    set dir=/platform
    end
    add inherit-pkg-dir
    set dir=/sbin
    end
    add inherit-pkg-dir
    set dir=/usr
    end
    add net
    set address=ha-host-1
    set physical=hme0
    end
    add attr
    set name=comment
    set type=string
    set value="Apache Tomcat cluster zone" Put your desired zone name between the quotes here.
    end
  3. Configure the failover zone, using the file you created.


    phys-schost-1# zonecfg -z clu1 -f /tmp/x
    
  4. Install the zone.


    phys-schost-1# zoneadm -z clu1 install
    
  5. Log in to the zone.


    phys-schost-1# zlogin -C clu1
    
  6. Open a new window to the same node and boot the zone?


    phys-schost-1a# zoneadm -z clu1 boot
    
  7. Close this terminal window and disconnect from the zone console.


    phys-schost-1# ~~.
    
  8. Copy the containers configuration file to a temporary location.


    phys-schost-1# cp /opt/SUNWsczone/sczbt/util/sczbt_config /tmp/sczbt_config
    
  9. Edit the /tmp/sczbt_config file and set variable values as shown:


    RS=RS-TOM-ZONE
    RG=RG-TOM
    PARAMETERDIR=/global/mnt3/zonepar
    SC_NETWORK=false
    SC_LH=
    FAILOVER=true
    HAS_RS=RS-TOM-HAS
    
    
    Zonename=clu1
    Zonebootopt=
    Milestone=multi-user-server
    Mounts=
  10. Create the zone according to the instructions in the Sun Cluster Data Service for Solaris Containers Guide.

  11. Register the zone resource.


    phys-schost-1# ksh /opt/SUNWsczone/sczbt/util/sczbt_register -f /tmp/sczbt_config
    
  12. Enable the zone resource.


    phys-schost-1# clresource enable RS-TOM-ZONE
    

ProcedureExample: Installing the Apache Tomcat Software on Shared Storage

These steps illustrate how to install the Apache Tomcat software in the directory /tomcat. As long as only one node is mentioned it needs to be the node where your resource group is online.

  1. Log in to the zone.


    phys-schost-1# zlogin clu1
    
  2. Add the tomcat group and user.


    zone# groupadd -g 1000 tomcat
    zone# useradd -g 1000 -d /tomcat -m -s /bin/ksh tomcat
    
  3. Install the Apache Tomcat binaries.


    zone# su - tomcat
    zone# gzcat apache-tomcat-5.5.17.tar.gz|tar xvf -
    zone# gzcat apache-tomcat-5.5.17-compat.tar.gz|tar xvf -
    
  4. Create your environment script /tomcat/env.kshwith the following contents.


    zone# cat env.ksh 
    #!/usr/bin/ksh
    JAVA_HOMME=/usr/j2se
    CATALINA_HOME=/tomcat/apache-tomcat-5.5.17
    export JAVA_HOME CATALINA_HOME
  5. Copy the Apache Tomcat configuration file from the agent directory to its deployment location.


    zone# cp /opt/SUNWsctomcat/bin/pfile /tomcat
    zone# chown tomcat:tomcat /tomcat/pfile
    
  6. Add this cluster's information to the parameter file /tomcat/pfile.

    The following listing shows the relevant file entries and the values to assign to each entry.


    .
    .
    .
    EnvScript=/tomcat/env.ksh
    User=tomcat
    Basepath=/tomcat/apache-tomcat-5.5.17
    Host=ha-host-1
    Port=8080
    TestCmd="get /index.jsp"
    ReturnString="CATALINA"
    Startwait=20
    
  7. Save and close the file.

  8. Leave the zone.

ProcedureExample: Modifying the Apache Tomcat Configuration Files

  1. Copy the Apache Tomcat configuration file from the agent directory to its deployment location.


    phys-schost-1# cp /opt/SUNWsctomcat/util/sctomcat_config /global/mnt3
    
  2. Add this cluster's information to the sctomcat_config configuration file.

    The following listing shows the relevant file entries and the values to assign to each entry.


    .
    .
    .
    
    RS=RS-TOM
    RG=RG-TOM
    PORT=8080
    LH=ha-host-1
    NETWORK=true
    SCALABLE=false
    PFILE=/tomcat/pfile
    HAS_RS=RS-TOM-HAS.
    .
    .
    ZONE=clu1
    ZONE_BT=RS-TOM-ZONE
    PROJECT=
    
  3. Save and close the file.

ProcedureExample: Enabling the Apache Tomcat Software to Run in the Cluster

  1. Run the sctomcat_register script to register the resource.


    phys-schost-1# ksh /opt/SUNWsctomcat/util/sctomcat_register \
    -f /global/mnt3/sctomcat_config
    
  2. Enable the resource.


    phys-schost-1# clresource enable RS-TOM