web下的tomcat集群

来源:互联网 发布:黑马程序员java教程 编辑:程序博客网 时间:2024/06/15 03:01

1.需要jar包
 先检查tomcat下的lib目录有没有下面的三个jar包
 catalina-ha-6.0.20.jar
 commons-logging-1.0.4.jar
commons-modeler-2.0.1.jar

2.tomcat下Server.xml配置
 在<Engine name="Catalina" defaultHost="localhost">该节点内增加如下配置:
 <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"
                 channelSendOptions="8">
 
          <Manager className="org.apache.catalina.ha.session.DeltaManager"
                   expireSessionsOnShutdown="false"
                   notifyListenersOnReplication="true"/>
 
          <Channel className="org.apache.catalina.tribes.group.GroupChannel">
            <Membership className="org.apache.catalina.tribes.membership.McastService"
                        address="228.0.0.4" ---这是广播地址不用修改
                        port="45588"   ---这个端口可修改几个tomcat配置一致
                        frequency="500"
                        dropTime="3000"/>
            <Receiver className="org.apache.catalina.tribes.transport.nio.NioReceiver"
                      address="auto"   ---这个地址值是本机ip建议填写auto
                      port="4000"    ---这个端口可修改几个tomcat配置一致
                      autoBind="100"
                      selectorTimeout="100"
                      maxThreads="6"/>
 
            <Sender className="org.apache.catalina.tribes.transport.ReplicationTransmitter">
              <Transport className="org.apache.catalina.tribes.transport.nio.PooledParallelSender"/>
            </Sender>
            <Interceptor className="org.apache.catalina.tribes.group.interceptors.TcpFailureDetector"/>
            <Interceptor className="org.apache.catalina.tribes.group.interceptors.MessageDispatch15Interceptor"/>
          </Channel>
 
          <Valve className="org.apache.catalina.ha.tcp.ReplicationValve" filter=""/>
          <Valve className="org.apache.catalina.ha.session.JvmRouteBinderValve"/>
 
          <Deployer className="org.apache.catalina.ha.deploy.FarmWarDeployer"
                    tempDir="/tmp/war-temp/"
                    deployDir="/tmp/war-deploy/"
                    watchDir="/tmp/war-listen/"
                    watchEnabled="false"/>
 
          <ClusterListener className="org.apache.catalina.ha.session.JvmRouteSessionIDBinderListener"/>
          <ClusterListener className="org.apache.catalina.ha.session.ClusterSessionListener"/>
        </Cluster>


3.web应用下web.xml配置
 
 在应用的web.xml增加如下配置:
 <distributable/>
原创粉丝点击