Linux下Tomcat多实例部署配置

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Linux下Tomcat多实例部署配置相关的知识,希望对你有一定的参考价值。

1、在/export/Domains下创建站点目录a.b.c,在站点目录下创建server1

2、将Tomcat除了Bin之外的配置文件拷贝到a.b.c下

3、创建启动脚本start.sh,停止脚本stop.sh,代码如下:

#!/bin/bash
export CATALINA_HOME=/export/servers/apache-tomcat-7
export CATALINA_BASE=/export/Domains/brand.jd.com/server1
export CATALINA_PID=$CATALINA_BASE/work/catalina.pid
export LANG=zh_CN.UTF-8
###JAVA
export JAVA_HOME=/export/servers/jdk1.7.0_79
export JAVA_BIN=$JAVA_HOME/bin
export PATH=$JAVA_BIN:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/bin
export CLASSPATH=.:/lib/dt.jar:/lib/tools.jar
export JAVA_OPTS="-Djava.library.path=/usr/local/lib -server -Xms1024m -Xmx1024m -XX:MaxPermSize=256m -Djava.awt.headless=true -Dsun.net.client.defaultConnec
tTimeout=60000 -Dsun.net.client.defaultReadTimeout=60000 -Djmagick.systemclassloader=no -Dnetworkaddress.cache.ttl=300 -Dsun.net.inetaddr.ttl=300 -XX:+HeapDu
mpOnOutOfMemoryError -XX:HeapDumpPath=$CATALINA_BASE/logs -XX:ErrorFile=$CATALINA_BASE/logs/java_error_%p.log -agentlib:jdwp=transport=dt_socket,server=y,sus
pend=n,address=8231 -Ddeploy.dynamic.config.dir=/export/App/brand.jd.com/WEB-INF/classe -Dfile.encoding=utf-8"
export JAVA_HOME JAVA_BIN PATH CLASSPATH JAVA_OPTS
$CATALINA_HOME/bin/startup.sh -config $CATALINA_BASE/conf/server.xml

#!/bin/bash
export CATALINA_HOME=/export/servers/tomcat6.0.33
export CATALINA_BASE=/export/Domains/brand.jd.com/server1
export CATALINA_PID=$CATALINA_BASE/work/catalina.pid
###JAVA
export JAVA_HOME=/export/servers/jdk1.6.0_25
export JAVA_BIN=/export/servers/jdk1.6.0_25/bin
export PATH=$JAVA_BIN:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/bin
export CLASSPATH=.:/lib/dt.jar:/lib/tools.jar
export  JAVA_OPTS="-Djava.library.path=/usr/local/lib -server -Xms1024m -Xmx1024m -XX:MaxPermSize=256m -Djava.awt.headless=true -Dsun.net.client.defaultConne
ctTimeout=60000 -Dsun.net.client.defaultReadTimeout=60000 -Djmagick.systemclassloader=no -Dnetworkaddress.cache.ttl=300 -Dsun.net.inetaddr.ttl=300 -XX:+HeapD
umpOnOutOfMemoryError -XX:HeapDumpPath=$CATALINA_BASE/logs -XX:ErrorFile=$CATALINA_BASE/logs/java_error_%p.log"
#export JAVA_HOME JAVA_BIN PATH CLASSPATH JAVA_OPTS

$CATALINA_HOME/bin/shutdown.sh -config $CATALINA_BASE/conf/server.xml
sleep 3
ps -aef | grep java|grep "/brand.jd.com/server1"| grep -v grep | sed ‘s/ [ ]*/:/g‘ |cut -d: -f2|kill -9 `cat`

4、修改站点目录conf下server.xml文件,解决端口冲突问题


5、在/export/Domains/brand.jd.com/server1/conf/Catalina/localhost目录下创建ROOT.xml,配置如下:

<?xml version="1.0" encoding="UTF-8"?>

<Context path="/" docBase="/export/App/a.b.c">

</Context>


本文出自 “大数据践行者” 博客,谢绝转载!

以上是关于Linux下Tomcat多实例部署配置的主要内容,如果未能解决你的问题,请参考以下文章

Linux集成环境部署 mysql + tomcat + redis

Tomcat多实例一键部署shell脚本

tomcat 多实例部署以及负载均衡配置

管理多tomcat实例的shell脚本

Tomcat 多实例部署

单机多实例tomcat 部署