Redis+nginx+tomcat Implementing session Sharing

Source: Internet
Author: User
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.

  • 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.