Additional Tomcat Instances
We have already installed one instance of Tomcat in the server. The basic directories associated with Tomcat, relative to $CATALINA_HOME, are:
/bin – Contains Startup, shutdown, and other scripts.
/conf – Contains configuration files. The main configuration file “server.xml” is present in this directory.
/logs – Contains related log files.
/webapps – Contains web applications.
We can still install multiple instances of Tomcat using the environment variable CATALINA_HOME. Each instance will use its own startup/shutdown scripts, configuration files, log files, etc.
Configure Second Instance
The first instance of Tomcat is installed inside the directory “/usr/local/tomcat“. In order to configure an additional instance, create a new directory “/usr/local/tomcat1“, assign correct permissions and copy all contents from the old directory to the new one.
mkdir /usr/local/tomcat1 chown tomcat:tomcat /usr/local/tomcat1 cp -pr /usr/local/tomcat/* /usr/local/tomcat1/
The Tomcat configuration is defined by the contents of the server.xml file that is found in the Tomcat’s configuration($CATALINA_HOME/conf) directory. In order to configure an additional instance, modify the tomcat configuration file corresponding to the second instance “/usr/local/tomcat1/conf/server.xml”
Change AJP connector port from 8080 to 8081, because the first instance is already using 8080. The AJP connector port is used by Apache to forward requests. After modifications, it should look something like this:
<!-- Define a non-SSL HTTP/1.1 Connector on port 8080 --> <Connector port="8081" maxHttpHeaderSize="8192" maxThreads="150" minSpareThreads="25" maxSpareThreads="75" enableLookups="false" redirectPort="8443" acceptCount="100" connectionTimeout="20000" disableUploadTimeout="true" /> <!-- Note : To disable connection timeouts, set connectionTimeout value to 0 -->
Change the SHUTDOWN port from 8005 to 8115, because the the first instance already is using port 8005. Now the line should be like this:
<Server port="8115" shutdown="SHUTDOWN">
Yes, we are now done with the configuration of the second instance of Tomcat. Now we can start this instance using the startup script /usr/local/tomcat1/bin/startup.sh. Before that, it is required that you define the variable CATALINA_HOME as /usr/local/tomcat1 in the script /usr/local/tomcat1/bin/catalina.sh.
You can access this instance of Tomcat using the URL http://server_IP:8081 and the manager interface at http://server_IP:8081/manager/.
Similar to how we did initially, here too, you will need to manually add the “manager” user in the user configuration file /usr/local/tomcat1/conf/tomcat-users.xml.
Tomcat can be used as an independent web server, with its own internal HTTP server, or can be used in combination with other web servers, like Apache webserver. |
In the same way, it is possible to install multiple Tomcat instances under different directories like /usr/local/tomcat2, /usr/local/tomcat3, etc.
It is important that the ports required for Tomcat connections are kept open in the server firewall.
The above installation steps has been tried and tested using Tomcat 5.x. In the above example, multiple instances are using the same version of Tomcat. However, it is possible to run different Tomcat versions for multiple instances in the same server. For that, while configuring the second instance, download and install an alternate Tomcat version(Tomcat 6.x) in the directory /usr/local and create the following symbolic link.
ln -s /usr/local/apache-tomcat-6.0.18 /usr/local/tomcat1
And then, proceed with the same steps as of the second instance.
By installing multiple instances, you can improve performance and easiness of the web application management. Also, it helps to improve the stability of web applications. On multi-user systems (with developers working), it is often useful to set up Tomcat, so that each user runs a separate instance of Tomcat.
Reference
http://tomcat.apache.org/tomcat-5.5-doc/index.html
http://tomcat.apache.org/tomcat-4.0-doc/manager-howto.html
About the Author :
Prathyush Babu has been working with Bobcares for over 3.5 years and he is an expert when it comes to Data Center Support Management. Prathyush loves to explore various Unix flavors and has a high degree of interest towards Server Security and Bash Scripting. He has a vast experience handling several control panels and brings in a lot of flexibility into the company, with his knowledge in various areas of the Hosting industry. Prathyush is cheerful and is a fun lover. Music, Painting and Travelling are some of his hobbies.
The process includes :
Step 1: Install the Tomcat files
Step 2: Make directories for each instance
Step 3: Configure the ports and/or addresses for each instance
Step 4: Startup
Hi
FYI! this is vinodh here! i have a doubt regarding “SYNFLOOD”
Im running a webserver with apache,tomcat,the problem is tomcat is down,
when i debugged,
# messages.log i found this –
(Kernel: possible SYN flooding on port 8009. Sending cookies)
# mod.jk logs i found this –
(Tomcat is down or refused connection. No response has been sent to the client (yet)
# error.log i found this –
server reached MaxClients setting, consider raising the MaxClients setting
i know that the kernal have dropped the connections
a) my doubt is this is a syn attack?
b) does the syn attack is the reason for tomcat down?
c) when there is a syn flood – i have an alert from my monitoring tool
d)could plz clarify me
does syn attack is responsible for tomcat down or does it is the increase in no of maximum clents as per error log is the cause of the tomcat down?
i googled & searched all forums, but i’m yet to find a solution!
please give me a solution?
after I did alll above configurations and run chown command I am getting follwing error
/usr/local/tomcat2/bin$ ./startup.sh
./catalina.sh: 1: ./catalina.sh: /usr/local/tomcat2: Permission denied
Cannot find /bin/setclasspath.sh
This file is needed to run this program