Tomcat多实例部署及配置原理
程序员文章站
2022-03-01 20:27:51
1、关闭防火墙,将安装 tomcat 所需软件包传到/opt目录下jdk-8u201-linux-x64.rpmapache-tomcat-9.0.16.tar.gz systemctl stop f...
1、关闭防火墙,将安装 tomcat 所需软件包传到/opt目录下
jdk-8u201-linux-x64.rpm apache-tomcat-9.0.16.tar.gz systemctl stop firewalld systemctl disable firewalld setenforce 0
2、安装jdk
cd /opt rpm -qpl jdk-8u201-linux-x64.rpm rpm -ivh jdk-8u201-linux-x64.rpm java -version
3、安装 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、配置 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
5、修改 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
6、修改各 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
7、启动各 tomcat 中的 /bin/startup.sh
/usr/local/tomcat/tomcat1/bin/startup.sh /usr/local/tomcat/tomcat2/bin/startup.sh netstat -natp | grep java
到此这篇关于tomcat多实例部署的文章就介绍到这了,更多相关tomcat多实例部署内容请搜索以前的文章或继续浏览下面的相关文章希望大家以后多多支持!
上一篇: 【前端】CSS3学习笔记(四)——浮动
下一篇: 利用PyQt5制作一个豆瓣电影信息查看器