tomcat配置集群

在Tomcat中使用集群功能相对简单。最简单的用法是直接在server.xml文件的或节点下添加

<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>

配置,这意味着集群相关的配置都使用默认的,它其实等同于

<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="45564"
                        frequency="500"
                        dropTime="3000"/>
            <Receiver className="org.apache.catalina.tribes.transport.nio.NioReceiver"
                      address="auto"
                      port="4000"
                      autoBind="100"
                      selectorTimeout="5000"
                      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>

默认情况下使用DeltaManager会话管理器;使用GroupChannel作为集群通信通道,组播地址和端口为228.0.0.4和45564,使用ReplicationTransmitter作为消息发射器,使用NioReceiver作为消息接收器,另外添加TcpFailureDetector和MessageDispatch15Interceptor两个拦截器;使用ReplicationValve和JvmRouteBinderValve管道阀门;使用FarmWarDeployer作为集群部署器;添加JvmRouteSessionIDBinderListener和ClusterSessionListener集群监听器。

上一篇:Docker报错 WARNING: IPv4 forwarding is disabled. Networking will not work.


下一篇:《C和指针》 读书笔记 -- 第9章 字符串、字符和字节