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


转载于:https://blog.51cto.com/8371379/1925151

最新回复(0)
/jishuwuku55MsLXZPAZ1i09LCpIWBEkrvi9VgfxfRKn9LEHU_3D4661835
8 简首页