multiple tomcat instance – single setup

running multiple tomcat by using a single catalina_base and catalina_home

this will make it easy to manage server management to use only one tomcat setup instance

download tomcat-6+ and unpack it.

and modify two configuration file under conf

replace ports & access log and cluster instance name with variables like:

<Server port="${tomcat.server.port}1" shutdown="SHUTDOWN">...
<Connector port="${tomcat.server.port}2" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />...
<Engine name="Standalone" defaultHost="localhost" jvmRoute="${tomcat.server.port}">

change log file prefix like

1catalina.org.apache.juli.FileHandler.prefix = ${tomcat.server.port}.catalina


and before you run the command you should set 2 enviroment varilable for each instance like

set JAVA_OPTS=-Dtomcat.server.port=810
set CATALINA_TMPDIR=%cd%..work810
catalina run



set JAVA_OPTS=-Dtomcat.server.port=820
set CATALINA_TMPDIR=%cd%..work820
catalina run

NAME SHUTDOWN HTTP AJP
810 8101 8102 8103
820 8201 8202 8203

and you have 2 tomcat instance :)

for apache load balance setup see:

Complete Apache 2.2-AJP Load Balance via mod_proxy

Tomcat Port Configuration

Share and Enjoy:
  • Digg
  • del.icio.us
  • Netvouz
  • DZone
  • Wists
  • LinkedIn
  • Slashdot
  • Google Bookmarks
  • Reddit
  • StumbleUpon
  • email
  • Twitter
  • FriendFeed

Related posts:

  1. tomcat port configuration
  2. Complete Apache 2.2-AJP Load Balance via mod_proxy
  3. URI Encoding for tomcat 5.5.X
  4. Configure Apache:virtual host, mod_proxy and mod_proxy_ajp
  5. top posts 2008 at altuure.com

    • yongcheolKim
    • January 31st, 2008

    참고

    • sanjeev
    • March 25th, 2008

    How can i install multiple tomcat instances sharing same web application i.e. there should be common place for web application shared by all tomcat server.

  1. hi sanjeev,
    in fact this installation works in a single directory and allows you run this single tomcat home multiple times by changing a single system property (environment variable). so all instances are running in a single directory.

    to do like things you should change several conf file mentioned above:
    server.xml
    catalina.properties
    and set tomcat.server.port for tomcat startup ports

    • sanjeev
    • March 26th, 2008

    Thanks Sir for reply

    actually i have 4 tomcat instances with cluster setup e.g. tomcatA,tomcatB,tomcatC,tomcatD and have application in each server now whenever i need to change something in application i have to change in 4 places so i want a common place like C:/webapplication where i put my application and shared by all tomcat, so for this what should i need to change.

    Thanks,

    sanjeev

  2. Hi again,
    in this case there are multiple solutions,

    first and most simple one is to use a context.xml file for your application and set a docBase eg: c:\webapplication

    like: file:conf/Catalina/localhost/webapplication.xml
    content:

    <Context path="/webapplication" docBase="c:/webapplication">
    </Context>

    I hope this would help

    • sanjeev
    • March 27th, 2008

    Hello,

    should i need to create webapplication.xml file in every tomcat instance or i need to put

    this entry into context.xml file.

    can you please give me a sample .xml file for the same

    Thanks,

    sanjeev

  3. Hi,
    I have give a sample in my previous post,
    you should use this (webapplication.xml) file under:
    CATALINA_BASE/ conf/Catalina/localhost/webapplication.xml
    its content is just single line

    <Context path=”/webapplication” docBase=”c:/webapplication”>
    </Context>

    and rest would work,

    • sanjeev
    • March 27th, 2008

    Hello,

    Thanks for ur quick reply

    i have done this, i have created ebapplication.xml file in each tomcat like (tomcatA\conf). but it is not using application from C:/webapplication path.
    Should i remoce application from tomcat instance or is there another setting.

    Thanks

    Sanjeev

    • sanjeev
    • March 28th, 2008

    hi,

    i have created webapplication.xml and put it into /webapps but it is not working…

    webapplication.xml is :

    please help..

    Thanks,
    Sanjeev

  4. hi sanjeev ,
    you should put it into CATALINA_BASE/conf/Catalina/localhost/
    not in CATALINA_BASE/webapps

    • sanjeev
    • March 28th, 2008

    HI,

    Thanks it’s working fine.

    sanjeev

    • sanjeev
    • April 15th, 2008

    Hello ,

    I have done tomcat clustering using Apache.and in my web application i have an HttpListener Class in which i am updating database for user log out when session timeout.

    when one of tomcat instance in clustering is down then it’s session value is replicated to others and user do work properly.

    Now My problem is when i shut down one of cluster instance then it call the Listener Class and updates the Database and marks the user as logout….

    I do not want to call the listener class OR how can i know that tomcat is shut down e.g. any event that i can get so that i will not update database.

    Please give your valuable ideas…..

    Thanks,
    Sanjeev

    • Gorav
    • April 18th, 2008

    Hi I have just started on Clustring of Tomcat and load balancing. I do not have very much doc support for the clustering so please do guide me so that I can start working. Till Now I have changed the Port number of my 2 Tomcat instances in server.xml. But for each deployment I need to write http://localhost:port number/appName

    That brings in my mind if the port number will changed then the context will change.

  5. Kindly can u help me in installing tomcat multiple instances where am using Tomcat6.0 ….

    Shyamala

  1. No trackbacks yet.