当前所在位置:珠峰网资料 >> 计算机 >> 计算机等级考试 >> 正文
实现在tomcat中跑多个服务器实例
发布时间:2010/7/7 10:37:27 来源:城市学习网 编辑:ziteng
  Server.xml 注释
  Server:
  Server只能有一个,它代表整个JVM,server可以包含一个或者多个service
  Service:
  service包含一个或者多个connector和container。
  Conector:
  connector用来为container接收请求,和返回响应的。
  Engine:
  engine是顶层container,它可以包含一个或者多个host
  Host:
  host是虚拟主机,它可以包含一个或者多个context
  Context:
  context对应一个web application。
  最近抽时间研究了一下tomcat的源码,发现可以增加多个Service到server.xml中,实现在tomcat中跑多个服务器实例,在Server.xml中增加如下配置信息:
  Xml代码
  <Service name="Catalina2">
  <Connector port="8081"
  maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
  enableLookups="false" redirectPort="8443" acceptCount="100"
  debug="0" connectionTimeout="20000"
  disableUploadTimeout="true" />
  <Connector port="8010"
  enableLookups="false" redirectPort="8443" debug="0"
  protocol="AJP/1.3" />
  <Engine name="Catalina" defaultHost="localhost" debug="0">
  <Logger className="org.apache.catalina.logger.FileLogger"
  prefix="catalina2_log." suffix=".txt"
  timestamp="true"/>
  <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
  debug="0" resourceName="UserDatabase"/>
  <Host name="localhost" debug="0" appBase="webapps2"
  unpackWARs="true" autoDeploy="true"
  xmlValidation="false" xmlNamespaceAware="false">
  <Logger className="org.apache.catalina.logger.FileLogger"
  directory="logs"   prefix="localhost2_log." suffix=".txt"
  timestamp="true"/>
  </Host>
  </Engine>
  </Service>
广告合作:400-664-0084 全国热线:400-664-0084
Copyright 2010 - 2017 www.my8848.com 珠峰网 粤ICP备15066211号
珠峰网 版权所有 All Rights Reserved