Tomcat Session 共享的配置

 

修改改动的配置文件如下:

Tomcat/conf/server.xml:

<Engine defaultHost="localhost" name="Catalina" jvmRoute="jvm1">

 

<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.4"    

port="45564"    

frequency="500"    

dropTime="3000"/>     

<Receiver className="org.apache.catalina.tribes.transport.nio.NioReceiver"    

  address="auto"  

  port="4005"    

  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"/>     

<Interceptor className="org.apache.catalina.tribes.group.interceptors.ThroughputInterceptor"/>     

  </Channel>     

 

  <Valve className="org.apache.catalina.ha.tcp.ReplicationValve" filter=""/>     

  <Valve className="org.apache.catalina.ha.session.JvmRouteBinderValve"/>     

 

  <ClusterListener className="org.apache.catalina.ha.session.JvmRouteSessionIDBinderListener"/>     

  <ClusterListener className="org.apache.catalina.ha.session.ClusterSessionListener"/>     

</Cluster>  

 

Tomcat/webapps/HaierFramework/WEB-INF/web.xml:

<distributable/>

</web-app>

 
备注: 各台服务器之间需要对Tomcat的4个端口和45565 4005端口 开放tcp,udp访问,此种方法是用的时ha*.jar.
下面列出tomcat5.5的配置方法:

Tomcat/conf/server.xml:

<Cluster className="org.apache.catalina.cluster.tcp.SimpleTcpCluster"
managerClassName="org.apache.catalina.cluster.session.DeltaManager"
expireSessionsOnShutdown="false"
useDirtyFlag="true"
notifyListenersOnReplication="true">
<Membership
className="org.apache.catalina.cluster.mcast.McastService"
mcastAddr="228.0.0.4"
mcastPort="45565"
mcastFrequency="500"
mcastDropTime="3000"/>
<Receiver
className="org.apache.catalina.cluster.tcp.ReplicationListener"
tcpListenAddress="10.135.106.111"
tcpListenPort="4006"
tcpSelectorTimeout="100"
tcpThreadCount="6"/>
<Sender
className="org.apache.catalina.cluster.tcp.ReplicationTransmitter"
replicationMode="pooled"
ackTimeout="15000"
waitForAck="true"/>
<Valve className="org.apache.catalina.cluster.tcp.ReplicationValve"
filter=""/>

<Deployer className="org.apache.catalina.cluster.deploy.FarmWarDeployer"
tempDir="/tmp/war-temp/"
deployDir="/tmp/war-deploy/"
watchDir="/tmp/war-listen/"
watchEnabled="false"/>

<ClusterListener className="org.apache.catalina.cluster.session.ClusterSessionListener"/>
</Cluster>

 

Tomcat/webapps/HaierFramework/WEB-INF/web.xml:

<distributable/>

</web-app>

 

附件中上传一个测试session共享的jsp:sessionShare.jsp

你可能感兴趣的:(session)