Note: Please go to docs.rightscale.com to access the current RightScale documentation set. Also, feel free to Chat with us!
Home > ServerTemplates > v12.11 LTS > ST > Tomcat App Server (v12.11 LTS) > Tomcat App Server (v12.11 LTS) - Tutorial

Tomcat App Server (v12.11 LTS) - Tutorial

 

 


Table of Contents    

Long Term Support

icon-lts-v1.png

Stable, tested ServerTemplate assets

     ►  Tutorial

Objective

To set up a combined Tomcat and Apache application server in a public or private cloud environment.

Prerequisites

  • 'actor', 'designer', and 'library' user role privileges in the RightScale account
  • For Amazon EC2, CloudStack, and other clouds that support security groups, you must have a security group defined with TCP port 22 open for SSH access, the default application port (8000) open to applicable load balancer servers, and any other port and protocol access required by your application. Also, remember that iptables is installed by default on all servers.
  • We strongly recommend that you set up credentials for password values and any other sensitive data included as Chef recipe inputs. Also, some default input values assume that predefined credentials exist, as described in Create Credentials for Common Inputs.
  • This tutorial assumes that you are setting up application servers that will function as part of a three-tier architecture that includes both back-end MySQL database servers and front-end load balancers. For information on setting up your database servers, see Database Manager for MySQL 5.1/5.5 Database Setup.
  • This tutorial assumes you are connecting the application servers to dedicated load balancing servers launched with RightScale's "Load Balancer with HAProxy" ServerTemplate. However, you can also connect application servers to a cloud provider's load balancing service such as Amazon's Elastic Load Balancing (ELB) or Rackspace's Cloud Load Balancing (CLB). 

Overview

This tutorial describes the steps for launching one or more application servers in the cloud.

For a technical overview of this ServerTemplate, see Tomcat App Server - Overview.

Create Credentials

In order to use the default input values in the ServerTemplate, you must set up credentials with the following names. For more information on setting up credentials, see Create a New Credential.

  • DBAPPLICATION_USER - Username to add to the MySQL database server for application access.
  • DBAPPLICATION_PASSWORD - Password for DBAPPLICATION_USER.
  • GIT_SSH_KEY (Optional) - If you are downloading application files from a private Git repository, create a credential for the contents of the private Git SSH key, which is used to access the repository.
  • RACKSPACE_USERNAME, RACKSPACE_AUTH_KEY (Optional) - If you are using Rackspace, you should create credentials for your Rackspace username and API key.

Steps

Prepare Application Code

The ServerTemplate supports the ability to download your application code either as a tarball (.tgz) from a Remote Object Storage location or checkout the codebase from a software repository.

  • Remote Object Storage (ROS)
    • Amazon S3
    • Rackspace Cloud Files
    • SoftLayer Object Storage
  • Software Repository
    • Git
    • SVN

Remote Object Storage (ROS)

  • Amazon S3 Bucket
  • Rackspace Cloud Files Container
  • SoftLayer Object Storage Container


If you have a tarball of your application, upload it to a Remote Object Storage location as either a 'public-read' or 'private' object. If you are using a 'private' object you must provide valid cloud credentials (as inputs) for authentication purposes in order to properly retrieve the object. For more information see the following tutorials.

Software Repository

  • Git
  • SVN


If you want to checkout your application code from a software repository (e.g. GitHub), you will need to provide your access credentials as inputs later in this tutorial so that a script can be executed to automatically retrieve your application code.

Sample Application

If you need a example application for testing purposes, you can use the application code from the following git repository.

  • Repository URL - git://github.com/rightscale/examples.git
  • Project App root - Set to "No value/ignore" or "Inherit:no value to inherit"
  • Git SSH Key - Set to "No value/ignore" or "Inherit:no value to inherit"
  • Repository Provider - repo_git
  • Branch/Tag - unified_tomcat

Create the Application Tier

You can either add application servers directly into a deployment or create an server array of application servers for autoscaling. 

Import the ServerTemplate

  1. Go to the MultiCloud Marketplace (Design > MultiCloud Marketplace > ServerTemplates) and import the most recently published revision of the following ServerTemplate into the RightScale account.
  2. (Optional) If you expect to make changes to the ServerTemplate, you will need to clone it to create an editable copy.  Click the Clone button and rename the ServerTemplate accordingly. (e.g. My App Server) Before you make any changes to the ServerTemplate, click the Commit button so that the first revision of the ServerTemplate matches the original revision, which will make it easier to perform differentials in the future to see what changes were made to the "original" version. When committing the ServerTemplate you can use a simple commit message. (e.g. Original version. No changes.) If you are actively developing the ServerTemplate, you may find it useful to use the HEAD version of the ServerTemplate to create the application server tier. However, for production environments, you should always use static, committed revisions of a ServerTemplate to launch servers.

Create a Server or Server Array

When you create a server or server array, you will first need to select a deployment and the cloud where the server will eventually be launched into (e.g. AWS us-east). Based on the chosen cloud provider, you will need to complete the configuration process that's specific for that cloud. For example, some cloud providers support features that are unique to their specific cloud. 

  • To create a server, click the Add Server button and complete the steps in the wizard. See Add Server Assistant for details. If you are setting up a multi-tier deployment, it's strongly recommended that you create at least two application servers.
    • The easiest way to create the second server is to clone the first one. Be sure to change the name of the server accordingly (e.g. app2) and its availability zone (if available) under the the Info tab.
  • To create a scalable server array, click the Add Array button and complete the steps in the wizard. See Add Server Array Assistant for details. 

Configure Inputs

The next step is to define the properties of your application server by entering values for inputs. It is best to do this at the deployment level. For a detailed explanation of how inputs are defined and used in Chef recipes and RightScripts, see Inputs and their Hierarchy.

To enter inputs for the Chef recipes that will run on your application servers, open the deployment's Inputs tab and click Edit, then follow the directions below to configure input values. We recommend that you set up credentials for password values and any other sensitive data as shown in the examples.

Note: The following examples and sample values assume that you will connect the application server with RightScale's "Load Balancer" ServerTemplate, which uses HAProxy. If you are using a cloud's load balancing service such as Rackspace Cloud Load Balancing (CLB) or Amazon's Elastic Load Balancing (ELB), please refer to the runbook for proper setup instructions.

APP

Input Name
Description
Example Value

Application Listen Port

The port that the application service listens on to accept requests from the load balancer. If you specify another port than the 8000 (default), be sure to add the port to the "Firewall Rule Port" input and make sure that the security group's settings also allow access (if applicable).

text:  8000

APP_TOMCAT

Input Name
Description
Example Value

War file for ROOT

The path to the war file relative to project repository's root directory. Will be renamed to ROOT.war. (e.g. /dist/app_test.war)

Note: This value should match the value specified for the 'Project App root' input.

text:  /

For the provided sample application:
text: /home/webapps

Database Schema Name Name of the MySQL database to which applications on the server will connect. It is also used to set up the application server's database configuration file.

text:  my_db_schema

For the provided sample application:
text: yourName_schema

DB_MYSQL

Input Name Description Example Value
MySQL Version Specify the version of the MySQL database that the application servers will connect to. (e.g. 5.1, 5.5) text:  5.1

DB

Input Name
Description
Example Value

Database Application Password

Database Application Username

Database username and password to add to the MySQL database server for application access.

cred:  DBAPPLICATION_USER

cred:  DBAPPLICATION_PASSWORD

Database Master FQDN

Fully qualified domain name for the master MySQL database server. Application servers use this input to locate the "master" database server.

text:  master-db.example.com

 

LB

Input Name
Description
Example Value

Load Balancer Provider

Select the type of load balancer (or service) that the application server(s) will connect to. 

  • lb_haproxy - Dedicated load balancer servers launched with RightScale's HAProxy "Load Balancer" ServerTemplate
  • lb_elb - Amazon Elastic Load Balancing (ELB) service
  • lb_clb - Rackspace Cloud Load Balancing (CLB) service

text:  lb_haproxy

For the provided sample application:
text:  lb_haproxy

Virtual Host Names

If you are using an HAProxy load balancer ('lb_haproxy'), specify the virtual host name that will be used by the application server to connect to the correct load balancer server. 

Note: A load balancer can have multiple virtual host names. If a load balancer is serving requests to multiple virtual host names, the virtual host name that the application server will use must be included in the list otherwise it will connect to the "default" virtual host name, which is the first one in the list.

text:  default

For the provided sample application:
text:  default

Load Balance Service ID

Load Balance Service Secret

For CLB, specify the Rackspace username and API key to use for authentication purposes.

For ELB, specify the Amazon access key ID and secret access key for authentication purposes.

cred: RACKSPACE_USERNAME
cred: RACKSPACE_AUTH_KEY

cred: AWS_ACCESS_KEY_ID
cred: AWS_SECRET_ACCESS_KEY

Load Balance Service Name The name of the Amazon Elastic Load Balancer (ELB) or Rackspace Cloud Load Balancer (CLB). text: my-lb-name
Load Balance Service Region

Note: Input only applies to a Rackspace Cloud Load Balancer (CLB).

For a CLB, select the Rackspace region of the Cloud Load Balancer. It's recommended that you create your CLB in a region as close to your application servers as possible.

  • ORD (Chicago)
  • LON (London)
  • DFW (Dallas/ Ft. Worth)
text: ORD

REPO

The values that you use for the repository inputs will depend on where the application code will be retrieved from. The selection for the Repository Provider input will determine which inputs will be used to retrieve the application. Unrelated inputs are ignored.

ALL Repositories (ROS, Git, SVN)

The following inputs are used to retrieve the application from either a Git/SVN software repository or an ROS location (Amazon S3 bucket or Rackspace Cloud Files container). Specify the appropriate inputs based upon the selection for the 'Repository Provider' input.

Input Name
Description
Example Value
Project App root

The destination location where the application code will be placed on the local instance. If you want the application code to be placed in the root directory, use a forward slash (/) otherwise you will need to specify the full path (e.g. /path/to/code). If set to 'ignore' the default location (/home/webapps) will be used. The 'Application Name' input is used to name the destination folder into which the application code will be placed. Apache and Tomcat will look for the application in the specified path.

Note: This value should match the value specified for the 'War file for ROOT' input.

text:  /home/webapps

For the provided sample application:
rext:  /home/webapps

Repository Provider

Specify where the application code should be checked out from.

  • repo_git - Git repository
  • repo_svn - SVN repository
  • repo_ros - Remote Object Store. (Amazon S3 or Rackspace Cloud Files) Select this option to download a tarball (.tgz) of your application code.

text:  repo_ros

For the provided sample application:
text:  repo_git

Action

Specify how the application code will be pulled from the specified repository.

  • pull - standard repository pull
  • capistrano_pull - standard repository pull plus a capistrano deployment style is applied.

text:  pull

For the provided sample application:
text:  pull

Git Repository

Important!
If you are checking out code from a Git repository, specify values for the following inputs.

Input Name
Description
Example Value
Git SSH Key In order to check out application code from a private (not public) Git repository, you must provide the repository's SSH key (e.g. Git SSH Key) for authentication purposes. Set to 'ignore' if you are using an application in a repository that allows 'public-read' access.

cred:  GIT_SSH_KEY

For the provided sample application:
inherit:  no value to inherit

Repository URL The URL that points to the location of the repository that contains the application code. Specify a "read-only" URL. (e.g. git://github.com/username/myapp.git) 

text:  git://github.com/username/myapp.git 

For the provided sample application:
text:  git://github.com/rightscale/examples.git

Branch/Tag

The specific branch/tag/SHA of the specified Git repository that the application code should be checked out from. (e.g. mybranch) Use "master" to retrieve the master branch from the repository.

text:  mybranch

For the provided sample application:
text:  unified_tomcat

SVN Repository

Important!
If you are checking out code from a SVN repository, specify values for the following inputs.

Input Name
Description
Example Value
Repository URL The URL that points to the location of the repository that contains the application code. Specify a "read-only" URL. (e.g. https://mysvn.net/app)

text:  https://mysvn.net/app

SVN Password

SVN Username 

The username and password required to access and retrieve the application code from the specified SVN repository.

cred:  SVN_USER

cred:  SVN_PASSWORD

Branch/Tag The specific branch or tag of the specified SVN repository that the application code should be checked out from. (e.g. mybranch) Use "trunk" to retrieve the main branch from the repository. text:  mybranch
Remote Object Storage (ROS)

Important!
If you are checking out code from a Remote Object Storage (ROS) location, specify values for the following inputs.

Input Name
Description
Example Value
ROS Container

The name of the Remote Object Storage (ROS) container where a tarball (.tgz) of the application code will be retrieved from.

  • Amazon S3 - bucket name
  • Rackspace Cloud Files - container name
  • SoftLayer Object Storage - container name
text:  my-container

ROS Prefix

The prefix that will be used to locate the correct tarball of the application. For example, if you're using 'myapp.tgz' specify 'myapp' as the ROS Prefix.

text:  myapp

ROS Storage Account ID

In order to retrieve a tarball of the application code that's a "private" object within the specified Remote Object Storage (ROS) location, you must provide proper cloud authentication credentials. For security reasons, it's recommended that you create and use credentials for these values instead of entering the text value.

  • Amazon S3 - Amazon Access Key ID (e.g. cred: AWS_ACCESS_KEY_ID)
  • Rackspace Cloud Files - Rackspace login username (e.g. cred: RACKSPACE_USERNAME)
  • SoftLayer Object Storage - SoftLayer Account ID (e.g. cred: SOFTLAYER_USER_ID)
text:  AWS_ACCESS_KEY_ID
ROS Storage Account Provider

 

The Remote Object Storage (ROS) service where the tarball of the application code will be retrieved from.

  • s3 - Amazon S3 
  • cloudfiles - Rackspace Cloud Files (United States)
  • cloudfilesuk - Rackspace Cloud Files (United Kingdom)
  • SoftLayer_Dallas - SoftLayer's Dallas (USA) cloud
  • SoftLayer_Singapore - SoftLayer's Singapore cloud
  • SoftLayer_Amsterdam - SoftLayer's Amsterdam cloud
text:  S3
ROS Storage Account Secret

In order to retrieve a tarball of the application code that's a "private" object within the specified Remote Object Storage (ROS) location, you must provide proper cloud authentication credentials. For security reasons, it's recommended that you create and use credentials for these values instead of entering the text value.

  • Amazon S3 - AWS Secret Access Key (e.g. cred: AWS_SECRET_ACCESS_KEY)
  • Rackspace Cloud Files - Rackspace Account API Key (e.g. cred: RACKSPACE_AUTH_KEY)
  • SoftLayer Object Storage - SoftLayer Authentication Token (e.g. cred: SOFTLAYER_API_KEY)
cred:  AWS_SECRET_ACCESS_KEY

WEB_APACHE

Input Name
Description
Example Value
Application Name

On your application servers, the server subdirectory where your application code files are stored.

If you are using dedicated load balancer servers launched with RightScale's "Load Balancer with HAProxy" ServerTemplate, this value must match the Application Name input for your load balancer servers.

text:  myapp
Multi-Processing Module Set to "worker" for a Tomcat application server. text:  worker

Launch the Server

After configuring your inputs, launch all of the Tomcat application servers. Refer to the instructions in Launch a Server if you are not already familiar with this process.

You must to post a comment.
Last modified
10:29, 29 Apr 2014

Tags

Classifications

This page has no classifications.

Announcements

None


© 2006-2014 RightScale, Inc. All rights reserved.
RightScale is a registered trademark of RightScale, Inc. All other products and services may be trademarks or servicemarks of their respective owners.