Tomcat memcached-session-manager

来源:互联网 发布:28岁程序员 压力大 编辑:程序博客网 时间:2024/04/30 23:00

项目地址

https://code.google.com/archive/p/memcached-session-manager/

Sticky Session, Non Sticky Session解释:

tomcat high-availability solution that additionally stores sessions in a memcached compatible key-value store for session failover, while reading them from local memory for optimal performance (for sticky sessions). For non-sticky sessions the memcached compatible backend is used as session store (keeping a copy of the session in a secondary memcached node). "memcached compatible" here refers to the memcached protocol, therefore the backend can be any (if you like persistent) solution "speaking" memcached (e.g. memcachedbmembaseetc.).

大概意思就是,Sticky Session粘性session,每次request会先从local tomcat jvm获取session,如果没有此session会从memcached同步(通过sessionid),response之后也会同步回去到memcached;Non Sticky Session非粘性session,统一session管理到memcached,所有的tomcat直接从memcached获取session。

配置步骤:

https://code.google.com/archive/p/memcached-session-manager/wikis/SetupAndConfiguration.wiki


1 拷贝jar包到lib

memcached-session-manager-2.1.1.jar

memcached-session-manager-tc7-2.1.1.jar

spymemcached-2.11.1.jar

javolution-5.4.3.1.jar

msm-javolution-serializer-2.1.1.jar

2 配置context.xml --non-sticky session配置方法:

        <Manager className="de.javakaffee.web.msm.MemcachedBackupSessionManager" 
                memcachedNodes="n1:127.0.0.1:11211"
                sticky="false"
                sessionBackupAsync="false"
                lockingMode="auto"
                requestUriIgnorePattern=".*\.(ico|png|gif|jpg|css|js)$" 
                transcoderFactoryClass="de.javakaffee.web.msm.serializer.javolution.JavolutionTranscoderFactory"
        />

3 安装memcached

yum -y install memcached

4 启动tomcat,验证是否生效


0 0