首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 互联网 >

tomcat多范例配置

2012-06-30 
tomcat多实例配置Make sure each instance uses a different port value. The port value will normally n

tomcat多实例配置

Make sure each instance uses a different port value. The port value will normally need to be higher than 1024, and shouldn't conflict with any other network service running on the same system. The shutdown string is the value that is sent to shut the server down. Note that Tomcat won't accept shutdown commands that come from other machines.

Unlike the other ports Tomcat listens to, the shutdown port can't be configured to listen to its port on a different IP address. It always listens on 127.0.0.1.

The other ports Tomcat listens to are configured with the <Connector> elements, for instance the HTTP or JK listeners. The port attribute configures which port to listen to. Setting this to a different value on the different Tomcat instances on a machine will avoid conflict.

Of course, you'll need to configure whatever connects to that Connector to use the different port. If a web server is used as the front end using mod_jk, mod_proxy, or the like, then this is simple enough - change your web server's configuration.

In some cases you may not want to do this, for instance you may not want to use a port other than 8080 for HTTP connectors. If you want all of your Tomcat intances to use the same port number, you'll need to use different IP addresses. The server system must be configured with multiple IP addresses, and the address attribute of the <Connector> element for each Tomcat instance will be set to the appropriate IP address.

Step 4: Startup

Startup scripts are a whole other topic, but here's the brief rundown. The main different from running a single Tomcat instance is you need to set CATALINA_BASE to the directory you set up for the particular instance you want to start (or stop). Here's a typical startup routine:

JAVA_HOME=/usr/java JAVA_OPTS="-Xmx800m -Xms800m" CATALINA_HOME=/usr/local/tomcat CATALINA_BASE=/var/tomcat/serverA export JAVA_HOME JAVA_OPTS CATALINA_HOME CATALINA_BASE $CATALINA_HOME/bin/catalina.sh start
补充:每个tomcat实例的启动脚本和关闭脚本必须设置的环境变量是:
 CATALINA_HOME (每个实例的值都一样,指向tomcat程序的安装目录)
 CATALINA_BASE (各个实例有不同的值,指向各个实例的安装目录)
 JAVA_HOME或JRE_HOME (各个实例的值都一样)
例子:start.bat (Windows环境下)
  1. rem?每个tomcat实例的启动脚本????
  2. rem?设置Java虚拟机的安装路径(也可以设置JDK的安装路径JAVA_HOME,二者选其一即可)??rem?------------------------------??
  3. set?JRE_HOME=C:/Program?Files/Java/jre6????
  4. rem?设置CATALINA_HOME??rem?-----------------??
  5. set?CATALINA_HOME=D:/server/tomcat6_HOME????
  6. rem?每个tomcat实例的CATALINA_BASE的值是不一样的??rem?-------------------------------------------??
  7. set?CATALINA_BASE=D:/server/tomcat6_BASE_1????
  8. call?%CATALINA_HOME%/bin/startup.bat??

热点排行