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

Problems encountered by MySQL nested transactions

MySQL supports nested transactions, but not many ...

Enabling and configuring MySQL slow query log

Introduction MySQL slow query log is an important...

Vue uniapp realizes the segmenter effect

This article shares the specific code of vue unia...

Detailed explanation of how to use zabbix to monitor oracle database

1. Overview Zabbix is ​​a very powerful and most ...

Detailed explanation of the difference between docker-compose ports and expose

There are two ways to expose container ports in d...

Install ethereum/Ethereum from scratch under CentOS7

Table of contents Preface Add sudo write permissi...

Let's talk about parameters in MySQL

Preface: In some previous articles, we often see ...

Detailed explanation of triangle drawing and clever application examples in CSS

lead Some common triangles on web pages can be dr...

Detailed explanation of character sets and validation rules in MySQL

1Several common character sets In MySQL, the most...

The latest virtual machine VMware 14 installation tutorial

First, I will give you the VMware 14 activation c...

How to install PostgreSQL and PostGIS using yum on CentOS7

1. Update the yum source The PostgreSQL version o...

js canvas realizes slider verification

This article example shares the specific code of ...

How to manage cached pages in Vue

Table of contents Problem 1: Destruction 1. How t...