Thursday, March 11, 2010

multiple tomcat instance – single setup

Tagged with: ,
Thursday, December 27, 2007, 16:30
This news item was posted in HowTo & Tutorial category and has 14 Comments so far.

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

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

You can leave a response, or trackback from your own site.

14 Responses to “multiple tomcat instance – single setup”

  1. yongcheolKim said on Thursday, January 31, 2008, 14:31

    참고

  2. sanjeev said on Tuesday, March 25, 2008, 8:08

    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 said on Tuesday, March 25, 2008, 8:15

    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 said on Wednesday, March 26, 2008, 1:07

    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 said on Thursday, March 27, 2008, 2:07

    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 said on Thursday, March 27, 2008, 2:36

    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 said on Thursday, March 27, 2008, 2:45

    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 said on Thursday, March 27, 2008, 5:15

    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 said on Friday, March 28, 2008, 4:42

    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 said on Friday, March 28, 2008, 4:57

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

  11. sanjeev said on Friday, March 28, 2008, 6:16

    HI,

    Thanks it’s working fine.

    sanjeev

  12. sanjeev said on Tuesday, April 15, 2008, 6:50

    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 said on Friday, April 18, 2008, 7:30

    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.

  14. shyamala said on Friday, February 26, 2010, 5:42

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

    Shyamala

Leave a Reply