tomcat集群-基于redis的session共享
来源:互联网 发布:c语言编程工具哪个好 编辑:程序博客网 时间:2024/05/16 01:33
1.环境依赖:tomcat7,jdk7
2.下载所需jar
commons-pool2-2.2.jar、jedis-2.6.1.jar、tomcat-redis-session-manager1.2.jar
下载地址:http://download.csdn.net/download/feifuzeng/10106249
把这三个jar添加到tomcat目录中的lib文件夹下
3.在tomcat的context.xml 配置里添加信息
①只有一个redis时:
<!-- 基于缓存数据库的Session共享配置开始 -->
<Valve className="com.orangefunction.tomcat.redissessions.RedisSessionHandlerValve" />
<Manager className="com.orangefunction.tomcat.redissessions.RedisSessionManager"
host="192.168.16.135"
port="6380"
database="0"
maxInactiveInterval="1800"/>
<!-- 基于缓存数据库的Session共享配置结束 -->
②多个redis时:
<!-- 基于缓存数据库的Session共享配置开始 -->
<Valve className="com.orangefunction.tomcat.redissessions.RedisSessionHandlerValve" />
<Manager className="com.orangefunction.tomcat.redissessions.RedisSessionManager"
database="1"
maxInactiveInterval="1800"
sentinelMaster="username"
password="password"
sentinels="172.10.2.11:26379,172.10.2.2:26379,172.10.2.3:26379"/>
<!-- 基于缓存数据库的Session共享配置结束 -->
4.关于maxInactiveInterval,即失效时间,这里做一些说明:
即使在这里配置的maxInactiveInterval是1800s,如果web.xml配置了session的失效时间,则以web.xml为准。
另,如果有一下三处配置了Session的失效时间,则下面的配置覆盖上面的配置:
TOMCAT_HOME/conf/web.xml
WebApplication/webapp/WEB-INF/web.xml
写在代码中的值 : HttpSession.setMaxInactiveInterval(int)
即实际生效顺序是:
HttpSession.setMaxInactiveInterval(int) > $WebApplication/webapp/WEB-INF/web.xml > $TOMCAT_HOME/conf/web.xml
5.启动Tomcat,访问应用,即可在Redis中看到效果。
参考:
http://blog.csdn.net/xuxile/article/details/52994534
https://yq.aliyun.com/articles/1298
2017.11.21记:更详细的基于redis的session共享博客:http://blog.csdn.net/xlgen157387/article/details/52024139
阅读全文
0 0
- 基于Redis的Tomcat集群Session共享
- tomcat集群-基于redis的session共享
- tomcat集群-基于redis的session共享
- tomcat集群基于redis共享session解决方案
- nginx+tomcat+redis的集群+session共享
- Tomcat集群--基于Memcached的Session共享
- 基于Memcached的tomcat集群session共享
- 用Redis存储Tomcat集群的Session实现session共享
- linux下实现redis共享session的tomcat集群
- Nginx + Tomcat + Redis 集群下的Session共享
- Centos6.5下ngnix+tomcat+redis的集群+session共享
- 使用redis进行基于shiro的session集群共享
- 使用redis进行基于shiro的session集群共享
- 使用redis进行基于shiro的session集群共享
- 基于redis sentinel 的tomcat7 集群 session 共享
- apache+tomcat集群session共享-redis服务器
- linux-tomcat-session共享-redis集群
- Nginx+Tomcat+Redis搭建共享SESSION集群
- 2017-2018 ACM-ICPC, NEERC, Southern Subregional Contest
- Centos6.8安装Mysql5.6
- c++中friend function
- Python logging模块
- 无行不至远方,无思不及深邃
- tomcat集群-基于redis的session共享
- Unity 游戏框架搭建 (一) 概述
- Course 4-Convolutional Neural Networks--Week 3
- php 反射
- Unity 游戏框架搭建 (二) 单例的模板
- 如何用好 github 中的 watch、star、fork
- php文件里面引用代码段,代码段里也能进行变量传递
- Android 多渠道打包 用3步来实现
- R