Friday, January 19, 2018

Tomcat multiple instances simultaneously

Let's say that you have only one Tomcat folder located in C:\apache-tomcat-7.0.39, and that you wish to run two instances from it.
Make sure that you have CATALINA_HOME system/user variable set, and pointing to C:\apache-tomcat-7.0.39
  1. Create a folder C:\instance1. Copy confwebapps and temp folders from C:\apache-tomcat-7.0.39 and paste them to C:\instance1. You can delete contents from webapps and temp folders located under instance1, but don't touch conf contents.
  2. Now copy>paste C:\instance1 and rename it to instance2. That way, both instance1 and instance2 will have the same content.
  3. Go to C:\instance2\conf, edit server.xml and change the numbers of these ports (I marked those as XXXX):
    <Server port="XXXX" shutdown="SHUTDOWN">
    <Connector port="XXXX" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
    <Connector port="XXXX" protocol="AJP/1.3" redirectPort="8443" />
  4. Deploy whatever you want into instance1\webapps and instance2\webapps
  5. Create the following 4 batch files under C:\
instance1_startup.bat
@echo off
set CATALINA_BASE=C:\instance1
cd "%CATALINA_HOME%\bin"
set TITLE=My Tomcat Instance 01
call startup.bat %TITLE%
instance1_shutdown.bat
@echo off
set CATALINA_BASE=C:\instance1
cd "%CATALINA_HOME%\bin"
call shutdown.bat
instance2_startup.bat
@echo off
set CATALINA_BASE=C:\instance2
cd "%CATALINA_HOME%\bin"
set TITLE=My Tomcat Instance 02
call startup.bat %TITLE%
instance2_shutdown.bat
@echo off
set CATALINA_BASE=C:\instance2
cd "%CATALINA_HOME%\bin"
call shutdown.bat
  1. Run instance1_startup.bat and instance2_startup.bat, hopefully it should work.

No comments:

Post a Comment

Recent Post

Databricks Delta table merge Example

here's some sample code that demonstrates a merge operation on a Delta table using PySpark:   from pyspark.sql import SparkSession # cre...