免费资源网 – https://freexyz.cn/
Tomcat 后端服务器实现 Session ID会话保持
基础架构:
7-6 代理服务器nginx配置
7-3 tomcat 服务器
7-5 同理
测试:
此时刷新,会话ID一直在变,这样不好
如何解决呢?
不好的是确定ip之后,会一直在一台机上,不调度了
但是这样不调度又不好了
我们在tomcat添加以下配置,实现sessionID不变,却依旧可以调度
官网文档:Apache Tomcat 9 (9.0.87) – Clustering/Session Replication How-To
<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.MessageDispatchInterceptor”/> </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.ClusterSessionListener”/> </Cluster>7-3
再改一处
也是在官方文档里面
7-5
测试:
IP地址在变,但此时的sessionID不变
© 版权声明
THE END
暂无评论内容