You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by David Ron <da...@bandmerch.com> on 2006/06/09 20:49:05 UTC

Database Persistance And Session Replication

Hey everybody,
     I would like to configure Tomcat for both session replication across
  > 3 servers and database session persistence.  The database persistence
lags several seconds which is why I don't think that I can simply
replicate sessions over many servers using the database.

I can get the sessions to persist to the database using
org.apache.catalina.session.PersistentManager, and I can get session to
replicate in memory using
org.apache.catalina.cluster.session.DeltaManager, but how to I use both
at the same time?


Here is server.xml with the in-memory replication that works:

--------------------
<Server port="8005" shutdown="SHUTDOWN">

   <Service name="Catalina">
     <Connector className="org.apache.coyote.tomcat5.CoyoteConnector"
         port="80" minProcessors="5" maxProcessors="75"
         enableLookups="true" address="192.168.0.250" redirectPort="443"/>

     <Engine name="Catalina" defaultHost="tomcat">
       <Host name="tomcat" appBase="webapps">

       <Cluster className="org.apache.catalina.cluster.tcp.SimpleTcpCluster"

managerClassName="org.apache.catalina.cluster.session.DeltaManager"
                  expireSessionsOnShutdown="false" debug="true"
                  useDirtyFlag="false">

             <Membership
                 className="org.apache.catalina.cluster.mcast.McastService"
                 mcastAddr="228.0.0.4"
                 mcastPort="45564"
                 mcastFrequency="500"
                 mcastDropTime="3000"/>

             <Receiver

className="org.apache.catalina.cluster.tcp.ReplicationListener"
                 tcpListenAddress="192.168.0.250"
                 tcpListenPort="4001"
                 tcpSelectorTimeout="100"
                 tcpThreadCount="6"/>

             <Sender

className="org.apache.catalina.cluster.tcp.ReplicationTransmitter"
                 replicationMode="pooled"/>

             <Valve
className="org.apache.catalina.cluster.tcp.ReplicationValve"

filter=".*\.gif;.*\.js;.*\.jpg;.*\.htm;.*\.html;.*\.txt;"/>

             <Deployer
className="org.apache.catalina.cluster.deploy.FarmWarDeployer"
                       tempDir="/tmp/war-temp/"
                       deployDir="/tmp/war-deploy/"
                       watchDir="/tmp/war-listen/"
                       watchEnabled="false"/>

     <Context path="" docBase=".">
<!--
         <Manager className="org.apache.catalina.session.PersistentManager"
              distributable="true"
              debug="10"
              checkInterval="1"
              saveOnRestart="true"
              maxActiveSessions="-1"
              minIdleSwap="-1"
              maxIdleSwap="1"
              maxIdleBackup="1">

              <Store className="org.apache.catalina.session.JDBCStore"
                  debug="100"


connectionURL="jdbc:mysql://192.168.0.253/tomcat?user=abc&amp;password=efg"
                  driverName="com.mysql.jdbc.Driver"
                  sessionDataCol="session_data"
                  sessionAppCol="app_name"
                  sessionIdCol="session_id"
                  sessionLastAccessedCol="last_access"
                  sessionMaxInactiveCol="max_inactive"
                  sessionTable="tomcat_sessions"
                  sessionValidCol="valid_session">
              </Store>
         </Manager>
-->
     </Context>

       </Cluster>
       </Host>
     </Engine>
   </Service>
</Server>
--------------------

-- 
David Ron
IT Director - BandMerch
5126 Clareton Drive #140
Agoura Hills, CA 91301
877-502-3728 x5201
David@BandMerch.com





Re: Database Persistance And Session Replication

Posted by Filip Hanik - Dev Lists <de...@hanik.com>.
unfortunately you can't do both, its either or

Filip


David Ron wrote:
> Hey everybody,
>     I would like to configure Tomcat for both session replication across
>  > 3 servers and database session persistence.  The database persistence
> lags several seconds which is why I don't think that I can simply
> replicate sessions over many servers using the database.
>
> I can get the sessions to persist to the database using
> org.apache.catalina.session.PersistentManager, and I can get session to
> replicate in memory using
> org.apache.catalina.cluster.session.DeltaManager, but how to I use both
> at the same time?
>
>
> Here is server.xml with the in-memory replication that works:
>
> --------------------
> <Server port="8005" shutdown="SHUTDOWN">
>
>   <Service name="Catalina">
>     <Connector className="org.apache.coyote.tomcat5.CoyoteConnector"
>         port="80" minProcessors="5" maxProcessors="75"
>         enableLookups="true" address="192.168.0.250" redirectPort="443"/>
>
>     <Engine name="Catalina" defaultHost="tomcat">
>       <Host name="tomcat" appBase="webapps">
>
>       <Cluster 
> className="org.apache.catalina.cluster.tcp.SimpleTcpCluster"
>
> managerClassName="org.apache.catalina.cluster.session.DeltaManager"
>                  expireSessionsOnShutdown="false" debug="true"
>                  useDirtyFlag="false">
>
>             <Membership
>                 
> className="org.apache.catalina.cluster.mcast.McastService"
>                 mcastAddr="228.0.0.4"
>                 mcastPort="45564"
>                 mcastFrequency="500"
>                 mcastDropTime="3000"/>
>
>             <Receiver
>
> className="org.apache.catalina.cluster.tcp.ReplicationListener"
>                 tcpListenAddress="192.168.0.250"
>                 tcpListenPort="4001"
>                 tcpSelectorTimeout="100"
>                 tcpThreadCount="6"/>
>
>             <Sender
>
> className="org.apache.catalina.cluster.tcp.ReplicationTransmitter"
>                 replicationMode="pooled"/>
>
>             <Valve
> className="org.apache.catalina.cluster.tcp.ReplicationValve"
>
> filter=".*\.gif;.*\.js;.*\.jpg;.*\.htm;.*\.html;.*\.txt;"/>
>
>             <Deployer
> className="org.apache.catalina.cluster.deploy.FarmWarDeployer"
>                       tempDir="/tmp/war-temp/"
>                       deployDir="/tmp/war-deploy/"
>                       watchDir="/tmp/war-listen/"
>                       watchEnabled="false"/>
>
>     <Context path="" docBase=".">
> <!--
>         <Manager 
> className="org.apache.catalina.session.PersistentManager"
>              distributable="true"
>              debug="10"
>              checkInterval="1"
>              saveOnRestart="true"
>              maxActiveSessions="-1"
>              minIdleSwap="-1"
>              maxIdleSwap="1"
>              maxIdleBackup="1">
>
>              <Store className="org.apache.catalina.session.JDBCStore"
>                  debug="100"
>
>
> connectionURL="jdbc:mysql://192.168.0.253/tomcat?user=abc&amp;password=efg" 
>
>                  driverName="com.mysql.jdbc.Driver"
>                  sessionDataCol="session_data"
>                  sessionAppCol="app_name"
>                  sessionIdCol="session_id"
>                  sessionLastAccessedCol="last_access"
>                  sessionMaxInactiveCol="max_inactive"
>                  sessionTable="tomcat_sessions"
>                  sessionValidCol="valid_session">
>              </Store>
>         </Manager>
> -->
>     </Context>
>
>       </Cluster>
>       </Host>
>     </Engine>
>   </Service>
> </Server>
> --------------------
>
> ------------------------------------------------------------------------
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> ------------------------------------------------------------------------
>
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.1.394 / Virus Database: 268.8.3/359 - Release Date: 6/8/2006
>   


-- 


Filip Hanik