Creating Multiple Tomcat Instances


This tutorial explains how to create multiple tomcat instances

What is 'Multiple instances' and why do I need it

Multiple tomcat instaces means, there are more than one tomcat servers running on its own process. Each instance runs on it's own java virtual machine, with it's own configuration. Each instance can have different memory settings, Each instance can be started and shutdown independent of other instances.

How to create multiple tomcat instances

  1. Download latest tomcat (tomcat 7 at the time of writing this tutorial) and extract it wherever you want. We will call it CATALINA_HOME.
  2. Create a new directory at any location and rename it to instance1. This would be our instance 1
  3. Create one another directory for instance2
  4. Copy conf,logs,temp,webapps and work directories from CATALINA_HOME to both of the instance directories that we created above.
  5. Modify the conf/server.xml files in each of the instances and change the ports so that all three ports are different on both of the instances. See this tutorial on How to change tomcat default ports
That's it, you just setup two seperate tomcat instances. Now you have to create a startup script for both of the instances.

startup script for instance 1

set CATALINA_HOME=<the directory where you have extracted tomcat>
set CATALINA_BASE=<path to your instance 1 directory>
start %CATALINA_HOME%\bin\catalina.bat start
Do the same for instance 2. Now you can use this scripts to start your tomcat instances. You can have both of the instances running at the same time too.

No comments:

Post a Comment