1. 如何配置tomcat节点之间进行会话共享? 

  2.  

  3. 1、首先确保节点服务器均运行正常。 

  4.  

  5. 2、修改节点服务器的server.xml文件。 

  6.  在以下行增加: 

  7. <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>   #允许集群,之前因为缺少这一行,

  8. 一把下面的配置贴到tomcat中,tomcat立即不能正常工作。折腾多次,记录一下。

  9.  <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster" 

  10.                  channelSendOptions="8"> 

  11.  

  12.           <Manager className="org.apache.catalina.ha.session.DeltaManager" 

  13.                    expireSessionsOnShutdown="false" 

  14.                    notifyListenersOnReplication="true"/> 

  15.  

  16.           <Channel className="org.apache.catalina.tribes.group.GroupChannel"> 

  17.             <Membership className="org.apache.catalina.tribes.membership.McastService" 

  18.                         address="228.0.0.4" 

  19.                         port="45564" 

  20.                         frequency="500" 

  21.                         dropTime="3000"/> 

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

  23.                       address="auto" 

  24.                       port="4000" 

  25.                       autoBind="100" 

  26.                       selectorTimeout="5000" 

  27.                       maxThreads="6"/> 

  28.  

  29.             <Sender className="org.apache.catalina.tribes.transport.ReplicationTransmitter"> 

  30.               <Transport className="org.apache.catalina.tribes.transport.nio.PooledParallelSender"/> 

  31.             </Sender> 

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

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

  34.           </Channel> 

  35.  

  36.           <Valve className="org.apache.catalina.ha.tcp.ReplicationValve" 

  37.                  filter=""/> 

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

  39.  

  40.           <Deployer className="org.apache.catalina.ha.deploy.FarmWarDeployer" 

  41.                     tempDir="/tmp/war-temp/" 

  42.                     deployDir="/tmp/war-deploy/" 

  43.                     watchDir="/tmp/war-listen/" 

  44.                     watchEnabled="false"/> 

  45.  

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

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

  48.         </Cluster>    

  49.     

  50. 以上内容为群集的设置,通过组播相互交换更新session. 

  51. 完成以上,还需要增加操作: 

  52. mkdip /tmp/{war-temp,war-deploy,war-listen{ 

  53. chmod 777 -R !$ 

  54. 即可。