问题描述
具有特定的群集体系结构,其中包含以下详细信息:
Having a specific cluster architecture with the following details:
- 使用Apache的mod_cluster 1.2.0的负载均衡器( 10.10.0.1 ),而无需使用多播进行广告
- 2个处于域模式(主机和从属)的JBoss AS 7.2服务器( jboss-instance-1,jboss-instance-1 ),我使用的是代理列表而不是多播
- Load balancer (10.10.0.1) using Apache's mod_cluster 1.2.0 without advertising using multicast
- 2 JBoss AS 7.2 servers (jboss-instance-1, jboss-instance-1) in domain mode (host and slave), i'm using proxy-list instead of multicast
在domain.xml中,我具有以下设置(仅重要的摘要):
In domain.xml i have the following settings (only important snippets):
...
<subsystem xmlns="urn:jboss:domain:modcluster:1.1">
<mod-cluster-config advertise-socket="modcluster" connector="ajp" balancer="${mycluster.modcluster.balancer:DefaultBalancer}" proxy-list="10.10.0.1:6677">
<dynamic-load-provider>
<load-metric type="busyness"/>
</dynamic-load-provider>
</mod-cluster-config>
</subsystem>
...
...
<server-group name="SG1" profile="ha">
<system-properties>
<property name="mycluster.modcluster.balancer" value="SG1Balancer"/>
</system-properties>
<jvm name="default"/>
<socket-binding-group ref="ha-sockets"/>
</server-group>
<server-group name="SG2" profile="ha">
<system-properties>
<property name="mycluster.modcluster.balancer" value="SG2Balancer"/>
</system-properties>
<jvm name="default"/>
<socket-binding-group ref="ha-sockets"/>
</server-group>
....
在host.xml中(与从属和主机相同):
And in host.xml (same as in slave and host):
....
<servers>
<server name="server-1" group="SG1" auto-start="true">
<socket-bindings port-offset="1"/>
</server>
<server name="server-2" group="SG2" auto-start="true">
<socket-bindings port-offset="2"/>
</server>
....
我需要将每个虚拟主机指向一个特定的服务器组,因此这是我的解决方案:
I need to point each virtual hosts to a specific server-group, so this is my solution for it:
- www.vhost1.com-> SG1Balancer,已附加到group = SG1,因此它将在以下两者之间实现负载平衡:
- jboss-instance-1的服务器-1
- jboss-instance-2的服务器-1
- www.vhost1.com -> SG1Balancer, which is attached to group=SG1, so it will load balance between:
- jboss-instance-1's server-1
- jboss-instance-2's server-1
- jboss-instance-1的服务器2
- jboss-instance-2的服务器2
这是我的httpd配置集:
Here's my httpd configuration sets:
loadbalancer.conf:
loadbalancer.conf:
LoadModule proxy_module modules/mod_proxy.so LoadModule proxy_ajp_module modules/mod_proxy_ajp.so LoadModule slotmem_module modules/mod_slotmem.so LoadModule manager_module modules/mod_manager.so LoadModule proxy_cluster_module modules/mod_proxy_cluster.so LoadModule advertise_module modules/mod_advertise.so <IfModule manager_module> Listen 0.0.0.0:6677 ManagerBalancerName ddrct-cluster <VirtualHost *:6677> ServerName RecetteDtvLb1 <Location /> Order deny,allow Allow from 0.0.0.0 </Location> # No server advertising # we're using proxy-list ServerAdvertise Off KeepAliveTimeout 300 MaxKeepAliveRequests 0 EnableMCPMReceive <Location /mcm> SetHandler mod_cluster-manager Order deny,allow Allow from 0.0.0.0 </Location> </VirtualHost> </IfModule>
vhosts.conf:
vhosts.conf:
ProxyRequests Off NameVirtualHost *:80 <VirtualHost *:80> ServerName www.vhost1.com ProxyPass / balancer://SG1Balancer stickysession=JSESSIONID ProxyPassReverse / balancer://SG1Balancer ProxyPreserveHost On ErrorLog "logs/vhost1_error.log" CustomLog "logs/vhost1_access.log" common </VirtualHost> <VirtualHost *:80> ServerName www.vhost2.com ProxyPass / balancer://SG2Balancer stickysession=JSESSIONID ProxyPassReverse / balancer://SG2Balancer ProxyPreserveHost On ErrorLog "logs/vhost2_error.log" CustomLog "logs/vhost2_access.log" common </VirtualHost>
一切运行正常, G1 中已部署的应用程序可以通过 www.vhost1.com 使用,反之亦然,对于 G2 ,该问题与会话粘性有关,症状如下:
Everything is running fine, deployed apps in G1 can be used through www.vhost1.com and vice versa for G2, the problem is all about session stickyness, here are the symptoms:
- 我的浏览器正在接受JSESSIONID cookie,但是具有以下内容: KhH7gInyAFPsILN6mYDQ84Kf.jboss-instance-1:server-1 不会使我的下一个请求粘贴到jboss-instance-1的服务器上-如图1所示,每次更改JSESSIONID cookie内容时,负载平衡器都会在jboss-instance-1的server-1和jboss-instance-2的server-1之间切换我的请求.
- 当我手动编辑JSESSIONID cookie的内容(使用firecookie插件)以删除服务器名称时,如下所示: KhH7gInyAFPsILN6mYDQ84Kf.jboss-instance-1 ,我的请求将停留在jboss-instance- 1,导致正确的行为
- My browser is accepting JSESSIONID cookie, but having a content like this: KhH7gInyAFPsILN6mYDQ84Kf.jboss-instance-1:server-1 will not get my next request sticked to jboss-instance-1's server-1, the load balancer will switch my requests between jboss-instance-1's server-1 and jboss-instance-2's server-1 and each time it changes the JSESSIONID cookie content.
- When i manually edit the content of JSESSIONID cookie (using firecookie plugin) to remove the server name like this: KhH7gInyAFPsILN6mYDQ84Kf.jboss-instance-1, my requests will be sticking on jboss-instance-1, leading to a correct behaviour
没有获得太多有关多虚拟机和多服务器组集群以及负载平衡配置的文档,实现这种配置是我自己的猜测,我可能会弄错...有什么帮助吗?
Did not get too much documentation about multi-vhost and multi-server-group clustering and load balancing configurations, it was my own guess to implement such configuration, i may get it wrong ... any help ?
推荐答案
问题已解决,来自 KB182813 :
- 请勿在平衡器名称中添加-"字符,因为众所周知,这会造成粘性会话问题
- 请勿在平衡器名称中使用大写字母
这篇关于粘性会话不适用于多个apache虚拟主机和多个JBoss 7.2服务器组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!