zoukankan      html  css  js  c++  java
  • tomcat 集群配置,Session复制共享

     本配置在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>
  • 相关阅读:
    mybatis2入门程序
    mybatis1
    mybeats与jdbc问题分析
    mysqljdbc简单连接释放
    jdbc问题记录
    section,article,div
    HB调试前端开发移动
    HTML,XML,XHTML
    访问地图
    OAuth
  • 原文地址:https://www.cnblogs.com/hanxianlong/p/3456780.html
Copyright © 2011-2022 走看看