Wednesday, March 21, 2007

Running more than one instance of Tomcat Server on the same machine

I came across one of the question in one of the Java forum on ITTOOLBOX which was like this:

Can we run more than one instance of the Tomcat server on the same machine?

I was trying this from two days, and finally I was successful in starting three Tomcat instances on the same machine with different port numbers.

I followed the following steps to do the same:
a. Made three different folders of Tomcat directory.

b. Made changes in the environment variables as CATALINA_HOME1, CATALINA_HOME2, and CATALINA_HOME3.

c. Then I reflected the above changes in the "startup.bat", "shutdown.bat" and "catalina.bat" batch files in each Tomcat "bin" folder accordingly.

d. Then I changed the default port numbers 8005, 8080, and 8009 in server.xml & server-minimal.xml files of second and third Tomcat directories.

e. Now first server was running at port 8080, second one at 8090, and the third one at 8095.

Conclusion:
We can either have the instances running on the same machine (different ports), different machines (same ports) or different machines (different ports).

5 comments:

Raminder Singh said...

quite useful.

Anitha said...

Good one.

But i have a doubt i use Tomcat 5.5 ,how to edit startup.bat or shutdown.bat files here,we have only tomcat5.exe.Any inputs on this?

Thanks

atuls said...

Hi Anitha,
We have "startup.bat" and "shutdown.bat" files present in the "bin" folder of Tomcat 5.5 installed directory. You can edit these batch files accordingly. At my end, I'm using Tomcat 5.5.9 and have successfully ran three instances of Tomcat on same machine.

Balu said...

it is nice to see this article

Java Experience said...

I have written a Java based portable utility for automating the above steps for creating multiple instances. Since Java is platform independent, this utility works on all operating systems


_________________________________________________________________________________________________________________

"Look at the sky. We are not alone. The whole Universe is friendly to us and conspires only to give the best to those who dream and work."

- Dr. A P J Abdul Kalam
_________________________________________________________________________________________________________________