首页 > 代码库 > tomcat7和redis的sessoin共享问题处理

tomcat7和redis的sessoin共享问题处理

1,安装redis并配置和启动, tomcat也做相就的下载,其他地方都有,可以在其他地方查阅。
2,  获取tomcat依赖包:
             Tomcat使用 从https://github.com/xetorthio/jedis/downloads下载jedis作为java的redis客户端,
              从https://github.com/jcoleman/tomcat-redis-session-manager/downloads下载tomcat的redis session manager插件
          从http://commons.apache.org/proper/commons-pool/download_pool.cgi下载apache的common pool2包,2.2,将这几个jar包拷贝到tomcat7的lib目录下
         包有: redis2.8、jedis.jar、common-pool2.2.jar、tomcat-redis-session-manager-1.2-tomcat-7.jar
3 配置tomcat
           在https://github.com/jcoleman/tomcat-redis-session-manager 这里面文章看到的配置为:
          <Valve className="com.orangefunction.tomcat.redissessions.RedisSessionHandlerValve" />
         <Manager className="com.orangefunction.tomcat.redissessions.RedisSessionManager"
         host="localhost" <!-- optional: defaults to "localhost" -->
         port="6379" <!-- optional: defaults to "6379" -->
         database="0" <!-- optional: defaults to "0" -->
         maxInactiveInterval="60" <!-- optional: defaults to "60" (in seconds) -->
         sessionPersistPolicies="PERSIST_POLICY_1,PERSIST_POLICY_2,.." <!-- optional -->
         sentinelMaster="SentinelMasterName" <!-- optional -->
         sentinels="sentinel-host-1:port,sentinel-host-2:port,.." <!-- optional --> />
            而下载的包tomcat-redis-session-manager-1.2-tomcat-7-java-7.jar或tomcat-redis-session-manager-1.2-tomcat-7.jar
        里面并没有类:com.orangefunction.tomcat.redissessions.RedisSessionHandlerValve
     所以从https://github.com/jcoleman/tomcat-redis-session-manager直接下载源码:
     发现源码里面存在相应的类,同时源码(tomcat-redis-session-manager)依赖了tomcat其他的包:tomcat-juli.jar
     而tomcat默认是没有这些包的,从http://mirrors.cnnic.cn/apache/tomcat/tomcat-7/v7.0.57/bin/extras/ 下载tomcat-juli-adapters.jar和tomcat-juli.jar两个包,放在apache-tomcat-7.0.57\lib目录下。
     同时将编译tomcat-redis-session-manager的源码,通过相应的依赖包common-pool2.2,jedis以及tomcat-juli.jar编译,并打成自己的jar包,我已经上传在:
    http://download.csdn.net/detail/qinxcb/8279761
   然后将这个依赖包放在apache-tomcat-7.0.57\lib目录下,删除网上下载的tomcat-redis-session-manager-1.2-tomcat-7.jar.

tomcat7和redis的sessoin共享问题处理