本次测试各版本说明:
apache 2.2 openfire 3.8.1 集群插件:hazelcast
1,修改openfire代码
1.1 HttpBindManager.java
1.2修改conf/openfire.xml
增加下面配置
true 此行是用来默认开启集群
openfire_e
2,通过JSESSIONID做session stickyness
2.1 修改 openfire HttpBindServlet.java代码
2.2 apache开启如下模块功能
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
LoadModule proxy_http_module modules/mod_proxy_http.so
如果使用openfire jetty ajp连接需要使用下面模块
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
2.3 在apache httpd.conf添加配置
ProxyRequests Off
ProxyPreserveHost On
ProxyPass /http-bind/ balancer://openfirecluster stickysession=JSESSIONID|jsessionid nofailover=On
ProxyPassReverse /http-bind/ balancer://openfirecluster stickysession=JSESSIONID|jsessionid
BalancerMember http://192.168.112.199:7077/http-bind/ route=openfire_a
BalancerMember http://192.168.112.54:7077/http-bind/ route=openfire_b
3.通过自定义cookie名做session stickyness
3.1 apache开启如下模块功能
LoadModule headers_module modules/mod_headers.so
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
LoadModule proxy_http_module modules/mod_proxy_http.so
如果使用openfire jetty ajp连接需要使用下面模块
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
3.2 在apache httpd.conf添加配置
ProxyRequests Off
ProxyPreserveHost On
Header add Set-Cookie "ROUTEID=ofroute.%{BALANCER_WORKER_ROUTE}e; path=/http-bind;" env=BALANCER_ROUTE_CHANGED
BalancerMember http://192.168.112.199:7077/http-bind/ route=openfire_e
BalancerMember http://192.168.112.54:7077/http-bind/ route=openfire_s
ProxySet stickysession=ROUTEID
ProxyPass /http-bind/ balancer://openfirecluster nofailover=On
ProxyPassReverse /http-bind/ balancer://openfirecluster
可以通过如下打开负载均衡控制台http://localhost:8888/balancer-manager apache端口:8888
ProxyPass /balancer-manager !
SetHandler balancer-manager
Order allow,deny
Allow from all