tomcat多实例部署

这里写目录标题

  • tomcat多实例部署
    • Tomcat多实例部署
      • 关闭防火墙和selinux
      • 将安装Tomcat所需软件包传到/opt目录下
      • 安装JDK环境
      • 设置JDK环境变量
      • 安装启动Tomcat
      • 配置tomcat环境变量
      • 修改tomcat2中的server.xml文件,要求各tomcat实例配置不能有重复的端口号
      • 修改各tomcat实例中的startup.sh和shutdown.sh文件,添加tomcat环境变量
      • 启动各tomcat中的/bin/startup.sh
      • 浏览器访问测试

tomcat多实例部署

Tomcat多实例部署

关闭防火墙和selinux

systemctl stop firewalld
setenforce 0
systemctl disable firewalld

img

将安装Tomcat所需软件包传到/opt目录下

tomcat多实例部署_第1张图片

安装JDK环境

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

tomcat多实例部署_第2张图片

设置JDK环境变量

vim /etc/profile
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
java -version

tomcat多实例部署_第3张图片
tomcat多实例部署_第4张图片

安装启动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

tomcat多实例部署_第5张图片

配置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

tomcat多实例部署_第6张图片

修改tomcat2中的server.xml文件,要求各tomcat实例配置不能有重复的端口号

1.vim /usr/local/tomcat/tomcat2/conf/server.xml
2.                           #22行,修改Server port,默认为8005 -> 修改为8006
3. 修改为8081
4.   #116行,修改Connector port AJP/1.3,默认为8009 -> 修改为8010

img
tomcat多实例部署_第7张图片
img

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

1.#tomcat1的startup.sh
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
2..#tomcat1的shuutdown.sh 
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
3.#tomcat2的startup.sh 
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
4.#tomcat2的shuutdown.sh 
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

tomcat多实例部署_第8张图片
tomcat多实例部署_第9张图片
tomcat多实例部署_第10张图片
tomcat多实例部署_第11张图片

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

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

tomcat多实例部署_第12张图片

浏览器访问测试

http://192.168.80.11:8080
http://192.168.80.11:8081

tomcat多实例部署_第13张图片
tomcat多实例部署_第14张图片

你可能感兴趣的:(web,tomcat,java,linux)