Nginx+redis+tomcat Implementing session Sharing

Source: Internet
Author: User

This test uses TOMCAT7, and the JDK must use the 1.7 version if you use TOMCAT7.

Using the component version nginx:1.8.0 tomcat two: 7.0.67 redis:2.4.10 jdk:1.7.0_79

(1) Place all of the following dependent jar packages in $tomcat_home/lib:

Jedis-2.2.1.jar

Tomcat-redis-session-manager-1.2-tomcat-7.jar

Commons-pool-1.6.jar

2 ) Two tomcat configured Conf/context.xml, respectively, added:

<valveclassname= "Com.radiadesign.catalina.session.RedisSessionHandlerValve"/>

<managerclassname= "Com.radiadesign.catalina.session.RedisSessionManager"

host= "localhost"

Port= "6379"

database= "0"

Maxinactiveinterval= "/>"

Nginx is configured as follows:

#user nobody;

Worker_processes 1;

#error_log Logs/error.log;

#error_log Logs/error.log Notice;

#error_log Logs/error.log Info;

#pid Logs/nginx.pid;

Events {

Worker_connections 1024;

}

HTTP {

Upstream cluster_redis{

server10.20.9.175:8080;

server10.20.9.176:8080;

}

Include Mime.types;

Default_type Application/octet-stream;

#log_format Main ' $remote _addr-$remote _user [$time _local] "$request" '

# ' $status $body _bytes_sent ' $http _referer '

# ' "$http _user_agent" "$http _x_forwarded_for" ';

#access_log Logs/access.log Main;

Then test the Nginx,tomcat,redis after it's started.

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M01/78/09/wKiom1Zz7haAMmMDAAJe6N2mO0c184.png "title=" 1.png " Width= "height=" 625 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width:700px;height:625px; "alt=" Wkiom1zz7haammmdaaje6n2mo0c184.png "/>

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M01/78/09/wKiom1Zz7jHy5AiVAAJjKW6wV2w468.png "title=" 2.png " Width= "height=" 636 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width:700px;height:636px; "alt=" Wkiom1zz7jhy5aivaajjkw6wv2w468.png "/>

Resources:

http://dinguangx.iteye.com/blog/2230980

Http://xstarcd.github.io/wiki/Java/tomcat_cluster.html

Http://www.cnblogs.com/lengfo/p/4260363.html


Nginx+redis+tomcat 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.