Resources download
- Tomcat-redis-session-manager:https://github.com/jcoleman/tomcat-redis-session-manager/downloads
- Build Jdk7 + mysql5.5 + tomcat7 + nginx environment under centos-6.5-64 position
- To build Nginx + tomcat cluster, please refer to "Tomcat cluster and session sharing + Nginx load"
- For Redis build, please refer to "Centos6.5 installation redis3.0.7"
- This underground load: Jedis-2.2.1.jar+commons-pool-1.6.jar+tomcat-redis-session-manager-1.2-tomcat-7.jar
Realize
- Restore the Conf/server.xml configuration under two Tomcat, especially in the following nodes, without adding jvmroute.
<Enginename="Catalina"defaultHost="localhost">?
Adding Jvmroute will cause Redis content to take up too much, and jvmroute will be recycled into redis, resulting in full memory. Such as:
- Modify two Tomcat configuration files Conf/context.xml
<ValveclassName="com.radiadesign.catalina.session.RedisSessionHandlerValve" /><ManagerclassName="com.radiadesign.catalina.session.RedisSessionManager"host="192.168.25.132"port="6379"database="0"maxInactiveInterval="60" />
The above approach is that the entire tomcat is using Redis to save the session, and we can also use the Conf\catalina\localhost to add an XML startup project, when the project is a separate redis, If you add a root.xml, the code is as follows:
<Contextpath="/"docBase="F:\learn\tomcat\ewebsite"debug="0"privileged="true"><ValveclassName="com.radiadesign.catalina.session.RedisSessionHandlerValve" /><ManagerclassName="com.radiadesign.catalina.session.RedisSessionManager"host="192.168.25.132"port="6379"database="0"maxInactiveInterval="60" />
Context>
- Add the corresponding jar under the lib of Tomcat
Test
Test method Please refer to "Tomcat cluster and session sharing + Nginx load"
Also view keys in Redis, save Sessoionid, flushdb to erase Redis data, Sessoionid will change
'). addclass (' pre-numbering '). Hide (); $ (this). addclass (' has-numbering '). Parent (). append ($numbering); for (i = 1; i <= lines; i++) {$numbering. Append ($ ('
'). Text (i)); }; $numbering. FadeIn (1700); }); });
The above describes the Redis+nginx+tomcat implementation session sharing, including the aspects of the content, I hope that the PHP tutorial interested in a friend helpful.