我已经配置了HttpServer2.2来实现我的java应用程序的load balancing和Clustering。
但是Load Balancing工作正常,而Clustering(session replication)不工作。
我在HttpServer中的worker.properties将是,
workers.java_home=C:/Program Files/Java/jdk1.6.0_25
#worker.list=worker1,worker2
worker.list=balancer
worker.worker1.port=8009
worker.worker1.host=localhost
worker.worker1.type=ajp13
worker.worker1.lbfactor=1
worker.worker2.port=8019
worker.worker2.host=192.168.100.84
worker.worker2.type=ajp13
worker.worker2.lbfactor=1
worker.balancer.type=lb
worker.balancer.balance_workers=worker1,worker2
worker.balancer.method=B
# Specifies whether requests with SESSION ID's
# should be routed back to the same #Tomcat worker.
worker.balancer.sticky_session =Truehttpd.conf将会是,
<IfModule jk_module>
JkWorkersFile conf/workers.properties
JkLogFile logs/mod_jk.log
JkLogLevel info
JkMount /CustomerChat_V1.02.00 balancer
JkMount /CustomerChat_V1.02.00/* balance
</IfModule>在我的Tomcat one server.xml中,
<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"
channelSendOptions="8">
<Manager className="org.apache.catalina.ha.session.DeltaManager"
expireSessionsOnShutdown="false"
notifyListenersOnReplication="true"/>
<Channel className="org.apache.catalina.tribes.group.GroupChannel">
<Membership className="org.apache.catalina.tribes.membership.McastService"
address="228.0.0.8"
port="45564"
frequency="500"
dropTime="3000" />
<Receiver className="org.apache.catalina.tribes.transport.nio.NioReceiver"
address="auto"
port="4200"
autoBind="100"
selectorTimeout="5000"
maxThreads="6" />
<Sender className="org.apache.catalina.tribes.transport.ReplicationTransmitter">
<Transport className="org.apache.catalina.tribes.transport.nio.PooledParallelSender"/>
</Sender>
<Interceptor className="org.apache.catalina.tribes.group.interceptors.TcpFailureDetector"/>
<Interceptor className="org.apache.catalina.tribes.group.interceptors.MessageDispatch15Interceptor"/>
</Channel>
<Valve className="org.apache.catalina.ha.tcp.ReplicationValve"
filter=".*\.gif;.*\.js;.*\.jpg;.*\.htm;.*\.html;.*\.txt;" />
<Deployer className="org.apache.catalina.ha.deploy.FarmWarDeployer"
tempDir="D:/cluster/temp/war-temp/"
deployDir="D:/cluster/temp/war-deploy/"
watchDir="D:/cluster/temp/war-listen/"
watchEnabled="false" />
<ClusterListener className="org.apache.catalina.ha.session.JvmRouteSessionIDBinderListener"/>
<ClusterListener className="org.apache.catalina.ha.session.ClusterSessionListener"/>
</Cluster>在我的Tomcat two server.xml中,
<Receiver className="org.apache.catalina.tribes.transport.nio.NioReceiver"
address="192.168.0.1"
port="4100"
autoBind="100"
selectorTimeout="5000"
maxThreads="6" />但仍然存在问题。
当我关闭Tomcat one时,新请求将自动发送到tomcat two。但是Tomcat two并不知道应用程序的当前用户状态和他存储的会话对象。
希望我们的堆栈成员能在这方面帮助我。
好的答案肯定是值得欣赏的。
发布于 2013-05-09 20:28:28
一些评论/建议
Tomcat集群,请参阅tomcat版本特定文档。这里是Tomcat 6.0 session clustering的链接。
编辑:
在配置中,您提到了
worker.balancer.sticky_session =True这将使HttpServer将所有请求发送到首次创建会话的tomcat (会话被固定在该服务器上,因此名称为粘滞会话)。这违背了会话集群的目的。请将其设置为false。
发布于 2021-08-02 11:51:20
作为一个很好的替代方案,可以使用基于Redis的Tomcat Session clustering。配置它所需的工作量要少得多。
First,添加会话管理器您的context.xml文件:
<Manager className="org.redisson.tomcat.RedissonSessionManager"
configPath="${catalina.base}/redisson.yaml"
readMode="MEMORY" updateMode="DEFAULT"/>第二个,创建redisson.yaml配置文件:
singleServerConfig:
address: "redis://my-redis:6379"第三个,将Redisson项目中的两个jars拷贝到с_BASE/lib目录中:
redisson-all-3.16.1.jar
对于Tomcat 7.x - redisson-tomcat-7-3.16.1.jar
对于Tomcat 8.x - redisson-tomcat-8-3.16.1.jar
对于Tomcat 9.x - redisson-tomcat-9-3.16.1.jar
对于Tomcat 10.x - redisson-tomcat-10-3.16.1.jar
https://stackoverflow.com/questions/16460716
复制相似问题