Tomcat+nginx+redis Implementing session Sharing

Source: Internet
Author: User

1. The required packages are placed in the Lib directory of the Tomcat directory (attached)

2. Configure the Conf/context.xml in the Tomcat directory to include the following:

<valve classname= "Com.radiadesign.catalina.session.RedisSessionHandlerValve"/>

<manager classname= "Com.radiadesign.catalina.session.RedisSessionManager"

Host= "192.168.0.222" #redis地址

Port= "6379" #redis端口

database= "0"

Maxinactiveinterval= "/> #session失效时间

3. Configuring Nginx Cluster

http{

Upstream AAA {

192.168.0.111:8888;

192.168.0.222:8888;

}

server {

server_name aaa.test.com;

Listen 80;

Location {

Proxy_pass http://aaa;

}

Access_log/data/logs/nginx/aaa.log main;

}

}

Start Redis-nginx-tomcat in turn

Effects can be viewed in the following ways:

1. Log in to your page to view your Jsessionid,

650) this.width=650; "Src=" http://note.youdao.com/yws/public/resource/bce638f34787ea84c138ed2f1bbd9acc/ 35041457352845e48ebec9fcd6be95e7 "style=" margin-top:8px;height:86.1977px;width:800px; "alt=" 35041457352845e48ebec9fcd6be95e7 "/>

2. Log in to the REDIS-CLI console and use the following command to view session information:

127.0.0.1:6379> Get f33c92b91b64b196ef1b7ed074bfbb38
"\xac\xed\x00\x05w\b\x00\x00\x01o\xd43s\x0bsr\x00\x0ejava.lang.long ... Too much content, do not show ... \x00\x0f\x00\x00\x00\x00w\x04\x00\x00\x00\x00xxxx "

This concludes that the session information has been successfully stored in Redis.


This article is from the "Letter" blog, please be sure to keep this source http://leon0long.blog.51cto.com/3011404/1695300

Tomcat+nginx+redis Implementing 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.