tomcat 使用memcache 实现 session共享web server
tomcat 使用memcache 实现 session共享web server
jar 包:
1.memcached-session-manager-1.3.6.jar
2.memcached-2.5.jar.jar
3.msm-javolution-serializer-1.3.6.jar
4.javolution-5.4.3.1.jar
5.msm-javolution-serializer-cglib-1.3.0.jar
6.msm-javolution-serializer-jodatime-1.3.0.jar
放到 %TOMCAT_HOME%/lib/中
然后 修改 %TOMCAT_HOME%/conf/server.xml
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
<!--docBase 是web项目物理路径 path 为虚拟目录-->
<Context docBase="/sessiontest" path="/sessiontest" reloadable="true" >
<Manager className="de.javakaffee.web.msm.MemcachedBackupSessionManager"
memcachedNodes="n1:localhost:11211"
requestUriIgnorePattern=".*\.(png|gif|jpg|css|js)$"
sessionBackupAsync="false"
sessionBackupTimeout="100"
transcoderFactoryClass="de.javakaffee.web.msm.serializer.javolution.JavolutionTranscoderFactory"
/>
</Context>
</Host>
这样就可以实现 tomcat集群间进行 session 共享