一、使用版本:apache-tomcat-7.0.56+nginx-1.8.0+redis-3.0.6
1、先给出正确的配置和jar包
所需jar包如下
tomcat-redis-session-manager1.2.jar
jedis-2.6.2.jar
tomcat-juli.jar
tomcat-juli-adapters.jar
commons-pool-1.5.4.jar
commons-pool2-2.4.1.jar
下载地址:http://download.csdn.net/detail/xiaoxiaosasasa/9403043
2、修改tomcat的配置文件conf/context.xml
单点配置
<Context>
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<ValveclassName="com.orangefunction.tomcat.redissessions.RedisSessionHandlerValve"/>
<Manager className="com.orangefunction.tomcat.redissessions.RedisSessionManager"
host="192.168.254.10"
port="6379"
database="0"
maxInactiveInterval="60"/>
</Context>
基于redis的集群配置如下:
<ValveclassName="com.orangefunction.tomcat.redissessions.RedisSessionHandlerValve"/>
<ManagerclassName="com.orangefunction.tomcat.redissessions.RedisSessionManager"
maxInactiveInterval="60"
sentinelMaster="mymaster"
sentinels="127.0.0.1:26379,127.0.0.1:26380,127.0.0.1:26381,127.0.0.1:26382"/>
二、搭建过程中遇到的问题
1、各个组件的下载地址:
Redis:http://redis.io/
JRedis: https://github.com/xetorthio/jedis
我用的是tomcat7和JDK7,
因此下载tomcat-redis-session-manager-1.2-tomcat-7-java-7.jar包
https://github.com/jcoleman/tomcat-redis-session-manager/downloads
Apache Commons Pool :