使用 Redis 服务器来存储Session非常有优势。首先它是一个NOSQL数据,第二它很容易扩展使用。 This kind of setup would lead to a clear understanding of how Redis can behave as cache as well as a session storing system. In order to do this the instructions are as follows :-
- Download Redis and build by the following commands (This includes downloading it too)
wget http://download.redis.io/redis-stable.tar.gz tar xvzf redis-stable.tar.gz cd redis-stable make
- Start Redis using command(Redis Directory refers to the directory where Redis is built)
cd RedisDirectory/src ./redis-server --port 6379
- Get the latest version of Apache Tomcat 7
- Download the latest version for JEDIS (A Redis Java Client), Tomcat Redis Session Manager (Redis-backed non-sticky session store for Apache Tomcat) and Apache Commons Pool .
- Copy all the above files into the lib folder of the Apache Tomcat 7 installation directory.
- Add the lines mentioned below in the context.xml of your Apache Tomcat 7 (Or on the context block of server.xml if applicable).Edit the Configurations as your settings. In out case the port number to be configured is 6279.
1
<
Valve
className
=
"com.radiadesign.catalina.session.RedisSessionHandlerValve"
/>
2
<
Manager
className
=
"com.radiadesign.catalina.session.RedisSessionManager"
3
host
=
"localhost"
<!-- optional: defaults to "localhost" -->
4
port="6379"
<!-- optional: defaults to "6379" -->
5
database="0"
<!-- optional: defaults to "0" -->
6
maxInactiveInterval="60"
<!-- optional: defaults to "60" (in seconds) -->
/>
- Now restart your Apache Tomcat 7 normally and now you would see that the sessions are being created in theRedis Rather than on Tomcat.
Thats it. Now you have your Apache Tomcat 7 storing all the sessions in Redis and it also takes care about the different aspects of sessions.
web.xml中的配置是有效的,即使是context.xml总配置maxInactiveInterval默认60秒,只要web.xml中的sessionConfig配置30分钟,则session的失效时间还是30分钟。
相关推荐
在Apache Tomcat 7设置redis作为session ...6.重启tomcat后就可以看到session存储到redis上了。 要严格注意你的jar版本 commons-pool-1.3.jar jedis-2.0.0.jar tomcat-redis-session-manager-1.2-tomcat-7-java-7.jar
tomcat-redis-session-manager-tomcat-7 Redis-backed non-sticky session store for Apache Tomcat
压缩文件包括tomcat-redis-session-manager-master-2.0.0.jar、jedis-2.7.3.jar、commons-pool2-2.3.jar三个jar包使用方法请参照https://github.com/jcoleman/tomcat-redis-session-manager。apache-tomcat-8.5.33....
redis充当tomcat7 session store需要用到的jar包 使用说明: 1、将zip解压出来的jar包放到tomcat的lib目录下. 2、修改tomcat/conf下的context.xml文件,示例如下: <!-- Default set of monitored resources --> ...
由于找了很多资料很几遍都没有实现,就整理分析下。 ,Apache+Tomca8+Redis实现session共享tomcat8依赖jar
apache-tomcat-7.0.67+nginx-1.14.0+Redis-x64-3.2.6379集群部署所需JAR包
这个包里含有commons-pool2-2.4.2、jedis-2.9.0、tomcat85-session-redis-1.0三个主要JAR包。apache-tomcat-8.5.20.tar.gz源码包和context.xml文件,这套配置是我自己亲测可用的。。另外我用的redis4这个版本。注意...
apache-tomcat-8.0.14_8081/apache-tomcat-8.0.14_8082为两个tomcat 服务器,修改目录中context.xml中redis连接地址和密码,直接可以在本地运行tomcat-->start.bat,直接访问...
tomcat集群session共享
3、将redisson-all-3.11.2.jar和redisson-tomcat-8-3.11.2.jar 拷贝到${catalina.base}\lib下 4、在原有tomcat\context.xml下 添加 以下代码(参考 <Manager className="org.redisson.tomcat....
tomcat7整合session所需的jar包,使用redis同步session信息
tomcat集群基于redis共享session使用到的所有jar包,放到tomcat的lib下即可使用 apache-tomcat-7.0.56+nginx-1.8.0+redis-3.0.6集群部署所需JAR包,session共享 tomcat-redis-session-manager1.2.jar jedis-2.6.2....
请求会话将立即存储到Redis中(会话属性必须是可序列化的),以供其他服务器使用。 当tomcat从客户端收到请求时,将直接从Redis加载会话。 支持Redis默认,哨兵和集群模式(基于配置)。 展望未来,我们无需在...
apache-tomcat-8.0.45以上版本 取消了LifecycleSupport ,而session管理器又不在维护,所有tomcat-8.0.45以上未能实现session同步
最新的apache-tomcat-8.5.42版本+最新的tomcat-cluster-redis-session-manager-2.0.4 配置了JAVA_OPTS,详见bin/catalina.sh及bin/catalina.bat文件 配置了manager账号密码,详见conf/tomcat-users.xml文件 卸载了...
支持tomcat8的redis-session-manager-master,测试环境jdk-8u191、apache-tomcat-8.0.53
本资源包含有nginx+tomcat+mysql主从+redis部署详细文档以及安装包,因开源组件tomcat-redis-session-manage-tomcat8.jar目前不支持tomcat8,本人亲自对该jar包对源码进行过修改可支持tomcat8 亲测有效,非常适合不...
包含: 1、apache-tomcat-7.0.41-windows-x64免安装 2、Redis-x64-3.2.100.msi ...3、tomcat-cluster-redis-session-manager tomcat session所需的jar包 4、getsession.jsp 和setsession.jsp 测试session设置和获取
tomcat 8.5.55 集成 tomcat-cluster-redis-session-manager 4.0
apache-tomcat-7基于redis进行session共享集群部署所需JAR包 commons-pool-1.6.jar commons-pool2-2.3.jar jedis-2.8.0.jar tomcat-juli.jar tomcat-juli-adapters.jar tomcat-redis-session-manager1.2.jar