Memcached+Tomcat7

发布于 2015-09-25 / Java / 0条评论 / 553浏览

作者教程
https://code.google.com/p/memcached-session-manager/wiki/SetupAndConfiguration#Introduction
看到google你们就醉了吧,没关系,我把原文截图了(打开截图

准备工作
1、在官网下载apache-tomcat-xxx.zip解压复制两个tomcat 将其中的一个端口改成9090,分别在webapps/ROOT下创建/session/index.jsp并添加

<%= session.getId() %>

并保存

2、启动后访问
http://wordpress.denghb.com:8080/session/
http://wordpress.denghb.com:9090/session/
页面都会出现32位字符串,但是不一样

tomcat集成memcached session manager
1、创建一个空的maven web项目在pom里面添加

<dependency> <groupId>de.javakaffee.msm</groupId> <artifactId>memcached-session-manager-tc7</artifactId> <version>1.9.0-RC1</version> </dependency> <dependency> <groupId>de.javakaffee.msm</groupId> <artifactId>msm-kryo-serializer</artifactId> <version>1.8.0</version> <scope>runtime</scope> </dependency>

2、mvn install获取编译好的war解压找到WEB-INF/lib下

 annotations-1.3.9.jar
 asm-3.2.jar
 commons-codec-1.5.jar
 couchbase-client-1.4.0.jar
 httpcore-4.3.jar
 httpcore-nio-4.3.jar
 jettison-1.1.jar
 jsr305-1.3.9.jar
 kryo-1.04.jar
 kryo-serializers-0.11.jar
 memcached-session-manager-1.9.0-RC1.jar
 memcached-session-manager-tc7-1.9.0-RC1.jar
 minlog-1.2.jar
 msm-kryo-serializer-1.8.0.jar
 netty-3.5.5.Final.jar
 reflectasm-1.01.jar
 spymemcached-2.11.1.jar
 stax-api-1.0.1.jar

3、copy这18个jar到两个tomcat/lib下
4、分别在tomcat/conf/context.xml的<Context>添加

<Manager className="de.javakaffee.web.msm.MemcachedBackupSessionManager" memcachedNodes="n1:localhost:11211" requestUriIgnorePattern=".*\.(ico|png|gif|jpg|css|js)$" sessionBackupAsync="false" sessionBackupTimeout="1800000" copyCollectionsForSerialization="false" transcoderFactoryClass="de.javakaffee.web.msm.serializer.kryo.KryoTranscoderFactory"/>

5、重启两个tomcat就O了

中秋快乐

评论
站长统计