Saturday, January 28, 2012

Run Multiple Instance of Apache Tomcat in Single Server



A lot of time we want to run multiple instances of Apache Tomcat server on a single machine. Generally this is done for creating a separate load balancer server for an application or install a different application independently.

This can be achieved easy by some configuration in Tomcat Server. We need to install a second instance of Tomcat and change few port in configuration files.

Open server.xml from /conf directory of your Tomcat installation folder. Change following ports in server.xml file.

Connector Port

This is the port where Apache Tomcat listen for the HTTP requests. By default this port is set to 8080. We can identify this Port inside server.xml by checking the following tag. Change the port to different value (for example 8081) and the second instance will listen the HTTP request on that port.


1
2
<connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000" redirectPort="8443" />

Shutdown Port

This port is used when we try to shutdown the Apache Tomcat Server. We can identify this Port inside server.xml by checking the following tag.


1
2
<server port="8005" shutdown="SHUTDOWN">
</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. We can identify this Port inside server.xml by checking the following tag.


1
<connector port="8009" protocol="AJP/1.3" redirectPort="8443" />

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. We can identify this Port inside server.xml by checking the following tag. Ensure that redirectPort should be same for AJP and HTTP protocol.


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

Just change the above ports in your second installation of Tomcat.



No comments:

Post a Comment