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