Tomcat-session-redis configuration (Session sharing)

Source: Internet
Author: User

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)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.