本人想利用tomcat6.0自带的集群功能与Apache2组成集群并配置负载均衡,现有2台测试主机tomcat1和tomcat2,配置文件server.xml已在附件中,两主机通过ajp1.3与apache2相连,apache配置文件workers.properties和mod_jk.conf也放在附件中,现在令我头疼的是两台tomcat主机无法进行session复制,从而造成session丢失。我具体的操作步骤如下:
1、启动Apache2
2、启动tomcat1应用
3、客户端连接apache,产生session
4、启动tomcat2应用在tomcat2启动过程及日志如下:
集群启动,并相互注册2008-1-15 9:57:53 org.apache.catalina.tribes.membership.McastServiceImpl waitForMembers
信息: Sleeping for 1000 milliseconds to establish cluster membership, start level:4
2008-1-15 9:57:53 org.apache.catalina.ha.tcp.SimpleTcpCluster memberAdded
信息: Replication member added:org.apache.catalina.tribes.membership.MemberImpl[tcp://localhost.localdomain:4000,localhost.localdomain,4000, alive=167774,id={-83 -84 59 -119 58 112 76 -55 -80 -86 42 -18 40 103 14 -37 }, payload={}, command={}, domain={}, ]
2008-1-15 9:57:53 org.apache.catalina.tribes.io.BufferPool getBufferPool
信息: Created a buffer pool with max size:104857600 bytes of type:org.apache.catalina.tribes.io.BufferPool15Impl注册已经成功,请求tomcat1复制其session
2008-1-15 9:59:03 org.apache.catalina.ha.session.DeltaManager getAllClusterSessions
警告: Manager [localhost#], requesting session state from org.apache.catalina.tribes.membership.MemberImpl[tcp://localhost.localdomain:4000,localhost.localdomain,4000, alive=238154,id={-83 -84 59 -119 58 112 76 -55 -80 -86 42 -18 40 103 14 -37 }, payload={}, command={}, domain={}, ]. This operation will timeout if no session state has been received within 60 seconds.
2008-1-15 10:00:14 org.apache.catalina.ha.session.DeltaManager waitForSendAllSessions
严重: Manager [localhost#]: No session state send at 08-1-15 上午9:59 received, timing out after 60,099 ms.
2008-1-15 10:00:14 org.apache.catalina.ha.session.DeltaManager getAllClusterSessions
警告: Manager [localhost#]: Drop message SESSION-GET-ALL inside GET_ALL_SESSIONS sync phase start date 08-1-15 上午9:59 message date 70-1-1 上午8:00问题来了,“No session state send ” 步骤3时已经有session的创建,为什么这时没有复制呢?而且当另一个客户端建立session时,集群成员也不会通知另一方。此问题我查了很长事件也没有发现问题所在,还望大家能帮我出出主意,在此先谢谢了由于配置文件无法上传,在此贴出了
tomcat1.xml
<Engine name="Catalina" defaultHost="localhost" jvmRoute="tomcat1">
<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" mcastAddr="228.0.0.4" mcastPort="45564" mcastFrequency="500" mcastDropTime="3000"/> 
<Receiver className= "org.apache.catalina.tribes.transport.nio.NioReceiver" tcpListenAddress= "auto" tcpListenPort= "4000" tcpSelectorTimeout="5000" tcpThreadCount= "6"/> 
<Sender className="org.apache.catalina.tribes.transport.ReplicationTransmitter" replicationMode="synchronous" resend="true" autoConnect="true">
<!--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= ""/--> 
<Valve className= "org.apache.catalina.ha.session.JvmRouteBinderValve"/> 
<Deployer className= "org.apache.catalina.ha.deploy.FarmWarDeployer" tempDir= "/tmp/war-temp/" deployDir= "/tmp/war-deploy/" watchDir= "/tmp/war-listen/" watchEnabled= "false"/> 
<ClusterListener className= "org.apache.catalina.ha.session.JvmRouteSessionIDBinderListener"/> 
<ClusterListener className= "org.apache.catalina.ha.session.ClusterSessionListener"/> 
</Cluster>
mod_jk.conf# 指出mod_jk模块工作所需要的工作文件workers.properties的位置
JkWorkersFile /opt/sudytech/apache2/conf/workers.properties# Where to put jk logs
JkLogFile /opt/sudytech/apache2/logs/mod_jk.log# Set the jk log level [debug/error/info]
JkLogLevel info# Select the log format
JkLogStampFormat "[%a %b %d %H:%M:%S %Y]"# JkOptions indicate to send SSL KEY SIZE, 
JkOptions  +ForwardKeySize +ForwardURICompat -ForwardDirectories# JkRequestLogFormat set the request format 
JkRequestLogFormat "%w %V %T"# 将所有servlet 和jsp请求通过ajp13的协议送给Tomcat,让Tomcat来处理
JkMount /*.jsp worker1
JKMount /*.jspy worker1
JKMount /*.faces worker1JkMount /resource-tomcat-status status
workers.properties# Defining a worker named worker1 and of type ajp13
worker.list=worker1,status# Set properties for worker1
worker.tomcat1.port=8010
worker.tomcat1.host=172.18.10.5
worker.tomcat1.type=ajp13
worker.tomcat1.lbfactor=1
worker.tomcat1.redirect=tomcat2worker.tomcat2.port=8010
worker.tomcat2.host=127.0.0.1
worker.tomcat2.type=ajp13
worker.tomcat2.lbfactor=1
worker.tomcat2.redirect=tomcat1
worker.tomcat2.activation=disabledworker.worker1.type=lb
worker.worker1.balance_workers=tomcat1,tomcat2
worker.worker1.method=B
worker.worker1.sticky_session=1worker.status.type=status