Tomcat multi-instance deployment and configuration principles

Tomcat multi-instance deployment and configuration principles

1. Turn off the firewall and transfer the software package required to install Tomcat to the /opt directory

jdk-8u201-linux-x64.rpm
apache-tomcat-9.0.16.tar.gz
 
systemctl stop firewalld
systemctl disable firewalld
setenforce 0

2. Install JDK

cd /opt
rpm -qpl jdk-8u201-linux-x64.rpm
rpm -ivh jdk-8u201-linux-x64.rpm
java -version

3. Install Tomcat

cd /opt
tar zxvf apache-tomcat-9.0.16.tar.gz
mkdir /usr/local/tomcat
mv apache-tomcat-9.0.16 /usr/local/tomcat/tomcat1
cp -a /usr/local/tomcat/tomcat1 /usr/local/tomcat/tomcat2

4. Configure Tomcat environment variables

vim /etc/profile.d/tomcat.sh
#tomcat1
export CATALINA_HOME1=/usr/local/tomcat/tomcat1
export CATALINA_BASE1=/usr/local/tomcat/tomcat1
export TOMCAT_HOME1=/usr/local/tomcat/tomcat1
 
#tomcat2
export CATALINA_HOME2=/usr/local/tomcat/tomcat2
export CATALINA_BASE2=/usr/local/tomcat/tomcat2
export TOMCAT_HOME2=/usr/local/tomcat/tomcat2
 
 
source /etc/profile.d/tomcat.sh

5. Modify the server.xml file in tomcat2 to ensure that each tomcat instance configuration does not have duplicate port numbers.

vim /usr/local/tomcat/tomcat2/conf/server.xml
<Server port="8006" shutdown="SHUTDOWN"> #22 line, modify Server port, default is 8005 -> change to 8006
<Connector port="8081" protocol="HTTP/1.1" #69 line, change the Connector port, HTTP/1.1 default is 8080 -> change to 8081
<Connector port="8010" protocol="AJP/1.3" redirectPort="8443" /> #116 line, change Connector port AJP/1.3, default is 8009 -> change to 8010

6. Modify the startup.sh and shutdown.sh files in each tomcat instance and add tomcat environment variables

vim /usr/local/tomcat/tomcat1/bin/startup.sh
# -----------------------------------------------------------------------------
# Start Script for the CATALINA Server
# -----------------------------------------------------------------------------
##Add the following content export CATALINA_BASE=$CATALINA_BASE1
export CATALINA_HOME=$CATALINA_HOME1
export TOMCAT_HOME=$TOMCAT_HOME1
 
 
vim /usr/local/tomcat/tomcat1/bin/shutdown.sh
# -----------------------------------------------------------------------------
# Stop script for the CATALINA Server
# -----------------------------------------------------------------------------
export CATALINA_BASE=$CATALINA_BASE1
export CATALINA_HOME=$CATALINA_HOME1
export TOMCAT_HOME=$TOMCAT_HOME1
 
vim /usr/local/tomcat/tomcat2/bin/startup.sh
# -----------------------------------------------------------------------------
# Start Script for the CATALINA Server
# -----------------------------------------------------------------------------
export CATALINA_BASE=$CATALINA_BASE2
export CATALINA_HOME=$CATALINA_HOME2
export TOMCAT_HOME=$TOMCAT_HOME2
 
vim /usr/local/tomcat/tomcat2/bin/shutdown.sh
# -----------------------------------------------------------------------------
# Stop script for the CATALINA Server
# -----------------------------------------------------------------------------
export CATALINA_BASE=$CATALINA_BASE2
export CATALINA_HOME=$CATALINA_HOME2
export TOMCAT_HOME=$TOMCAT_HOME2

7. Start /bin/startup.sh in each tomcat

/usr/local/tomcat/tomcat1/bin/startup.sh
/usr/local/tomcat/tomcat2/bin/startup.sh
 
netstat -natp | grep java

This is the end of this article about Tomcat multi-instance deployment. For more relevant content about Tomcat multi-instance deployment, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • GitLab+Jenkins+Maven+Tomcat realizes automatic integration, packaging and deployment
  • Deploy Bolo in Tomcat

<<:  Example of using @media responsive CSS to adapt to various screens

>>:  MySQL aggregate function sorting

Recommend

The latest 36 high-quality free English fonts shared

01. Infinity Font Download 02. Banda Font Download...

Solution to Mysql binlog log file being too large

Table of contents 1. Related binlog configuration...

Json advantages and disadvantages and usage introduction

Table of contents 1. What is JSON 1.1 Array liter...

Tudou.com front-end overview

1. Division of labor and process <br />At T...

Summary of the use of CSS scope (style splitting)

1. Use of CSS scope (style division) In Vue, make...

A detailed introduction to the basics of Linux scripting

Table of contents 1. Script vim environment 2. Ho...

How to use JSZip compression in CocosCreator

CocosCreator version: 2.4.2 Practical project app...

Solutions to the Problem of Creating XHTML and CSS Web Pages

The solutions to the problems encountered during x...

Sample code using scss in uni-app

Pitfalls encountered I spent the whole afternoon ...

CSS solution for centering elements with variable width and height

1. Horizontal center Public code: html: <div c...

Example code for implementing a text marquee with CSS3

Background Here's what happened, Luzhu accide...

Introduction to common MySQL storage engines and parameter setting and tuning

MyISAM, a commonly used storage engine in MySQL c...

Analysis of log files in the tomcat logs directory (summary)

Each time tomcat is started, the following log fi...