[英]To use apache as load balancer with sticky session - Need sticky session based load balancing
I am using apache as LB with sticky session handling (using 2 tomcats as balancer member). 我正在使用apache作为具有粘性会话处理的LB(使用2个tomcat作为平衡器成员)。
Below are config. 下面是配置。 done by me at apache level - 由我在apache级别完成-
<Proxy balancer://mycluster>
(...)
ProxySet stickysession=JSESSIONID
BalancerMember http://{ip/hostname of tomcat1 backed:port} route=tomcat1
BalancerMember http://{ip/hostname of tomcat2 backed:port} route=tomcat2
</Proxy>
ProxyPass / “balancer://mycluster”
PorxyPassReverse / “balancer://mycluster”
Defining jvm route at tomcat level - 在tomcat级别定义JVM路由-
(...)
<Engine name="Catalina" defaultHost="localhost" jvmRoute="tomcat1"> ##where the jvmroute should be the route value set at apache config.
(...)
same is been defined for tomcat 2 also 同样为tomcat 2定义了
(...)
<Engine name="Catalina" defaultHost="localhost" jvmRoute="tomcat2"> ##where the jvmroute should be the route value set at apache config.
(...)
Everything works fine, but the main drawback of this setup is if tomcat1 goes down then session sticked to tomcat1 also dies and doesn't route to tomcat2. 一切正常,但是此设置的主要缺点是,如果tomcat1崩溃,则粘在tomcat1上的会话也会死亡,并且不会路由到tomcat2。
Is there any way to replicate sticky session to tomcat2 also, or simply if tomcat1 dies then session is been transferred to tomcat2 & vice-versa? 是否有任何方法也可以将粘性会话复制到tomcat2,或者简单地,如果tomcat1死了,则将会话转移到tomcat2,反之亦然?
Use of "sticky sessions" is only a mechanism to ensure that all requests for the same session go to the same node when multiple nodes could possibly be used. “粘性会话”的使用仅是一种机制,以确保在可能使用多个节点时,针对同一会话的所有请求都到达同一节点。 If you want session fail-over, you need Clustering . 如果要会话故障转移,则需要Clustering 。
There are many guides for how to do clustering with Tomcat. 关于如何与Tomcat进行群集的指南很多。 There are also several presentations on Tomcat's Presentations Page for background on how clustering works and how to configure it. Tomcat的“演示文稿”页面上也有一些演示文稿, 介绍了群集如何工作以及如何配置群集的背景知识。
Note that you may have to make some changes to your application in order for clustering to work properly. 请注意,您可能必须对应用程序进行一些更改才能使群集正常工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.