tomcat多实例的部署
Posted zc1741845455
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了tomcat多实例的部署相关的知识,希望对你有一定的参考价值。
解压部署tomcat程序
创建2个实例的工作目录
mkdir -p /usr/local/tomcat8_instance/tomcat1
mkdir -p /usr/local/tomcat8_instance/tomcat2
拷贝tomcat 程序目录下的conf分别放入2个实例目录中
cp -R /usr/local/tomcat8/conf /usr/local/tomcat8_instance/tomcat1
cp -R /usr/local/tomcat8/conf/ /usr/local/tomcat8_instance/tomcat2
mkdir /usr/local/tomcat_instance8/{tomcat1,tomcat2}/bin
touch /usr/local/tomcat_instance8/{tomcat1,tomcat2}/bin/statup.sh
chmod +x /usr/local/tomcat_instance8/{tomcat1,tomcat2}/bin/startup.sh
在tomcat实例目录下的bin目录中创建实例启动和停止脚本
vim /usr/local/tomcat8_instance/tomcat1/bin/startup.sh
#!/bin/bash
export CATALINA_HOME="/usr/local/tomcat8"
export CATALINA_BASE="/usr/local/tomcat8_instance/tomcat1"
export CATALINA_TMPDIR="$CATALINX_BASE/temp"
export CATALINA_PID="$CATALINA_BASE/bin/tomcat.pid"
export JAVA_OPTS="-server -Xms1024m -Xmx1024m -Djava.awt.headless=true -Dtomcat.name=tomcat1"
#创建logs目录
if [ ! -d "$CATALINA_BASE/logs" ]
then
mkdir $CATALINA_BASE/logs
fi
#创建temp目录
if [ ! -d "$CATALINA_BASE/temp" ]
then
mkdir $CATALINA_BASE/temp
fi
#调用tomcat启动脚本
bash $CATALINA_HOME/bin/startup.sh "[email protected]"
vim /usr/local/tomcat8_instance/tomcat2/bin/startup.sh
#!/bin/bash
export CATALINA_HOME="/usr/local/tomcat8"
export CATALINA_BASE="/usr/local/tomcat8_instance/tomcat2"
export CATALINA_TMPDIR="$CATALINX_BASE/temp"
export CATALINA_PID="$CATALINA_BASE/bin/tomcat.pid"
export JAVA_OPTS="-server -Xms1024m -Xmx1024m -Djava.awt.headless=true -Dtomcat.name=tomcat2"
#创建logs目录
if [ ! -d "$CATALINA_BASE/logs" ]
then
mkdir $CATALINA_BASE/logs
fi
#创建temp目录
if [ ! -d "$CATALINA_BASE/temp" ]
then
mkdir $CATALINA_BASE/temp
fi
#调用tomcat启动脚本
bash $CATALINA_HOME/bin/startup.sh "[email protected]"
[[email protected] ~]# touch /usr/local/tomcat8_instance/{tomcat1,tomcat2}/bin/shutdown.sh
[[email protected] ~]# chmod +x /usr/local/tomcat8_instance/{tomcat1,tomcat2}/bin/shutdown.sh
[[email protected] ~]# vim /usr/local/tomcat8_instance/tomcat1/bin/shutdown.sh
#!/bin/bash
export CATALINA_HOME="/usr/local/tomcat8"
export CATALINA_BASE="/usr/local/tomcat8_instance/tomcat1"
export CATALINA_TMPDIR="$CATALINX_BASE/temp"
export CATALINA_PID="$CATALINA_BASE/bin/tomcat.pid"
bash $CATALINA_HOME/bin/shutdown.sh "[email protected]"
[[email protected] ~]# vim /usr/local/tomcat8_instance/tomcat2/bin/shutdown.sh
#!/bin/bash
export CATALINA_HOME="/usr/local/tomcat8"
export CATALINA_BASE="/usr/local/tomcat8_instance/tomcat1"
export CATALINA_TMPDIR="$CATALINX_BASE/temp"
export CATALINA_PID="$CATALINA_BASE/bin/tomcat.pid"
bash $CATALINA_HOME/bin/shutdown.sh "[email protected]"
修改实例中配置文件端口,详细文档中的
创建测试页
vim /usr/local/tomcat8_instance/tomcat1/webapps/ROOT/index.jsp
<html>
<title>Tomcat-1</title>
<body>
THIS IS TOMCAT1
</body>
</html>
vim /usr/local/tomcat8_instance/tomcat2/webapps/ROOT/index.jsp
<html>
<title>This-TOMCAT2</title>
<body>
this is tomcat2
</body>
</html>
访问http://192.168.30.21:8080
192.168.30.21:8090
以上是关于tomcat多实例的部署的主要内容,如果未能解决你的问题,请参考以下文章