我正在使用 JBoss EAP 6.2 和 Apache 2.2.25-no-ssl 来进行应用程序的负载平衡和集群部署。
我想关闭会话复制并打开粘性会话。
但是在做了各种配置之后,我注意到我的负载均衡器没有将基于 session-id 的用户请求粘贴到一个特定的节点,而是将请求转发到另一个节点。
以下是我的集群配置。
集群节点数 = 2
Apache 负载均衡器 = Apache 2.2.25-no-ssl
应用服务器 = JBoss EAP 6.2.0
Apache 负载均衡器配置
worker.properties
# Define list of workers that will be used
# for mapping requests
worker.list=loadbalancer,status
# Define Node1
# modify the host as your host IP or DNS name.
worker.node1.port=8009
worker.node1.host=172.20.150.33
worker.node1.type=ajp13
worker.node1.ping_mode=A
worker.node1.lbfactor=1
# Define Node2
# modify the host as your host IP or DNS name.
worker.node2.port=8209
worker.node2.host=172.20.150.33
worker.node2.type=ajp13
worker.node2.ping_mode=A
worker.node2.lbfactor=1
# Load-balancing behavior
worker.loadbalancer.type=lb
worker.loadbalancer.balance_workers=node1,node2
worker.loadbalancer.sticky_session=1
# Status worker for managing load balancer
worker.status.type=status
uriworkermap.properties
# Simple worker configuration file
# Mount the Servlet context to the ajp13 worker
/*=loadbalancer
mod-jk.conf
# Load mod_jk module
# Specify the filename of the mod_jk lib
LoadModule jk_module modules/mod_jk.so
# Where to find workers.properties
JkWorkersFile conf/workers.properties
# Where to put jk logs
JkLogFile logs/mod_jk.log
# Set the jk log level [debug/error/info]
JkLogLevel debug
# Select the log format
JkLogStampFormat "[%a %b %d %H:%M:%S %Y]"
# JkOptions indicates to send SSK KEY SIZE
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
# JkRequestLogFormat
JkRequestLogFormat "%w %V %T"
# Mount your applications
# The default setting only sends Java application data to mod_jk.
# Use the commented-out line to send all URLs through mod_jk.
# JkMount /* loadbalancer
JkMount /* loadbalancer
# Add shared memory.
# This directive is present with 1.2.10 and
# later versions of mod_jk, and is needed for
# for load balancing to work properly
JkShmFile logs/jk.shm
# You can use external file for mount points.
# It will be checked for updates each 60 seconds.
# The format of the file is: /url=worker
# /examples/*=loadbalancer
JkMountFile conf/uriworkermap.properties
# Add jkstatus for managing runtime data
<Location /jkstatus/>
JkMount status
Order deny,allow
Deny from all
Allow from 127.0.0.1
</Location>
mod-jk.conf 加载在 httpd.conf 文件中,Apache 在端口 80 上运行。
在 JBoss EAP 中,在同一台机器上创建独立文件夹的两个名为node1和node2的副本,如下图所示
启动服务器的命令:
节点1
standalone.bat -c standalone-ha.xml -b 172.20.150.33 -u 230.0.10.0 -Djboss.server.base.dir=../node1 -Djboss.node.name=node1 -Dlogging.configuration=file:/${JBOSS_HOME}/node1/configuration/logging.properties
节点2
standalone.bat -c standalone-ha.xml -b 172.20.150.33 -u 230.0.10.0 -Djboss.server.base.dir=../node2 -Djboss.node.name=node2 -Dlogging.configuration=file:/${JBOSS_HOME}/node2/configuration/logging.properties -Djboss.socket.binding.port-offset=200
我尝试使用 Session Replication On(通过添加 web.xml),但仍然存在同样的问题。
以下是我的 JSESSIONID 观察结果。
应第一次要求
JSESSIONID = SY1d0wVTmX2b-czp50whdmCW.61423f3f-b623-3da4-bd2f-69ba448af636 where 61423f3f-b623-3da4-bd2f-69ba448af636 is JVM-ROUTE for node2.
在第二次请求
JSESSIONID = QMTCTAzt2u-ANTidqZdBIzxO.f742b8d4-46f7-3914-86bb-1044d0a1bfce where f742b8d4-46f7-3914-86bb-1044d0a1bfce is a JVM-ROUTE for node1.
似乎即使 jvm-route 附加到主会话 id ,负载均衡器(apache mod-jk)仍然向其他节点发送请求,而不是坚持建立会话的节点。
请帮忙。