安装tomcat,jdk,memcache等步骤省略。下面说说tomcat服务中配置memcache的session共享
首先下载tomcat支撑memcache的jar包
具体包名为kryo-1.04.jar memcached-session-manager-tc6-1.5.1.jar kryo-serializers-0.9.jar minlog-1.2.jar memcached-2.5.jar msm-kryo-serializer-1.5.1.jar memcached-session-manager-1.5.1.jar reflectasm-1.01.jar
并把这些jar包放到tomcat的lib目录下/usr/local/tomcat/lib
修改tomcat的context.xml配置文件
在<Context>下添加配置
<Manager className="de.javakaffee.web.msm.MemcachedBackupSessionManager"
memcachedNodes="n1:172.17.11.242:11211,n2:172.17.11.243:11211"
sticky="false"
sessionBackupAsync="false"
lockingMode="all"
requestUriIgnorePattern=".*\.(ico|png|gif|jpg|css|js)$"
transcoderFactoryClass="de.javakaffee.web.msm.serializer.kryo.KryoTranscoderFactory"
/>
前提是memcache要配置正确使用,重启tomcat即可