1.1     背景

     因业务需要准备在原有Tomcat部署的web项目中加入Redis 实现session共享方案。

1.2     业务流程

 Redis +Tomcat实现Session共享

 

1.3     功能改造

1)      下载tomcat-cluster-redis-session-manager

https://github.com/ran-jit/tomcat-cluster-redis-session-manager

 tomcat-cluster-redis-session-manager.rar

 

2)      添加redis-data-cache.properties

在tomcat/conf/redis-data-cache.properties文件中配置redis数据库信息

redis.hosts=10.3.8.235:6379,10.3.8.236:6379,10.3.8.237:6379

redis.password=123456

 

3)      修改context.xml

在tomcat/conf/context.xml文件中…段中增加以下两行:

<Valve className="tomcat.request.session.redis.SessionHandlerValve" />

<Manager className="tomcat.request.session.redis.SessionManager" />

 

4)      web.xml 配置 session有效期

设置tomcat/conf/web.xml 中 session有效期(默认值是30分钟)

<session-config>

     <session-timeout>60<session-timeout>

<session-config>

相关文章:

  • 2021-12-10
  • 2021-07-03
  • 2022-12-23
  • 2022-12-23
  • 2021-10-17
  • 2021-09-04
  • 2021-11-19
猜你喜欢
  • 2022-01-19
  • 2017-11-27
  • 2022-01-03
  • 2021-07-18
相关资源
相似解决方案