tomcat 集群配置,Session复制共享

出处:http://www.cnblogs.com/hanxianlong/p/3456780.html


本配置在tomcat7上验证通过。通过此方法配置的集群,session信息将会被自动复制到各个节点。

1、配置Server.xml

在Server.xml中,找到被注释<Cluster/>节点,修改为如下:

复制代码

<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"bind="127.0.0.1"address="228.0.0.4"<!--保留ip,用于广播-->port="45564"
frequency="500"
dropTime="3000"/> 
<Receiver className="org.apache.catalina.tribes.transport.nio.NioReceiver"address="auto"port="4001"<!--如果是在同一台机器上的两个tomcat做负载,则此端口则不能重复-->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=""/><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>

复制代码

 

2、修改web.xml

在web.xml中,标志为 <distributable/> 

<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4"> <display-name>session</display-name> <distributable/> </web-app>


你可能感兴趣的:(session复制,tomact集群)