tomcatrpmmultiple-instances

Install Multiple Tomcat9 Instance using RHEL RPM Package


How to create multiple tomcat instance using the RHEL RPM package(RHEL8.7). I have installed one instance using the package. Does it need to be replication of all the folders for example /usr/share/tomcat1 with conf,webapps,bin,work and temp folders replicated or it can be done in any other way?


Solution

  • Solution: The tomcat package installed using the RHEL RPM package has two directory tomcats and tomcat. Multiple instances can be deployed inside the tomcats directory. The following changes need to be done for installing multiple instance.

    1.Create a directory in /var/lib/tomcats which will be the instance 1(tom1). --> /var/lib/tomcats/tom1

    1. Create another directory conf in /var/lib/tomcats/tom1 and copy all the files/directory from /etc/tomcat to /var/lib/tomcats/tom1/conf Update the port details in server.xml file as each instance requires its own port.

    2. Copy the tomcat file in /etc/sysconfig directory to tomcat@instance i.e tomcat@tom1 in the same directory. This systemconfig file is used to override the global tomcat configuration and we can define the catalina_home & Base & other instance specific parameters for each instance. example CATALINA_HOME=/var/lib/tomcats/tom1

    3. Create a directory for log folder in /var/log with instance name. i,e /var/log/tom1.

    4. Create a webapps folder in /var/lib/tomcats/tom1 and copy the content from /var/lib/tomcat/webapps.

    5. create tom1 directory in /var/cache and create work & temp directory in /var/cache/tom1.

    6. Copy the bin directory from /usr/share/tomcat to /var/lib/tomcats/tom1

    7. Created a symbolic link directory lib in /var/lib/tomcats/tom1 pointing to /usr/share/java/tomcat

    8. Copy tomcat@instance service file from /usr/lib/systemd/system to /etc/systemd/system and rename it to tomcat@tom1 . Enable the service file & start the services.

    Repeat the same step for instance2 & so on.