5、在/opt/apps/下新建logs/test目录
6、在/opt/apps/下新建bin目录:
创建test-start.sh文件,文件内容如下:
#!/bin/bash
export LD_LIBRARY_PATH="/opt/apps/apache-tomcat-7.0.26/bin/native"
#export JAVA_HOME="/opt/apps/jdk1.7.0_05"
export CATALINA_OPTS="-Dtomcat.server.port=8005 -Dtomcat.http.port=8010 -Dtomcat.instance.name=test -Xms1024m -Xmx1024m -XX:PermSize=128m -XX:MaxPermSize=256m -XX:+HeapDumpOnOutOfMemoryError"
export CATALINA_OUT="/opt/apps/logs/test/catalina.$(date +'%Y-%m-%d').out"
export CATALINA_PID="/opt/apps/apache-tomcat-7.0.26/tomcat-test.pid"
export CATALINA_BASE="/opt/apps/apache-tomcat-7.0.26/test"
rm -rf /opt/apps/apache-tomcat-7.0.26/test/work
/opt/apps/apache-tomcat-7.0.26/bin/catalina.sh start
exit $?
创建test-stop.sh文件,文件内容如下:
#!/bin/bash
export JAVA_HOME="/opt/apps/jdk1.7.0_05"
export JAVA_OPTS="-Dtomcat.server.port=8005"
export CATALINA_PID="/opt/apps/apache-tomcat-7.0.26/tomcat-test.pid"
/opt/apps/apache-tomcat-7.0.26/bin/catalina.sh stop 0 -force
7、将应用拷贝到apache-tomcat-7.0.26/test/webapps/,通过test-start.sh来启动应用实例,test-stop.sh来停止应用实例。
8、如要再创建一个实例,重复进得2~7操作。
二、遇到的问题:
1、Another unnamed CacheManager already exists in the same VM. Please provide unique names for each CacheManager in the config or do one of following:
1. Use one of the CacheManager.create() static factory methods to reuse same CacheManager with same name or create one if necessary
2. Shutdown the earlier cacheManager before creating new one with same name.
解决方案:copy apache-tomcat-7.0.26/conf/web.xml到apache-tomcat-7.0.26/test/conf/
2、利用jenkins自动部署时,报错:Caused by: java.io.IOException: Server returned HTTP response code: 401 for URL: http://localhost:8010/manager/text/list
解决方案:copy apache-tomcat-7.0.26/webapps/manager到apache-tomcat-7.0.26/test/webapps/,同时需要在test/conf/tomcat-user.xml加上用户配置。