安装配置:
在/usr/share/tomcat7/webapps/manager目录创建indx.jsp测试文件:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>获取session id</title>
</head>
<body>
Session Id : <%= request.getSession().getId() %>
</body>
</html>
拷贝tomcat需要的jar
将如下几个jar拷贝到${TOMCAT_HOME}/lib下
tomcat-redis-session-manager-VERSION.jar jedis-2.5.2.jar commons-pool2-2.2.jar
备注: jar已经上传到百度网盘
配置tomcat
编辑${TOMCAT_HOME}/conf/context.xml,在context中加入
集群设置:
<Valve className="com.orangefunction.tomcat.redissessions.RedisSessionHandlerValve" />
<Manager className="com.orangefunction.tomcat.redissessions.RedisSessionManager"
maxInactiveInterval="60"
password="Chin@1314"
sentinelMaster="mymaster"
sentinels="x.x.x.137:26379,x.x.x.136:26379" />
单点设置:
<Valve className="com.orangefunction.tomcat.redissessions.RedisSessionHandlerValve" />
<Manager className="com.orangefunction.tomcat.redissessions.RedisSessionManager"
host="x.x.x.137"
port="6379"
password="Chin@1314"
database="0"
maxInactiveInterval="60" />
测试