Tomcat Redis Nginx for session sharing

Source: Internet
Author: User

Redis Tomcat Nginx for session sharing

redis3.1 TOMCAT7 Nginx 1.8.1

Jar Package Jedis-2.7.2.jar Tomcat-redis-session-manage-tomcat7.jar Commons-pool2-2.4.2.jar

Redis installed in Fedora

First, the redis Settings master-slave server http://blog.csdn.net/qq_27966627/article/details/51249774

Ports are 6379 6380 , respectively.

Second, install and configure Nginx

1. Installing nginx http://blog.csdn.net/qq_27966627/article/details/51141860

2. Locate the Nginx configuration file nginx.conf and then Add the http.

Upstream Tomcat {

Server localhost:8080;

Server localhost:8081;

}

Localhost is the computer IP where Tomcat resides

8080 Port number

3. check that the nginx configuration file is correct

#nginx-T

4. Restart nginx

#nginx-S-reload

Third, configure Tomcat

1. Extract two tomcatand place the required jar Pack into Tomcat Lib

2. Modify one of the Tomcat ports, edit the servicex.xml file, modify the port

I.

Ii.

Iii.

3. Modification of two tomcat context.xml files

<valve classname= "Com.orangefunction.tomcat.redissessions.RedisSessionHandlerValve"/>

<manager classname= "Com.orangefunction.tomcat.redissessions.RedisSessionManager"

Host= "192.168.139.128"

Port= "6379"

database= "0"

Maxinactiveinterval= "/>"

a). Add the code and file as above, Host to be Redis where IP

Iv. Edit Web page run

A

A) Add the following code to the webpage

<%

String Values=request.getparameter ("values");

HttpSession sessions=request.getsession ();

Session.setattribute ("values1", values);

Object Sessionvalues=sessions.getattribute ("values1");

//

%>

Remove value from session whooooooooo:<%=sessions.getid ()%>

C). Run, get SessionID

D). Check whether the database is plugged in, insert completed successfully

Tomcat Redis Nginx for 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.