multiple tomcat instance - single setup

Thursday, December 27, 2007 16:30
Posted in category Configuration

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%\..\work\810
catalina run



set JAVA_OPTS=-Dtomcat.server.port=820
set CATALINA_TMPDIR=%cd%\..\work\820
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
  • description
  • Wists
  • Technorati
  • YahooMyWeb
  • Furl
  • Slashdot
  • Google
  • Reddit
  • StumbleUpon
You can leave a response, or trackback from your own site.

13 Responses to “multiple tomcat instance - single setup”

  1. yongcheolKim says:

    January 31st, 2008 at 2:31 pm

    참고

  2. sanjeev says:

    March 25th, 2008 at 8:08 am

    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.

  3. altuure says:

    March 25th, 2008 at 8:15 am

    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

  4. sanjeev says:

    March 26th, 2008 at 1:07 am

    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

  5. altuure says:

    March 27th, 2008 at 2:07 am

    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

  6. sanjeev says:

    March 27th, 2008 at 2:36 am

    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

  7. altuure says:

    March 27th, 2008 at 2:45 am

    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,

  8. sanjeev says:

    March 27th, 2008 at 5:15 am

    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

  9. sanjeev says:

    March 28th, 2008 at 4:42 am

    hi,

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

    webapplication.xml is :

    please help..

    Thanks,
    Sanjeev

  10. altuure says:

    March 28th, 2008 at 4:57 am

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

  11. sanjeev says:

    March 28th, 2008 at 6:16 am

    HI,

    Thanks it’s working fine.

    sanjeev

  12. sanjeev says:

    April 15th, 2008 at 6:50 am

    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

  13. Gorav says:

    April 18th, 2008 at 7:30 am

    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.

Leave a Reply