Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
501 views
in Technique[技术] by (71.8m points)

windows - Tomcat multiple instances simultaneously

I am trying to run multiple instances of Tomcat, but even after configuring different ports for listening and shutting down the second instance, it keeps trying to listen on 8080 (configured for 8081). I read that I have to set a different value for CATALINA_BASE. From all the articles there are online, none of them actually show in which file this variable can be set.

Where and how can I set CATALINA_BASE for my Tomcat instance in C:apache-tomcat-7.0.39

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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 conf, webapps 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:instance2conf, 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 instance1webapps and instance2webapps

  5. Create the following 4 batch files under C:

instance1_startup.bat

@echo off

set CATALINA_BASE=C:instance1

cd "%CATALINA_HOME%in"

set TITLE=My Tomcat Instance 01

call startup.bat %TITLE%

instance1_shutdown.bat

@echo off

set CATALINA_BASE=C:instance1

cd "%CATALINA_HOME%in"

call shutdown.bat

instance2_startup.bat

@echo off

set CATALINA_BASE=C:instance2

cd "%CATALINA_HOME%in"

set TITLE=My Tomcat Instance 02

call startup.bat %TITLE%

instance2_shutdown.bat

@echo off

set CATALINA_BASE=C:instance2

cd "%CATALINA_HOME%in"

call shutdown.bat

  1. Run instance1_startup.bat and instance2_startup.bat, hopefully it should work.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...