Page tree
Skip to end of metadata
Go to start of metadata


Purpose

This page describes the method to deploy several tomcat instances

http://tomcat.apache.org/tomcat-7.0-doc/RUNNING.txt


Details


1. Install your first instance of Apache Tomcat


Just download an Apache Tomcat Windows Service Installer. Just follow the steps to install.
And I would expect the software to be installed at this directory "C:\Program Files\Apache Software Foundation\Tomcat x.y".

Default installation should be as : 

Remark : in the following parts, we will call %CATALINA_HOME% the install root directory

2. Duplicate Tomcat configuration


A tomcat instance base structure must be deployed into other directories

  • Create as many sub-directories under the %CATALINA_HOME% as required (like "%CATALINA_HOME%\N01") .
    (info) These folders will be dedicated to the other required tomcat nodes.
     
  • Copy the folder "%CATALINA_HOME%\conf" into these sub-directories (%CATALINA_HOME%\N01\conf)
     
  • Create the sub-directories "temp", "logs", "webapps" into the directories %CATALINA_HOME%\N01...
     
  • If you plan to use the tomcat manager, deploy this web-application into the created nodes :
     
    • Copy the folder "%CATALINA_HOME%\webapps\manager" into the folders "%CATALINA_HOME%\N01\webapps\manager"


3- Configure the apache tomcat instances


(info) By default, Apache Tomcat installer configured serval ports. For example Connector Port, Shutdown Port, AJP(Apache JServ Protocol) Connection Port & Redirect Port, to run the service.

In order to get multiple Tomcat instances running on a single machine, we need to configure the ports on each instance by modifying for each Tomcat node, the file "%CATALINA_HOME%\N01\conf\server.xml" as :

  • (info) Connector Port:  8080 is the default port where Apache Tomcat listen to HTTP request.
    Use your expected one by changing the port number identified with the following tag :

    <connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
  • (info) Shutdown Port: 8005 is the port used to shutdown the Apache Tomcat.
    Use your expected one by changing the port number identified with the following tag :

     <server port="8005" shutdown="SHUTDOWN">
  • (info) AJP (Apache JServ Protocol) Connector Port: The Apache JServ Protocol (AJP) is a protocol that  conduct inbound requests from a web server to an application server that sits behind the web server. 
    Use your expected one by changing the port number identified with the following tag :

     <connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
  • (info) Redirect Port: Any redirection happening inside Apache Tomcat will happen through this port. In the server.xml, there are two places mentioned the redirectPort.
    Use your expected one by changing the port number identified with the following tag :

    <connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
    <connector port="8100" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
    

4. Install Windows Services


To start a Tomcat instance, we need to create a Windows Service which quick start the instance by supplying corresponding parameters.

  • Open a DOS prompt, and navigate to Tomcat's bin directory (%CATALINA_HOME%\bin)
     
  • To install a Windows service, set the CATALINA_HOME environment variable to the Tomcat installation directory (contained in %CATALINA_HOME%).
  • Then create a second environment variable CATALINA_BASE and point this to the instance folder (%CATALINA_HOME%\N01)

  • Check the environment variable JAVA_HOME is set.

  • Install the service and edit it to check its content with the next block of command lines.

    (warning) Don't forget  to modify the node name in parameters "//IS//N0" and "--DisplayName="Tomcat N01"
C:\>set CATALINA_HOME=C:\Program Files\Apache Software Foundation\Tomcat 7.0
C:\>set CATALINA_BASE=C:\Program Files\Apache Software Foundation\Tomcat 7.0\N01
C:\>set JAVA_HOME=C:\Program Files\Java\jre6
C:\>"%CATALINA_HOME%\bin\tomcat7.exe" //IS//N01 --DisplayName="Tomcat N01" 
--Startup auto
--Install="%CATALINA_HOME%\bin\tomcat7.exe" 
--JavaHome="%JAVA_HOME" --Classpath="%CATALINA_HOME%\bin\bootstrap.jar;%CATALINA_HOME%\bin\tomcat-juli.jar" 
--JvmOptions="-Dcatalina.home=%CATALINA_HOME%" 
--JvmOptions="-Dcatalina.base=%CATALINA_BASE%" 
--JvmOptions="-Djava.endorsed.dirs=%CATALINA_BASE%\endorsed" 
--JvmOptions="-Djava.io.tmpdir=%CATALINA_BASE%\temp" 
--JvmOptions="-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager" 
--JvmOptions="-Djava.util.logging.config.file=%CATALINA_BASE%\conf\logging.properties" 
--LogPath="%CATALINA_BASE%\logs" --StdOutput="auto" --StdError="auto" 
--StartMode=jvm --StartClass=org.apache.catalina.startup.Bootstrap --StartParams=start --StartPath="%CATALINA_BASE%" 
--StopMode=jvm  --StopClass=org.apache.catalina.startup.Bootstrap  --StopParams=stop   --StopPath="%CATALINA_BASE%" 

(lightbulb) In order to check or edit your settings, you can edit the new service with this command line

C:\>"%CATALINA_HOME%\bin\tomcat7w.exe" //ES//N01  



Notes / Comments



Related Pages


  • No labels