目標是實現單個應用在同個tomcat中運行多個實例。每一個實例除端口、日誌輸出不同以外,其餘相同,應用只發布和配置一次。如下步驟是按照Tomcat 7.0.22進行的。java
<?xml version='1.0' encoding='utf-8'?> <Server port="9000" shutdown="SHUTDOWN"> <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" /> <Listener className="org.apache.catalina.core.JasperListener" /> <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" /> <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" /> <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" /> <Service name="Catalina"> <Connector port="9080" protocol="HTTP/1.1" connectionTimeout="20000" acceptCount="200" maxThreads="800" URIEncoding="UTF-8"/> <Connector port="9010" protocol="AJP/1.3" /> <Engine name="Catalina" defaultHost="localhost"> <Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true"></Host> </Engine> </Service> </Server>
handlers = java.util.logging.ConsoleHandler .handlers = java.util.logging.ConsoleHandler java.util.logging.ConsoleHandler.level = FINE java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
#!/bin/sh PRG="$0" PRGDIR=`dirname "$PRG"` EXECUTABLE=catalina.sh export CATALINA_OUT=`cd "$PRGDIR/.." >/dev/null; pwd`/logs/"$1".out echo Using config :conf/"$1".xml echo Using CATALINA_OUT:"$CATALINA_OUT" exec "$PRGDIR"/"$EXECUTABLE" start -config conf/"$1".xml
如今就能夠在webapps中部署應用,Catalina/localhost配置上下文以及數據源了。web