集群/会话复制 tomcat 9 两台不同的机器

集群/会话复制 tomcat 9 两台不同的机器

我正在尝试在不同的 EC2 (AWS) 实例上的两个 tomcat 上配置会话复制。我在互联网上找不到此类配置的任何示例。我已根据此文档准备了配置:集群指南

雄猫1:

<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster" 
           channelSendOptions="8" channelStartOptions = "3">
      <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.StaticMembershipService">
                <LocalMember className="org.apache.catalina.tribes.membership.StaticMember"
                          uniqueId="{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,0}"/>
                <Member className="org.apache.catalina.tribes.membership.StaticMember"
                          port="4110"
                          host="10.0.200.221"
                          domain="tomcat-sys-ws"
                          uniqueId="{0,2,3,4,5,6,7,8,9,10,11,12,13,14,15,1}" />
            </Membership>

           <Receiver className="org.apache.catalina.tribes.transport.nio.NioReceiver"
                     address="10.0.200.82"
                     port="4110"
                     autoBind="9"
                     selectorTimeout="2000"
                     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.TcpPingInterceptor"/>
           <Interceptor className="org.apache.catalina.tribes.group.interceptors.TcpFailureDetector"/>
           <Interceptor className="org.apache.catalina.tribes.group.interceptors.MessageDispatchInterceptor"/>
           <Interceptor className="org.apache.catalina.tribes.group.interceptors.ThroughputInterceptor"/>

           <Interceptor className="org.apache.catalina.tribes.group.interceptors.StaticMembershipInterceptor">
                <Member className="org.apache.catalina.tribes.membership.StaticMember"
                          port="4110"
                          host="10.0.200.221"
                          domain="tomcat-sys-ws"
                          uniqueId="{0,2,3,4,5,6,7,8,9,10,11,12,13,14,15,1}" />
           </Interceptor>

      </Channel>

      <Valve className="org.apache.catalina.ha.tcp.ReplicationValve" filter=""/>
      <Valve className="org.apache.catalina.ha.session.JvmRouteBinderValve"/>

      <ClusterListener className="org.apache.catalina.ha.session.ClusterSessionListener"/>
 </Cluster>

雄猫2

 <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster" 
           channelSendOptions="8" channelStartOptions = "3">
      <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.StaticMembershipService">
                <LocalMember className="org.apache.catalina.tribes.membership.StaticMember"
                             uniqueId="{0,2,3,4,5,6,7,8,9,10,11,12,13,14,15,1}"/>
                <Member className="org.apache.catalina.tribes.membership.StaticMember"
                          port="4110"
                          host="10.0.200.82"
                          domain="tomcat-sys"
                          uniqueId="{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,0}" />
            </Membership>

           <Receiver className="org.apache.catalina.tribes.transport.nio.NioReceiver"
                     address="10.0.200.221"
                     port="4110"
                     autoBind="9"
                     selectorTimeout="2000"
                     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.TcpPingInterceptor"/>
           <Interceptor className="org.apache.catalina.tribes.group.interceptors.TcpFailureDetector"/>
           <Interceptor className="org.apache.catalina.tribes.group.interceptors.MessageDispatchInterceptor"/>
           <Interceptor className="org.apache.catalina.tribes.group.interceptors.ThroughputInterceptor"/>

           <Interceptor className="org.apache.catalina.tribes.group.interceptors.StaticMembershipInterceptor">
                <Member className="org.apache.catalina.tribes.membership.StaticMember"
                          port="4110"
                          host="10.0.200.82"
                          domain="tomcat-sys"
                          uniqueId="{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,0}" />
           </Interceptor>

      </Channel>

      <Valve className="org.apache.catalina.ha.tcp.ReplicationValve" filter=""/>
      <Valve className="org.apache.catalina.ha.session.JvmRouteBinderValve"/>

      <ClusterListener className="org.apache.catalina.ha.session.ClusterSessionListener"/>
 </Cluster>

命令输出lsof -i -P -n | grep 4110

雄猫1:

java    3872   ws   61u  IPv6  28517      0t0  TCP 10.0.200.82:4110 (LISTEN)
java    3872   ws   69u  IPv6  30873      0t0  TCP 10.0.200.82:4110->10.0.200.221:47020 (ESTABLISHED)
java    3872   ws   77u  IPv6  30882      0t0  TCP 10.0.200.82:58452->10.0.200.221:4110 (ESTABLISHED)

tomcat2:

java      6888 mibbot   62u  IPv6  28987      0t0  TCP 10.0.200.221:4110 (LISTEN)
java      6888 mibbot   71u  IPv6  28590      0t0  TCP 10.0.200.221:47020->10.0.200.82:4110 (ESTABLISHED)
java      6888 mibbot  281u  IPv6  29035      0t0  TCP 10.0.200.221:4110->10.0.200.82:58452 (ESTABLISHED)

集群日志文件中的错误:

23-Apr-2020 11:28:18.498 FINE [Tribes-Task-Receiver[Catalina-Channel]-1] org.apache.catalina.tribes.transport.nio.NioReplicationTask.remoteEof Channel closed on the remote end, disconnecting
23-Apr-2020 11:28:20.643 INFO [MessageDispatchInterceptor.MessageDispatchThread[Catalina-Channel]1] org.apache.catalina.tribes.group.interceptors.ThroughputInterceptor.report ThroughputInterceptor Report[
        Tx Msg:1 messages
        Sent:0.00 MB (total)
        Sent:0.00 MB (application)
        Time:0.00 seconds
        Tx Speed:∞ MB/sec (total)
        Tx Speed:∞ MB/sec (application)
        Error Msg:0
        Rx Msg:4 messages
        Rx Speed:0.00 MB/sec (since 1st msg)
        Received:0.00 MB]

23-Apr-2020 11:28:23.498 FINE [Tribes-Task-Receiver[Catalina-Channel]-5] org.apache.catalina.tribes.group.interceptors.TcpFailureDetector.messageReceived Received a failure detector packet:ClusterData[src=org.ap
ache.catalina.tribes.membership.MemberImpl[tcp://{10, 0, 200, 221}:4110,{10, 0, 200, 221},4110, alive=1587638117809, securePort=-1, UDP Port=-1, id={0 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1 }, payload={}, command={
}, domain={}]; id={-110 -41 53 -5 37 -7 72 -84 -101 52 55 37 -46 3 83 41 }; sent=2020-04-23 11:28:23.497]

知道我应该改变我的配置吗?

答案1

移动

      <Manager className="org.apache.catalina.ha.session.DeltaManager"
               expireSessionsOnShutdown="false"
               notifyListenersOnReplication="true"/>

到 context.xml

相关内容