使用 Redis 来存储 Apache Tomcat 7 的 Session
来源:互联网 发布:新闻类app数据 编辑:程序博客网 时间:2024/05/18 02:51
使用 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.gztar xvzf redis-stable.tar.gzcd redis-stablemake
- 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.<Valve className="com.radiadesign.catalina.session.RedisSessionHandlerValve" />
<Manager className="com.radiadesign.catalina.session.RedisSessionManager"
host="192.168.1.45"
port="6379"
password="password"
database="1"
maxInactiveInterval="60"/> - 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分钟。
注意:需要增加 tomcat-redis-session-manager-1.2-tomcat-7.jar 和 jedis-2.2.1.jar、commons-pool-1.6.jar 这三个个jar
英文原文:http://shivganesh.com/category/database/no-sql/redis-no-sql/
0 0
- 使用 Redis 来存储 Apache Tomcat 7 的 Session
- 使用 Redis 来存储 Apache Tomcat 7 的 Session
- Tomcat集群之使用Redis来存储集群Session
- Tomcat 使用Redis存储Session
- 使用Redis存储Nginx+Tomcat负载均衡集群的Session
- 使用Redis存储Nginx+Tomcat负载均衡集群的Session
- 使用Redis存储Nginx Tomcat负载均衡集群的Session
- 使用Redis存储Nginx+Tomcat负载均衡集群的Session
- 使用Redis存储Nginx+Tomcat负载均衡集群的Session
- 使用Redis存储Nginx+Tomcat负载均衡集群的Session
- 使用Redis存储Nginx+Tomcat负载均衡集群的Session
- 使用Redis存储Nginx+Tomcat负载均衡集群的Session
- 使用Redis存储Nginx+Tomcat负载均衡集群的Session
- 使用Redis存储Nginx+Tomcat负载均衡集群的Session
- 使用Redis存储Nginx+Tomcat负载均衡集群的Session
- 使用Redis存储Nginx+Tomcat负载均衡集群的Session
- 使用Redis存储Nginx+Tomcat负载均衡集群的Session
- 使用Redis存储Nginx+Tomcat负载均衡集群的Session
- coco2dx 3.0 EventDispatcher事件派发
- java图像处理
- SWT/JFACE 在Tableviewer中只在表头上右击显示上下文菜单
- 《走出软件作坊》读书心得1
- Java--三大特性体验
- 使用 Redis 来存储 Apache Tomcat 7 的 Session
- cocos2dx读书笔记之CCLOG打印%百分号
- spark的安装过程记录
- 组包的code
- ios8 iphone5s,6 touchid指纹登录
- Android 智能问答机器人的实现
- java字符串的引用
- Hadoop,HBase添加和删除节点
- android 4.4.3上面,联系人的头像默认显示首字母,但是不支持中文字符,修改支持中文