Thursday, May 15, 2008

Creating Multi Instances in Tomcat6


Currently my company is using Sun ONE Application Server 7 as their production application server. There are more than ten instances are running so far. Recently, I was requested to set up another server as a backup. Initially, I planned to use Glass Fish as my first option. Unfortunately, I was given an old PC (-_-") and it works very slow after I started ten instances in the same time. Then I have to switch to my second option which is tomcat. I have gone through lots of web site which explained how to create multiple instance of tomcat in one server. I have tried according to their suggestion.Therefore, I have finalized them in quick steps as following:

1. Considering that the tomcat is working fine in the first place.

2. I want to create two instances: server1 and server2.

3. Copy 5 folders from tomcat folder which are conf, logs, temp, webapps, work to another folder for example /$CATALINA_HOME/instances/server1/ and /$CATALINA_HOME/instances/server2

3. Edit the server.xml which is located in conf for each instance.

4. Change the server port for < port="8005" shutdown="SHUTDOWN">
This 8005 is the default value, so you may change it for example 8105 for server1 and 8205 for server2. (This value is totally different for each instance)

5. Change the connector port for < Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />

This 8080 is the defult value, therefore change it to for example 8081 for server1 and 8082 for server2. (This value is totally different for each instance)

6. Change the connector port for < port="8009" protocol="AJP/1.3" redirectport="8443"> to 8019 for server1 and 8029 for server2. (This value is totally different for each instance)

7. Before starting the tomcat new instance, you need to export the CATALINA_BASE=[instance path]. For example, in order to start the server1,

#CATALINA_BASE=$CATALINA_HOME/instances/server1
#export CATALINA_BASE
#$CATALINa_HOME/bin/startup.sh

8. Yupe, the tomcat instance has started.

These are the steps that I have done to create 2 instances of tomcat. You can create as many as you can (or your server can).
So do correct me, if I have done some mistakes or missed out something else.

Actually I am writing a shell script to ease my job. That is starting 10 instances in the same time. I will share here in next post.

No comments: