Tomcat多实例部署

1.安装好jdk

2.安装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 3.配置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/1ocal/tomcat/ tomcat2

source /etc/profile.d/tomcat. sh

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

vim /usr/1ocal/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

第一个连接器默认监听8080端口,负责建立HTTP连接。在通过浏览器访问Tomcat服务器的Web应用时,使用的就是这个连接器。 第二个连接器默认监听8009端口,负责和其他的HTTP服务器建立连接。在把Tomcat与其他HTTP服务器集成时,就需要用到这个连接器。

5.修改各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=SCATALINA 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