Tomcat 6会话复制不适用于HAProxy

我有HAProxy负载均衡器和两个Tomcat后端服务器。 HAProxyconfiguration了基于cookie的持久性,Tomcat根据文档configuration了SimpleTcpCluster。 两个Tomcat后端服务器之间的组播被启用。 但会话复制不起作用。 每当我closures服务器举行会议,用户注销。 在catalina.out中,我看到服务器正在相互通信,例如,当我取下一个后端时:

2014年5月8日上午11:00:25 org.apache.catalina.tribes.group.interceptors.TcpFailureDetector performBasicCheck信息:可疑成员,已确认死亡。[org.apache.catalina.tribes.membership.MemberImpl [tcp:// { 10,2,1,69}:5000,{10,2,1,69},5000,alive = 931801,id = { – 18 123 59 -88 -95 20 78 -34 -83 31 -43 73 -64 -71 42 -62},有效载荷= {},命令= {},域= {},]]

另外,当我采取后端:

警告:Manager [webservice#],从org.apache.catalina.tribes.membership.MemberImpl [tcp:// {10,2,1,69}:5000,{10,2,1,69})请求会话状态。 5000,alive = 672675,id = { – 18 123 59 -88 -95 20 78 -34 -83 31 -43 73 -64 -71 42 -62},payload = {},command = {},domain = {} ,]。 如果在60秒内没有收到会话状态,此操作将超时。 2014年5月8日上午10:54:21 org.apache.catalina.tribes.group.interceptors.ThroughputInterceptor报告信息:ThroughputInterceptor报告Tx消息:1个消息已发送:0.00 MB(总计)已发送:0.00 MB(应用程序)时间:0.01秒发送速度:0.04 MB /秒(总计)TxSpeed:0.04 MB /秒(应用程序)错误消息:0 Rx消息:0消息Rx速度:0.00 MB /秒(自第一个msg)接收:0.00 MB]

2014年5月8日上午10:54:21 org.apache.catalina.ha.session.DeltaManager waitForSendAllSessions INFO:Manager [webservice#]; 会话状态在111年5月8日上午10:54 AM发送。

所以,群集和多播正在工作。

这里是HAProxy后端configuration:

backend BE-tomcat_http mode http cookie SERVERID insert indirect nocache balance leastconn timeout connect 30000 timeout server 30000 retries 3 option httpchk OPTIONS / option redispatch option http-server-close option http-pretend-keepalive server node01 10.2.1.69:80 cookie node01 check inter 1000 server node02 10.2.1.90:80 cookie node02 check inter 1000 

这里是Tomcat server.xml

  <Engine name="Catalina" defaultHost="localhost" jvmRoute="node01"> <Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/> <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster" channelSendOptions="8"> <Manager className="org.apache.catalina.ha.session.DeltaManager" expireSessionsOnShutdown="false" notifyListenersOnReplication="true" mapSendOptions="8"/> <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="5000" selectorTimeout="500" minThreads="2" 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"/> <Interceptor className="org.apache.catalina.tribes.group.interceptors.ThroughputInterceptor"/> </Channel> <Valve className="org.apache.catalina.ha.tcp.ReplicationValve" filter=".*\.gif;.*\.js;.*\.jpg;.*\.png;.*\.htm;.*\.html;.*\.css;.*\.txt;"/> <ClusterListener className="org.apache.catalina.ha.session.JvmRouteSessionIDBinderListener"/> <ClusterListener className="org.apache.catalina.ha.session.ClusterSessionListener"/> <!-- <Deployer className="org.apache.catalina.ha.deploy.FarmWarDeployer" tempDir="/tmp/war-temp/" deployDir="/tmp/war-deploy/" watchDir="/tmp/war-listen/" watchEnabled="false"/> --> </Cluster> 

我发现cookie的持久性是有效的,因为当用户login时,只要会话有效,它们就会被粘贴到一个后端服务器上。 但是当我closures服务器持有会话,用户被踢出虽然我看到在其他服务器注意到的日志文件。

另外web.xml有可分配的元素集。

有任何想法吗?

谢谢

我看不到您提供的configuration有问题。 几点build议给你。

  1. 您可以通过进入pipe理器( http:// node01:80 / manager / html )来确认会话复制到集群中的每个节点,并查看其他节点的pipe理器中的每个会话。

    我怀疑你不复制,因为节点的损失不应该杀死会话。

  2. 检查端口5000的防火墙规则,以及多播地址228.0.0.4

    我们在防火墙configuration中遇到了大多数问题!