How to Run Multiple Tomcat Instances on One Server?



How to Run Multiple Tomcat Instances on One Server?

name="aswift_0" width="728" height="90" id="aswift_0" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" vspace="0" hspace="0" allowfullscreen="true" style="left: 0px; top: 0px; position: absolute;" allowtransparency="true">

I’m sure you must have faced one of below question while developing Dynamic Web Project in past.

  • Running multiple Tomcat instances on one server
  • Advanced Configuration – Multiple Tomcat Instances
  • Running Multiple Tomcat Instances on Single Machine
  • java – Running Multiple Tomcat Instances on One Windows Machine
  • use multiple CATALINA_BASE to setup tomcat 6 instances on windows

If yes, then you are at right place..

Tomcat Multiple Instances

Lets 1st understand Tomcat Directory Structure..

When creating multiple instances of tomcat server, we need to play with the folders inside the server. These folders contain the actual scripts and code for the server. We have the option to either use the code base for tomcat in shared mode where all tomcat instances refer to the same physical code or we can create separate copies of these folder for each tomcat instance.

  • /bin : This directory contains the startup and shutdown scripts for both Windows and Linux.
  • /conf : This directory contains the main configuration files for Tomcat. The two most important are the server.xml and the global web.xml .
  • /server : This directory contains the Tomcat Java Archive files.
  • /lib : This directory contains Java Archive files that Tomcat is dependent upon.
  • /logs : This directory contains Tomcat’s log files.
  • /src : This directory contains the source code used by the Tomcat server. Once Tomcat is released, it will probably contain interfaces and abstract classes only.
  • /webapps : All web applications are deployed in this directory; it contains the WAR file.
  • /work : This is the directory in which Tomcat will place all servlets that are generated from JSPs. If you want to see exactly how a particular JSP is interpreted, look in this directory.
Tomcat server ports

Having a good understanding of tomcat ports is essential to manage the multiple instances of the same server installation. These ports are used by tomcat for start-up, deployment and shut-down operations. The detail of each port is as:

  • Connector Port : This is the port where Apache Tomcat listen for the HTTP requests.
  • Shutdown Port : This port is used when we try to shutdown the Apache Tomcat Server.
  • AJP (Apache JServ Protocol) Connector Port : The Apache JServ Protocol (AJP) is a binary protocol that can conduct inbound requests from a web server through to an application server that sits behind the web server.
  • Redirect Port : Any redirection happening inside Apache Tomcat will happen through this port. In Apache TOMCAT there are two instance where redirectPort is mentioned. First one is for the Apache TOMCAT server and other one is for the AJP port.

Other must read:

Lets start creating multiple Tomcat Instances in Mac environment..

Step-1

Download and Copy Tomcat Instances under ~/Documents/Crunchify/ folder.

Multiple Tomcat Instances

Step-2

name="aswift_1" width="728" height="15" id="aswift_1" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" vspace="0" hspace="0" allowfullscreen="true" style="left: 0px; top: 0px; position: absolute;" allowtransparency="true">

Change below HTTP, HTTPS, AJP, Shutdown Ports for Tomcat2 instance.

File location: Tomcat2/conf/server.xml file.

Apache Tomcat Server Shutdown Port Apache Tomcat Server Connector Port Apache Tomcat Server AJP Port

Step-3

The startup.sh and shutdown.sh script files make use of catalina.sh for performing the startup and shutdown operations. We shall edit catalina.sh file as described below:

a)

For tomcat1, specify following two variables in catalina.sh  script file present in the bin folder of the tomcat_home

b)

For tomcat2, specify following two variables in catalina.sh script file present in the bin folder of the tomcat_home

Step-4

Startup scripts are a whole other topic, but here’s the brief rundown. The main different from running a single Tomcat instance is you need to set CATALINA_BASE  to the directory you set up for the particular instance you want to start (or stop).

Here’s a typical startup routine:

Have anything to add to this article? Please chime in and join the conversion.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值