Installing Tomcat in a Sensible Way in an EC2 Cloud Machine: Part 3




Part 1 2 3 4

Putting it All Together





So, based on the brilliant approach presented by Filip Hanik at SpringSource, let’s build a directory layout and a script or two that will make deployment, management, version control, and resource management intuitive.
An interesting aspect to Filip’s presentation was that he proposed having a TC instance per application. This allows for isolation of your applications in a way that doesn’t allow performance or memory issues of one application to affect other applications. This does present more management overhead and certainly once things are clearly stable, they could be deployed in a combined environment but it was an approach I hadn’t thought of.

The directory structure

  • /usr/local/tomcat/apache-tomcat-6.0.18/
    This will be the basic TC install for a given version. The run script will be referencing this
  • /usr/local/tomcat/run.sh
    The key to it all. This script will take a start|stop|run input as well as instance number(1 or 2 or etc.)
  • /usr/local/tomcat/shared/
    This folder will contain shared instance data if you do not provide it at the instance level. So if you want to provide a specific server.xml for a given instance, place it in
    instance/conf/server.xml, otherwise, the one in shared/ will be used.
  • /usr/local/tomcat/instance_1/
  • /usr/local/tomcat/instance_2/
  • /usr/local/tomcat/instance_n/
    These are specific TC instances.

Let’s examine some differences between instances

Instance_1 is running on port 8080 using jdk1.5 and has a connection timeout of 20 seconds and sets the JVM heap to 512m max and 192k per thread.

/usr/local/tomcat/instance_1/bin/setenv.sh
JAVA_HOME=”/usr/local/java/jdk1.5”
CATALINA_HOME=”/usr/local/apache_tomcat-6.0.18”
CATALINA_BASE=”/usr/local/tomcat/instance_1”
CATALINA_OPTS=”-Xmx512m –Xss192k”

/conf/catalina.properties
http.port=8080

/conf/server.xml
<Connector port=”${http.port}”
protocol=”HTTP/1.1”
connectionTimeout=”20000”  />

Instance_3 is running on port 8081 and is using jdk1.5 and has a connection timeout of 60 seconds

/usr/local/tomcat/instance_3/bin/setenv.sh
JAVA_HOME=”/usr/local/java/jdk1.6”
CATALINA_HOME=”/usr/local/apache_tomcat-6.0.18”
CATALINA_BASE=”/usr/local/tomcat/instance_3”

/conf/catalina.properties
http.port=8081

/conf/server.xml
<Connector port=”${http.port}”
protocol=”HTTP/1.1”
connectionTImeout=”60000”  />

You can hopefully see the beauty and the benefits of an approach like this. You can isolate instances, JVMs, applications, configurations. Or, you can share various pieces and isolate others.

If the Tomcat Seminar by SpringSource is coming to your town, it’s a great presentation for short money.

Post to Twitter Tweet This Post

,

  1. #1 by Rodney - November 24th, 2009 at 03:46

    Can you share the run.sh file described in the article (e.g. /usr/local/tomcat/run.sh)? I like the approach and would like to take a similar approach myself.

  2. #2 by Leonardo - July 14th, 2010 at 12:34

    Please… describe the file run.sh.

    Thz.

  3. #3 by Sigmund Lundgren - March 8th, 2011 at 17:37

    I have the run.sh

(will not be published)
  1. No trackbacks yet.