Tomcat多实例部署

Tomcat多实例部署

一、安装好 jdk

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

1.1设置JDK环境变量

vim /etc/profile.d/java.sh
export JAVA_HOME=/usr/java/jdk1.8.0_201-amd64
export CLASSPATH=.:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar
export PATH=$JAVA_HOME/bin:$PATH

source /etc/profile.d/java.sh
java -version
 source /etc/profile

image-20240820142906811二、安装 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

image-20240820143224321

2.1配置 tomcat 环境变量

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

image-20240820143544256

2.2修改 tomcat2 中的 server.xml 文件

要求各 tomcat 实例配置不能有重复的端口号

vim /usr/local/tomcat/tomcat2/conf/server.xml
<Server port="8006" shutdown="SHUTDOWN">		#22行,修改Server prot,默认为8005 -> 修改为8006
<Connector port="8081" protocol="HTTP/1.1"		#69行,修改Connector port,HTTP/1.1  默认为8080 -> 修改为8081
<Connector port="8010" protocol="AJP/1.3" redirectPort="8443" />	#116行,修改Connector port AJP/1.3,默认为8009 -> 修改为8010

2.3修改各 tomcat 实例中的 startup.sh 和 shutdown.sh 文件,添加 tomcat 环境变量

vim /usr/local/tomcat/tomcat1/bin/startup.sh 

# -----------------------------------------------------------------------------

# Start Script for the CATALINA Server

# -----------------------------------------------------------------------------

##添加以下内容
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

2.4启动各 tomcat 中的 /bin/startup.sh

/usr/local/tomcat/tomcat1/bin/startup.sh 
/usr/local/tomcat/tomcat2/bin/startup.sh 

netstat -natp | grep java

image-20240820145703193

2.5浏览器访问测试

http://192.168.78.11:8080
http://192.168.78.11:8081

image-20240820145953066

Y4DR77-1724637359060)]

2.5浏览器访问测试

http://192.168.78.11:8080
http://192.168.78.11:8081

[外链图片转存中…(img-JAbHYw0a-1724637359060)]

image-20240820150003958

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值