Tomcat-session-redis Configuration
Session persistence mechanism Three methods of implementation:
1. Session binding: Always direct requests from the same source IP to the same RS; no fault tolerance; lossy equalization effect (SH)
2. Session copy: Sync session between RS, each RS has all the sessions in the cluster; it is not applicable to scale clusters; must RS support (LBLCR)
3. Session server: Use a separate server to manage the session in the cluster; (single point of failure only)
Nginx-tomcat-redis (session sharing) Configuration Instance :
Environment: Two machines:
10.15.51.141:tomcata
10.15.51.222:TOMCATB, Nginx, Redis
Steps:
1. The required packages are placed in the Lib directory of the Tomcat directory (attached)
Commons-pool-1.6.jar
Jedis-2.1.0.jar
Tomcat-redis-session-manager-1.2-tomcat-7.jar
2. Configure the Conf/context.xml in the Tomcat directory to include the following:
<valve classname= "Com.radiadesign.catalina.session.RedisSessionHandlerValve"/> <manager classname= "COM.R Adiadesign.catalina.session.RedisSessionManager "host=" 10.15.51.222 "#redis地址 port=" 63 "#redis端口 database=" 0 "maxinactiveinterval="/> #session失效时间 (sec)
3. Nginx Configuration:
http{upstream AAA {server 10.15.51.222:8080; Server 10.15.51.141:8080; }server {server_name aaa.test.com; Listen 80; Location {Access_log logs/ning_access.txt; Proxy_pass http://aaa; } }}
4. Add the following to the two tomcat to facilitate testing
A provides testing:
# mkdir -pv test/web-inf/{classes,lib}# vim test/index.jsp<%@ page Language= "Java" %> B provides testing:
# mkdir -pv test/web-inf/{classes,lib}# vim test/index.jsp<%@ page Language= "Java" %>
Access:
Http://IP:80/test or Http://IP/test
This article is from the "struggling People" blog, please be sure to keep this source http://wodemeng.blog.51cto.com/1384120/1696958
Tomcat-session-redis configuration (Session sharing)