![JBoss EAP 7 的 Mod_cluster 负载平衡器中不维护粘性会话](https://linux22.com/image/703350/JBoss%20EAP%207%20%E7%9A%84%20Mod_cluster%20%E8%B4%9F%E8%BD%BD%E5%B9%B3%E8%A1%A1%E5%99%A8%E4%B8%AD%E4%B8%8D%E7%BB%B4%E6%8A%A4%E7%B2%98%E6%80%A7%E4%BC%9A%E8%AF%9D.png)
我正在 JBoss EAP 7 上认证我的应用程序。我的应用程序在独立模式下运行,但在集群模式下,我的应用程序已部署,但我无法登录。我再次重新路由到登录 URL。我已经使用 mod_cluster 设置了集群。
负载均衡器服务器日志中没有错误日志,集群的各个节点上也没有。在我的测试环境中,我的负载均衡器和 2 个服务器节点位于同一台机器上。我为 JBoss 节点提供了不同的端口和实例 ID 来区分节点。我正在从集群中的一个节点共享我的 mod_cluster.conf 和 JBoss standalone-ha.xml 摘录。提前致谢。。请不要否决该问题,请在评论中发送任何建议以重新表述该问题。
以下是 standalone-ha.xml 文件中的代码片段:
Modcluster 设置如下:
<subsystem xmlns="urn:jboss:domain:modcluster:2.0">
<mod-cluster-config advertise-socket="modcluster" proxies="proxy1" balancer="testcluster" advertise="true" connector="ajp">
<dynamic-load-provider>
<load-metric type="busyness"/>
</dynamic-load-provider>
</mod-cluster-config>
</subsystem>
Undertow 设置如下:
<subsystem xmlns="urn:jboss:domain:undertow:3.1" instance-id="node1">
<buffer-cache name="default"/>
<server name="default-server">
<ajp-listener name="ajp" socket-binding="ajp"/>
<http-listener name="default" socket-binding="http" redirect-socket="https"/>
<host name="default-host" alias="localhost">
<location name="/" handler="welcome-content"/>
<filter-ref name="server-header"/>
<filter-ref name="x-powered-by-header"/>
</host>
</server>
<servlet-container name="default">
<jsp-config/>
<websockets/>
</servlet-container>
<handlers>
<file name="welcome-content" path="${jboss.home.dir}/welcome-content"/>
</handlers>
<filters>
<response-header name="server-header" header-name="Server" header-value="JBoss-EAP/7"/>
<response-header name="x-powered-by-header" header-name="X-Powered-By" header-value="Undertow/1"/>
</filters>
</subsystem>
套接字绑定组的内容为:
<socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}">
<socket-binding name="management-http" interface="management" port="${jboss.management.http.port:9990}"/>
<socket-binding name="management-https" interface="management" port="${jboss.management.https.port:9993}"/>
<socket-binding name="ajp" port="${jboss.ajp.port:8009}"/>
<socket-binding name="http" port="${jboss.http.port:8080}"/>
<socket-binding name="https" port="${jboss.https.port:8443}"/>
<socket-binding name="jgroups-mping" interface="private" port="0" multicast-address="${jboss.default.multicast.address:230.0.0.4}" multicast-port="45700"/>
<socket-binding name="jgroups-tcp" interface="private" port="7600"/>
<socket-binding name="jgroups-tcp-fd" interface="private" port="57600"/>
<socket-binding name="jgroups-udp" interface="private" port="55200" multicast-address="${jboss.default.multicast.address:230.0.0.4}" multicast-port="45688"/>
<socket-binding name="jgroups-udp-fd" interface="private" port="54200"/>
<socket-binding name="modcluster" port="0" multicast-address="224.0.1.105" multicast-port="23364"/>
<socket-binding name="txn-recovery-environment" port="4712"/>
<socket-binding name="txn-status-manager" port="4713"/>
<outbound-socket-binding name="mail-smtp">
<remote-destination host="localhost" port="25"/>
</outbound-socket-binding>
<outbound-socket-binding name="proxy1">
<!-- host and port number of the load-balancer. -->
<remote-destination host="x.x.x.x" port="81"/>
</outbound-socket-binding>
</socket-binding-group>
mod_cluster.conf的内容如下:
LoadModule proxy_cluster_module modules/mod_proxy_cluster.so
LoadModule cluster_slotmem_module modules/mod_cluster_slotmem.so
LoadModule manager_module modules/mod_manager.so
LoadModule advertise_module modules/mod_advertise.so
MemManagerFile "//httpd2.4.6Home/var/cache/mod_cluster"
<IfModule manager_module>
Listen 81
<VirtualHost *:81>
<Directory />
Require all granted
</Directory>
<Location />
Require all granted
</Location>
<Location /mod_cluster_manager>
SetHandler mod_cluster-manager
Require all granted
</Location>
KeepAliveTimeout 60
MaxKeepAliveRequests 0
ManagerBalancerName testcluster
AdvertiseFrequency 5
ServerAdvertise on
EnableMCPMReceive
</VirtualHost>
</IfModule>
答案1
这看起来确实像是会话粘性问题。
在我看来,您的配置似乎没问题。您可以在应用程序上执行 curl 调用吗?或者只是一些 JSP 页面来验证您的配置。
curl -b cookie.txt -c cookie.txt YOUR_BALANCER_ADDRESS/YOURAPP -v
你能在你的应用上执行 curl 调用吗?或者只是一些 JSP 页面来验证你的配置。
curl -b cookie.txt -c cookie.txt YOUR_BALANCER_ADDRESS/YOURAPP -v
或者使用这个 groovy 脚本
final char CR = '\r'
final char LF = '\n'
String host = (args.size() >= 1) ? args[0] : '127.0.0.1'
int port = (args.size() >= 2) ? Integer.parseInt(args[1]) : 8080
String path = (args.size() >= 3) ? args[2] : "/clusterbench/jvmroute"
Socket socket
OutputStreamWriter out
InputStream ins
BufferedReader reader
try {
socket = new Socket(host, port)
def req = "GET ${path} HTTP/1.1" + CR + LF +
"Host: ${host}:${port}" + CR + LF +
'Accept: */*' + CR + LF +
'Connection: close' + CR + LF + CR + LF
println "Sending request \n" + req
socket = new Socket(host, port)
out = new OutputStreamWriter(socket.getOutputStream(), "UTF-8")
out.write(req)
out.flush()
ins = socket.getInputStream()
reader = new BufferedReader(new InputStreamReader(ins))
reader.readLines().each { line ->
println line
}
} catch (Exception ex) {
println "Exception: " + ex
} finally {
socket?.close()
out?.close()
reader?.close()
}
用法是:
groovy test.groovy IP_ADDRESS PORT PATH_TO_APP
例子:
groovy test.groovy 127.0.0.1 2080 "/clusterbench/jvmroute"
输出:发送请求 GET /clusterbench/jvmroute HTTP/1.1 主机:192.168.122.206:2080 接受:/ 连接:关闭
HTTP/1.1 200 OK
Date: Wed, 07 Jun 2017 08:18:03 GMT
Server: JBoss-EAP/7
X-Powered-By: Undertow/1
Set-Cookie: JSESSIONID=TK454oHgFFX05Duw7LxTS3bO4JyyMLcqrqv5IWm_.jboss-eap-7.1-2; path=/clusterbench
Content-Type: text/plain;charset=UTF-8
Content-Length: 15
Connection: close
我们正在寻找“Set-Cookie:”标头来验证工作节点是否正确设置了 sessionId 及其 jvm 路由。
如果他这么做,那么问题就会出在别处
Mod-cluster 管理器控制台输出也可能有帮助。
我什么都没想起来。
您在同一台机器上运行 2 个 EAP,没有指定名称,它们没有集群。Mod-cluster 管理器控制台输出将显示这一点。EAP 日志输出也可能有帮助
EAP 节点未设置 jvmRoute,并且它们未集群(curl、EAP 日志可能会有帮助)
您的应用未设置 sessionID(随机 JSP 页面 curl 请求可能会有帮助)
抱歉,我无法提供更多帮助