分享

实现在tomcat中跑多个服务器实例

 超越郑越超 2011-02-21
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>

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多