1.环境
tomcat6.0
nginx1.4.4 安装
memcached 1.4.15 安装
2.所需的jar包
memcached-session-manager-${version}.jar
memcached-session-manager-tc6-${version}.jar(tomcat1.6)
memcached-session-manager-tc7-${version}.jar(tomcat1.7)
下边是我下载包的列表
[root@SESSION src]# ll /usr/src/tomcatlib/
总用量 3988
-rw-r--r--. 1 root root 43398 7月 7 2009 asm-3.2.jar
-rw-r--r--. 1 root root 73098 12月 25 15:05 commons-codec-1.5.jar
-rw-r--r--. 1 root root 284363 12月 25 15:05 couchbase-client-1.2.2.jar
-rw-r--r--. 1 root root 89706 7月 1 14:29 flexjson-3.1.jar
-rw-r--r--. 1 root root 181204 12月 25 15:05 httpcore-4.1.1.jar
-rw-r--r--. 1 root root 196368 12月 25 15:05 httpcore-nio-4.1.1.jar
-rw-r--r--. 1 root root 452748 4月 9 2011 javolution-5.4.3.1.jar
-rw-r--r--. 1 root root 67758 12月 25 15:04 jettison-1.1.jar
-rw-r--r--. 1 root root 94830 4月 19 2011 kryo-1.04.jar
-rw-r--r--. 1 root root 62112 12月 4 17:53 kryo-serializers-0.11.jar
-rw-r--r--. 1 root root 142281 12月 25 14:33 memcached-session-manager-1.7.0.jar
-rw-r--r--. 1 root root 100620 12月 25 14:33 memcached-session-manager-1.7.0-sources.jar
-rw-r--r--. 1 root root 10477 12月 25 14:33 memcached-session-manager-tc6-1.7.0.jar
-rw-r--r--. 1 root root 4879 4月 19 2011 minlog-1.2.jar
-rw-r--r--. 1 root root 5312 12月 20 06:47 msm-flexjson-serializer-1.7.0.jar
-rw-r--r--. 1 root root 71145 12月 20 06:46 msm-javolution-serializer-1.7.0.jar
-rw-r--r--. 1 root root 26511 12月 20 06:45 msm-kryo-serializer-1.7.0.jar
-rw-r--r--. 1 root root 5466 12月 20 06:47 msm-xstream-serializer-1.7.0.jar
-rw-r--r--. 1 root root 1126301 12月 25 15:05 netty-3.5.5.Final.jar
-rw-r--r--. 1 root root 11615 4月 19 2011 reflectasm-1.01.jar
-rw-r--r--. 1 root root 439107 11月 5 05:46 spymemcached-2.10.2.jar
-rw-r--r--. 1 root root 7188 6月 16 2003 xmlpull-1.1.3.1.jar
-rw-r--r--. 1 root root 24677 2月 18 2006 xpp3_min-1.1.3.4.O.jar
-rw-r--r--. 1 root root 513765 12月 12 12:55 xstream-1.4.6.jar
3.配置
将以上的jar包放到$TOMCAT_HOME/lib下
然后修改$TOMCAT_HOME/conf/
[root@SESSION src]# tail -9 /usr/local/tomcat8092/conf/context.xml
<Manager className="de.javakaffee.web.msm.MemcachedBackupSessionManager"
memcachedNodes="n1:localhost:11211,n2:localhost:16000" //此处用多个memcache可以防止一个memcached down掉后session丢失的问题。
sticky="false"
lockingMode="auto"
requestUriIgnorePattern=".*\.(png|gif|jpg|css|js)$"
sessionBackupAsync="true"
sessionBackupTimeout="1800"
transcoderFactoryClass="de.javakaffee.web.msm.serializer.kryo.KryoTranscoderFactory" copyCollectionsForSerialization="false" />
</Context>
nginx中负载均衡配置如下:
upstream myserver
{
server 127.0.0.1:8093 max_fails=3 fail_timeout=30s ;
server 127.0.0.1:8091 max_fails=3 fail_timeout=30s ;
}
百度上天下文章一顿乱抄,缺了很多包,最后也是在官网
http://code.google.com/p/memcached-session-manager/wiki/SetupAndConfiguration
找到了靠谱的解决方法
###############################
迷途小运维原创
转载请注明出处
作者:john