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可以修改为其它名字   

你可能感兴趣的:(jvm,tomcat,Web,session,filter,IE)