Tomcat与resin集群解决session的问题

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

Tomcat与resin集群解决session的不同方法

Tomcat集群通过nginx的jvm-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>

<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 defaultHost="localhost" jvmRoute="tomcat1">        

<!-- Engine 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  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集群通过nginx的jvm-route解决配置

<web-app-default>

<session-config>

<use-persistent-store/>

<always-save-session/>

</session-config>

</web-app-default>

</cluster>

<cluster>

<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 address="127.0.0.1" port="6809">

<http port="9000"/>

</server>

<host root-directory=".">

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

</host>

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

</cluster>

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/7a6818a39713f72d9e8cdde87f9cc4b4.html