简体   繁体   English

要将Apache用作具有粘性会话的负载平衡器-需要基于粘性会话的负载平衡

[英]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.

相关问题 如何使用apache mod_proxy_balancer基于会话标识符启用粘性负载平衡 - How do I enable sticky load balancing based on session identifiers using apache mod_proxy_balancer Apache 作为反向代理和负载均衡器需要使用粘性会话 - Apache as Reverse-Proxy and Load-Balancer need to use sticky session 为Apache / Tomcat负载平衡启用粘性会话模式 - Enabling sticky session mode for Apache/Tomcat load balancing 粘性会话,用于多个域的负载平衡 - Sticky session for load balancing with multiple domains 使用Apache和mod_proxy_balancer进行轻微的粘性负载平衡 - Slightly sticky load-balancing with Apache and mod_proxy_balancer 在 Apache http 服务器中启用负载平衡和粘性 session 是必需的 worker.properties - Is worker.properties is mandatory to enable load balancing and sticky session in Apache http server Apache:按会话进行负载平衡 - Apache: Load balancing by session Apache + Tomcat - 粘性会话和负载平衡问题 - Apache + Tomcat - Problems with sticky sessions and load balancing 带有cookie的Apache负载均衡器,在PHP中更改ROUTEID /粘性cookie - Apache load balancer with cookies, change ROUTEID / sticky cookie in PHP 使用tomcat的Apache负载平衡:丢失会话 - Apache load balancing with tomcat : losing session
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM