In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Today, the editor will share with you the relevant knowledge points about how to achieve session server session persistence through Memcached. The content is detailed and the logic is clear. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article.
Memcached is a high-performance distributed in-memory object caching system, which is used for dynamic Web applications to reduce database load. It reduces the number of times to read the database by caching data and objects in memory, thus improving the speed of dynamic, database-driven websites.
Three ways of session persistence
Session sticky session binding: unified session sending to the same backend server in the configuration of the front-end scheduler
Session cluster session clustering: keep the session information of all Tomcat consistent by configuring Tomcat.
Session server session service: all session is handed over to a dedicated session service management.
The third way is to use Memcached to do session server.
I. Architecture Diagram
System environment
All servers use CentOS7.3
Required software package
The following files should be placed in the class library directory on the tomcat server host
Rpm-ql tomcat-lib # / usr/share/java/tomcat/ # yum is installed in this directory by default / usr/local/tomcat/lib # is installed in the official website rpm by default in this directory memcached-session-manager-1.8.3.jar http://repo1.maven.org/maven2/de/javakaffee/msm/memcached-session-manager/1.8.3/ Memcached-session-manager-tc7-1.8.3.jar http://repo1.maven.org/maven2/de/javakaffee/msm/memcached-session-manager-tc7/1.8.3/spymemcached-2.11.1.jar http://repo1.maven.org/maven2/net/spy/spymemcached/2.11.1/javolution-5.4.3.1.jar http://memcached-session-manager.googlecode.com/svn/maven / javolution/javolution/5.4.3.1/msm-javolution-serializer-1.8.3.jar http://repo1.maven.org/maven2/de/javakaffee/msm/msm-javolution-serializer/1.8.3/ II. Detailed configuration of Apache
Install httpd
Yum install httpd
Create a profile
Create a new configuration file under / etc/httpd/conf.d
Shell > vim / etc/httpd/conf.d/ajp-tomcat.conf # # define host group BalancerMember ajp://172.18.68.21:8009 route=tomcatA BalancerMember ajp://172.18.68.22:8009 route=tomcatB ProxySet lbmethod=byrequests # # create virtual host ServerName www.baidu.com ProxyVia On ProxyRequests Off ProxyPreserveHost On proxyvia on Require all granted ProxyPass / balancer://tomcatservers/ # set all schedules To backend ProxyPassReverse / balancer://tomcatservers/ # set all schedules to backend # centos7 reject by default Therefore, it is necessary to allow the management page of Require all granted # apache SetHandler balancer-manager ProxyPass! # that matches to apache not to be proxied. Require all granted # set allow # shell > systemctl start httpd 3. Configuration of Tomcat
The configuration of the two tocat is more or less the same, and the configuration files are basically the same, except that the two test pages created later are different.
Install Tomcat
Yum install tomcat tomcat-admin-webapps tomcat-webapps
Modify the configuration file
There is a server.xml file under / etc/tomcat/. Open this file and add or modify the following configuration in the host tag.
Vim / etc/tomcat/server.xml configures the following content within the host tag. The yellow mark section is a streaming management tool. If you use other streaming tools, you can change these two names.
Download dependent software packages
Place the soft cloth at the end of all the .jar files mentioned at the beginning of the article in the class library directory on the tomcat server host
Rpm-ql tomcat-lib # use this command to check the directory where the .jar files are stored, which is the directory of the class library files / usr/share/java/tomcat/ # yum installed tomcat class library path / usr/local/tomcat/lib # tomcat class library path installed on the official website rpm
Add a test page
The following two test pages are different, so create them in their respective directories.
Add a test page in tomcatA
Shell > mkdir-pv / usr/local/tomcat/webapps/test/WEB-INF/ {classes,lib} shell > vim / usr/local/tomcat/webapps/test/index.jsp add the following:
Start the service
Systemctl start tomcat IV. Memcached configuration
Mechached is basically not configured, just install and start the service.
Yum install memcachedsystemctl start memcached 5. Testing
Use a browser to access http://172.18.68.11, and refresh it several times. As long as the value in the SessionID column remains the same, it means that the session has remained the same.
These are all the contents of the article "how to achieve session server session persistence through Memcached". Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.