For the previous Nginx+tomcat load-balancing mechanism, because there will be session loss, special research on the next Redis session sharing; (if you want to build this environment can start from the previous, involving the nginx of the environment to build http:// blog.csdn.net/qq584852076/article/details/46469141)
Download JDK7, TOMCAT7 for follow-up test;
First, download the source of tomcat-redis-session Packaging: Https://github.com/jcoleman/tomcat-redis-session-manager
Here's a special record for tomcat-redis-session packaging:
Because our environment is based on the 7 series to run, we must maintain consistency;
Second, download Redis install and run Http://redis.io/download
Download and enter the redis-windows-master\src\msopentech\redis-64.2.8.17 directory
Execute Redis-server.exe redis.windows.conf in cmd as shown
Third, pack and generate Tomcat-redis-session.jar package, download Jedis-2.7.2.jar Commons-pool2-2.4.1.jar from the Internet, put the 3 packets into the Tomcat\lib directory;
Iv. Configure the Context.xml files under tomcat\conf[HTML] View plain copy <?xml version= ' 1.0 ' encoding= ' utf-8 '?> ' <Context> <WatchedResource>WEB-INF/web.xml</WatchedResource> <!-- tomcat-redis-session shared configuration --> <valve classname= " Com.orangefunction.tomcat.redissessions.RedisSessionHandlerValve " /> <manager classname= " Com.orangefunction.tomcat.redissessions.RedisSessionManager " host= "localhost" port = "6379" database= "0" maxinactiveinterval= " /> <!-"---------------------------- --> </Context>
Five, multiple tomcat configuration is consistent, so the configuration is copy to the corresponding other tomcat; If you test on one machine, remember to modify the ports of each tomcat; The personal deployment environment is as follows:
Testing the entire environment: (need to place a simple Web project in Tomcat in advance)
Start Redis
Start Nginx
Start 3 Tomcat
Access: http://localhost/non-stop F5 Refresh the page to find the SessionID of the page is unchanged; turn off a tomcat and continue to f5,sessionid unchanged, indicating the success of the environment; Place the configuration files that need to be used in the personal repository and the associated jar packs. Redis server and other resources;