ए भाई Think ज़रा हटके
Note: amtyThumb must be installed for new version of amty thumb post/recent

Running Multiple Tomcat instances

  1. Install Tomcat in /opt/tomcat. (You can choose different path as well. You are independent after all)
  2. Create two directories beneath /opt/, say article-stack.com and thinkzarahatke.com, to keep 2 separate instances of Tomcat.
  3. Create required sub-directories in article-stack.com and thinkzarahatke.com.
  4. #cd thinkzarahatke.com
    #mkdir common logs temp server shared webapps work conf
    
  5. Copy all contents of conf directory from installed Tomcat distribution to newly created conf directory in step 3.
  6. #cp -a $CATALINA_HOME/conf conf/.
    

    Tomcat Multiple Instance directory structure Mockup 

  7. Since both Tomcat instance must run from different ports, change port number in both server.xml (/opt/thinkzarahatke.com/conf/server.xml and /opt/article-stack.com/conf/server.xml). Keep port number different in both server.xml.
  8. <Server port="8007" shutdown="SHUTDOWN">
    :
    <!-- Define a non-SSL HTTP/1.1 Connector on port 8080 -->
    <Connector port="8081" maxHttpHeaderSize="8192"
    maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
    enableLookups="false" redirectPort="8443" acceptCount="100"
    connectionTimeout="20000" disableUploadTimeout="true" />
    
    
  9. Now, you must set the CATALINA_HOME environment variable to where you installed the Tomcat binary distribution (ie /opt/tomcat) and you must set the CATALINA_BASE environment variable to a different path where you are storing a JVM instance’s files (ie /opt/article-stack.com and /opt/thinkzarahatke.com)
    1. Create start.sh & stop.sh script to run particular Tomcat instance
    2. Put following contents inside start.sh
    3. #!/bin/sh
       set CATALINA_BASE="/opt/article-stack.com "
       set CATALINA_HOME="/opt/tomcat"
       export CATALINA_BASE CATALINA_HOME
       service tomcat start 	# Standard way to start on Linux
      
    4. Put following contents inside stop.sh
    5. #!/bin/sh
       set CATALINA_BASE="/opt/article-stack.com "
       set CATALINA_HOME="/opt/tomcat"
       export CATALINA_BASE CATALINA_HOME
       service tomcat stop # Standard way to stop on Linux
      
    6. Repeat all 3 steps for another instance. But change the value of CATALINA_BASE to “/opt/thinkzarahatke.com”
  10. #mkdir /opt/article-stack.com/bin
    #cd /opt/article-stack.com/bin
    
Amit Gupta

Hey! this is Amit Gupta (amty). By profession, I am a Software Eng. And teaching is my passion. Sometimes I am a teacher, as you can see many technical tutorials on my site, sometimes I am a poet, And sometime just a friend of friends...

532
views


To book below area mail me




  • I had once a requirement for having multiple instances of tomcat on same machine and for that I created a small too so that these steps could be automated. See if you like it.

  • thanks, Sandeep.

captcha

You can follow any responses to this entry through the RSS 2.0 feed.