tomcat session复制(转)

1.修改conf/server.xml文件,把cluster部份注释去掉,修改tcpListenAddress和tcpListenPort参数。 如果有多网卡或虚拟网卡,增加下面参数mcastBindAddress="127.0.0.1" 具体配置如下:
        <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"
                mcastBindAddress="127.0.0.1"  # 多网卡或虚拟网卡 
                mcastAddr="228.0.0.4"
                mcastPort="45564"
                mcastFrequency="500"
                mcastDropTime="3000"/>
            <Receiver 
                className="org.apache.catalina.cluster.tcp.ReplicationListener"
                tcpListenAddress="192.168.1.55"  # 配置IP地址
                tcpListenPort="4001"             #配置端口,不能与其它tomcat的server.xml端口相同
                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=".*/.gif;.*/.js;.*/.jpg;.*/.png;.*/.htm;.*/.html;.*/.css;.*/.txt;"/>
                   
            <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>
2. 修改conf/web.xml文件,添加 distributable 属性,表示Tomcat要为此web应用复制 Session。在web.xml文件最后加上distributable,具体配置如下:
    <welcome-file-list>
        <welcome-file>index.html</welcome-file>
        <welcome-file>index.htm</welcome-file>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>
<distributable/>  #新加 的distributable属性 
</web-app>
3.去悼conf/server.xml文件里的注 释,这一步在实际应用中可以不用配置.
    <!-- You should set jvmRoute to support load-balancing via AJP ie :
    <Engine name="Standalone" defaultHost="localhost" jvmRoute="jvm1">         
    --> 
    修 改为
    <!-- You should set jvmRoute to support load-balancing via AJP ie :--> 

    < Engine name = "Standalone" defaultHost = "localhost" jvmRoute = "jvm1" / > # jvm1可以修改为其它名字    

转自:http://blog.csdn.net/liuzhenwen/article/details/5335712

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值