In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
I. Preface
Magent is an open source proxy service software, through which we can synchronize cached data. Of course, synchronization here does not mean that memcached can communicate with each other, while magent can connect multiple memcached nodes at the same time, log in to memcached and write data from the client through VIP bound by magent, and the memcached data of other nodes will also be synchronized.
II. Architectural deployment
Environment description:
1. Configure memcache master cache node and slave cache node (the two servers have the same configuration)
Yum install gcc gcc-c++ make-Y1, tar zxvf memcached-1.5.6.tar.gz-C / opt/2, tar zxvf libevent-2.1.8-stable.tar.gz-C / opt/3, mkdir / opt/magenttar zxvf magent-0.5.tar.gz-C / opt/magent/
2. Compile and install
Cd / opt/libevent-2.1.8-stable./configure-prefix=/usr/make & & make installcd / opt/memcached-1.5.6./configure\-with-libevent=/usrmake & & make install
3. Create a soft connection
Ln-s / usr/lib/libevent-2.1.so.6 / usr/lib64/libevent-2.1.so.6
4. Deploy master server-install magent agent, slave server is not required
Cd / opt/magent
Vim ketama.h adds or subtracts the following code at the beginning: # ifndef SSIZE_MAX#define SSIZE_MAX 32767#endif
Vim MakefileLIBS =-levent-lm / / plus-lm
5. Make compilation after modification
6. At this point, after the make is completed, the magent executable program will be generated.
7. Copy the magent program to the path environment variable
Cp magent / usr/bin/
8. You can copy the installed magent to the slave server, so that the slave server does not need to be configured.
Yum install openssh-clients-y / / installation kit scp magent root@192.168.220.135:/usr/bin/
9. Install keepalived on both master and slave servers and deploy
(1) Master server
Yum install keepalived-y / / install keepalived
Modify the configuration file:
Vim / etc/keepalived/keepalived.conf// defines a function It is recommended to write in front of vrrp_script magent {script "/ opt/shell/magent.sh" interval 2} to make the following modifications: router_id MAGENT_HA / / modify id name interface ens33 / / modify network card information virtual_ipaddress {192.168.220.100 / / define the virtual ip address} vrrp_instance VI_1 {. / / call the function. The following three lines of code are written in the vrrp module track_script {magent}.}
(2) from the server
Vim / etc/keepalived/keepalived.conf is modified as follows: router_id MAGENT_HB / / id name is different from the first state BACKUP / / slave server virtual_router_id 52 / / id number is different from the first priority 90 / / priority is lower than the master server.
10. Configure master and slave server scripts
(1) create a script
Mkdir / opt/shell
(2) compiling
Vim magent.shrunken binapash Bash K = `ps-ef | grep keepalived | grep-v grep | wc-l`if [$K-gt 0] Then magent-u root-n 51200-l 192.168.220.100-p 12000-s 192.168.220.137192.168.220.135:11211elsepkill 11211-b 192.168.220.135:11211elsepkill-9 magentfi//-n 51200 / define the maximum number of user connections-l 192.168.220.100 / / specify virtual IP-p 12000 / / specify port number-s / / specify main cache service Server-b / / specifies that from the cache server
(3) add an execution permission to the script
Chmod + x magent.shsystemctl stop firewalld.service / / must be closed or magent will not start setenforce 0
(4) enable keepalived service
Systemctl start keepalived.servicenetstat-anpt | grep 12000 / / confirm that magent is running and the port is running normally
(5) verify the master and slave:
1. Master server-check the / var/log/messages file and find the keyword: Transition to MASTER STATE
2. From the server-find the key words: Entering BACKUP STATE
(6) ip addr command-make sure the drift address is valid
Step 5: start the master and slave servers
(1) start the master server:
Memcached-m 512k-u root-d-l 192.168.220.137-p 11211
(2) start the slave server:
Memcached-m 512k-u root-d-l 192.168.220.135-p 11211netstat-anptu | grep 11211
Step 6: client test
Install the Telnet tool first:
Yum install telnet-y
Test:
1. Log in to the connection using the drift address:
2. We operate on the client, write a data, and observe whether it will be generated synchronously on the master and slave servers:
(1) Master server:
(2) from the server:
3. Dual-computer hot backup:
(1) stop the master server:
Systemctl stop keepalived.service
(2) the client can still connect:
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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.