Tomcatresin集群解决session的问题

这里测试的是tomcat 6.0与resin 4.0的.

Tomcatresin集群解决session的不同方法

 

Tomcat集群通过nginxjvm-route解决配置

<?xml version='1.0' encoding='utf-8'?>

<?xml version='1.0' encoding='utf-8'?>

<Server port="8417" shutdown="SHUTDOWN">

  <!--APR library loader. Documentation at /docs/apr.html -->

  <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />

  <!--Initialize Jasper prior to webapps are loaded. Documentation at /docs/jasper-howto.html -

->

  <Listener className="org.apache.catalina.core.JasperListener" />

  <!-- JMX Support for the Tomcat server. Documentation at /docs/non-existent.html -->

  <!-- Global JNDI resources

       Documentation at /docs/jndi-resources-howto.html

  -->

  <GlobalNamingResources>

    <!-- Editable user database that can also be used by

         UserDatabaseRealm to authenticate users

    -->

  </GlobalNamingResources>

  <Service name="Catalina">

          <Connector port="8080" protocol="HTTP/1.1"

               connectionTimeout="20000"

               redirectPort="8443" />

    <!-- Define an AJP 1.3 Connector on port 8009 -->

    <Connector port="8411" protocol="AJP/1.3" redirectPort="8443" maxThreads="5000" acceptCount="700" connectionTimeout="20000" />

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

    <!-- Engine name="Catalina" defaultHost="localhost" -->

        <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="224.0.0.4"

                        port="45564"

                        frequency="500"

                        dropTime="3000"/>

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

                      address="192.168.2.248"

                      port="4000"

                      autoBind="100"

                      selectorTimeout="5000"

                      maxThreads="6"/>

            <!-- timeout="60000"-->

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

       <Host name="localhost"  appBase="webapps"

            unpackWARs="true" autoDeploy="true"

            xmlValidation="false" xmlNamespaceAware="false">

        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" 

               prefix="localhost_access_log." suffix=".txt" pattern="common" resolveHosts="false"/>

        <Context path="" docBase="/usr/local/tomcat/llq/ROOT/ "  reloadable="true"/>       

      </Host>

    </Engine>

  </Service>

</Server>

 

 

Tomcat集群把session写入到memcached配置,<Context></Context>字段添加如下(需要驱动包,google有下)

  <Context path="" docBase="/usr/local/tomcat/llq/ROOT/ "  reloadable="true">

  <Manager className="de.javakaffee.web.msm.MemcachedBackupSessionManager" 

     memcachedNodes="n1:192.168.2.245:3000" 

     requestUriIgnorePattern=".*\.(png|gif|jpg|css|js)$" 

     sessionBackupAsync="false" 

     sessionBackupTimeout="100"

transcoderFactoryClass="de.javakaffee.web.msm.serializer.javolution.JavolutionTranscoderFactory"    copyCollectionsForSerialization="false" 

     /> 

</Context>

 

 

Resin集群通过nginxjvm-route解决配置

 <web-app-default>

      <session-config>

      <use-persistent-store/>

      <always-save-session/>

    </session-config>

   </web-app-default>

 

  </cluster>

 <cluster id="cshop">

    <server-default>

      <jvm-arg>-Xms256m</jvm-arg>

      <jvm-arg>-Xmx256m</jvm-arg>

      <jvm-arg>-Xss96m</jvm-arg>

   </server-default>

        <resin:import path="${resin.home}/conf/app-default.xml"/>

    <server id="cshop" address="127.0.0.1" port="6809">

        <http id="" port="9000"/>

    </server>

    <host id="" root-directory=".">

           <web-app id="/" root-directory="/usr/local/wwwweb " />

    </host>

  <character-encoding>UTF-8</character-encoding>

 </cluster>

 

 

resin集群把session写入到memcached配置通过网上找了个别人分享的模块( memsession.rar),但测试没成功,不知道那位博友有更好的方法,分享下.