tomcat 多实例做
解压部署tomcat程序
tar xf apache-tomcat-8.9.16.tar.gz
mv apache-tomcat-8.9.16 /usr/local/
创建实例一个
mkdir -p /usr/local/tomcat_instance/tomcat1
拷贝程序目录下的conf文件放入个实例中
cp -R /usr/local/apache-tomcat-8.9.16/conf/ /usr/local/tomcat_instance/tomcat1
在实例中创建启动脚本和停止脚本
mkdir /usr/local/tomcat_instance/tomcat1/bin
touch /usr/local/tomcat_instance/tomcat1/bin
chmod +x /usr/local/tomcat_instance/tomcat1/bin/startup.sh
ls /usr/local/tomcat_instance/
指向实例目录路径(编辑)
vim /usr/local/tomcat_instance/tomcat1/bin/startup.sh
------------------------------------------------------------
#!/bin/bash
export CATALINA_HOME="/usr/local/apache-tomcat-8.5.16"
export CATALINA_BASE="/usr/local/tomcat_instance/tomcat1"
export CATALINA_TMPDIR="$CATALINA_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]"
----------------------------------------------------------------
第二个实例,同上
touch /usr/local/tomcat_instance/tomcat2}/bin/shutdown.sh
chmod +x /usr/local/tomcat_instance/{tomcat1,tomcat2}/bin/shutdown.sh
vim /usr/local/tomcat_instance/tomcat1/bin/shutdown.sh
---------------------------------------------------------------------
#!/bin/bash
export CATALINA_HOME="/usr/local/apache-tomcat-8.5.16"
export CATALINA_BASE="/usr/local/tomcat_instance/tomcat1"
export CATALINA_TMPDIR="$CATALINA_BASE/temp"
export CATALINA_PID="$CATALINA_BASE/bin/tomcat.pid"
bash $CATALINA_HOME/bin/shutdown.sh "[email protected]"
------------------------------------------------------------------------------
[[email protected] ~]# vim /usr/local/tomcat_instance/tomcat2/bin/shutdown.sh
#!/bin/bash
export CATALINA_HOME="/usr/local/apache-tomcat-8.5.16"
export CATALINA_BASE="/usr/local/tomcat_instance/tomcat2"
export CATALINA_TMPDIR="$CATALINA_BASE/temp"
export CATALINA_PID="$CATALINA_BASE/bin/tomcat.pid"
bash $CATALINA_HOME/bin/shutdown.sh "[email protected]"
----------------------------------------------------------------
创建测试页
# mkdir -p /usr/local/tomcat_instance/{tomcat1,tomcat2}/webapps/ROOT
编辑文件
vim /usr/local/tomcat_instance/tomcat1/webapps/ROOT/index.jsp
<html>
<title>Tomcat-1</title>
<body>
Hello This is Tomcat-1.
</body>
</html>
启动tomcat实例
/usr/local/tomcat_instance/tomcat1/bin/startup.sh
查看监听端口
netstat -lnpt | grep java
原文地址:https://www.cnblogs.com/123456likun/p/11566911.html