In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
Brief introduction
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 magent-bound VIP, and the memcached data of other nodes will also be synchronized.
Experimental environment memcached master 192.168.13.128 (magent, memcached, libevent, keeplived) memcached from 192.168.13.129 (memcached, libevent, keeplived) client client 192.168.13.130 (telnet test tool) virtual ip 192.168.13.1001, configure memcached master cache node and slave cache node (both are the same configuration There is no need to install magent) [root@master ~] # mount.cifs / / 192.168.100.3/LNMP-C7 / mnt/Password for root@//192.168.100.3/LNMP-C7: [root@master ~] # cd / mnt/memcached/ [root@master memcached] # tar zxvf memcached-1.5.6.tar.gz-C / opt/ [root@master memcached] # tar zxvf libevent-2.1.8-stable.tar.gz-C / opt/ # # event Library [root@master memcached] # mkdir / opt/magent [root@master memcached] # tar zxvf magent-0.5.tar.gz-C / opt/magent/ [root@master memcached] # yum install gcc gcc-c++ make-y [root@master memcached] # cd / opt/libevent-2.1.8-stable/ [root@master libevent-2.1.8-stable] #. / configure-- prefix=/usr/ [root@master libevent-2.1.8-stable] # cd .. / memcached-1.5.6/ [root@master memcached-1.5.6] #. / configure\ >-- with-libevent=/usr [root@master magent] # systemctl stop firewalld.service [root@master magent] # setenforce 02 Configure the primary server Install the magent agent [root@master memcached-1.5.6] # cd / opt/magent/ [root@master magent] # vim ketama.h # # modify the magent configuration file # # modify the first line to add # ifndef SSIZE_MAX#define SSIZE_MAX 32767#endif / / if there is this item, you do not need to add [root@master magent] # vim Makefile # # Edit the Makefile configuration file # # find this item and add-lmLIBS =-levent-lm [root@master magent ] # make # # generate a magent executable program [root@master magent] # yum install openssh-clients-y [root@master magent] # cp magent / usr/bin/ # # in / usr/bin [root@master magent] # scp magent root@192.168.13.129:/usr/bin/ # # copy to slave server / usr/bin 3 Configure and install keepalided [root @ master magent] # yum install keepalived-y # # install the keepalived service [root@master magent] # vim / etc/keepalived/keepalived.conf # # modify the configuration file / / define a function on the master-slave server It is recommended to write at the front (master server configuration) 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.13.100 / / well defined 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} # # the slave server is configured as follows (you can copy the master server configuration file directly to the slave server via scp) the router_id MAGENT_HB / / id name is different from the first state BACKUP / / slave server virtual_router_id 52 / / id number and the first server Different from the low priority of priority 90 / / on the main server [root@master keepalived] # mkdir / opt/shell [root@master keepalived] # cd / opt/shell/ [root@master shell] # vim magent.sh # # Edit magent script #! / bin/bashK= `ps-ef | grep keepalived | grep-v grep | wc-l`if [$K-gt 0] Then magent-u root-n 51200-l 192.168.13.100-p 12000-s 192.168.13.128 192.168.13.129:11211elsepkill 11211-b 192.168.13.129:11211elsepkill-9 magentfi//-n 51200 / / define the maximum number of user connections-l 192.168.13.100 / / specify virtual IP-p 12000 / / specify port number-s / / specify main cache Storage server-b / / specify slave cache server [root@master shell] # chmod + x magent.sh # # execute permission [root@master shell] # systemctl start keepalived.service # # enable service [root@master shell] # netstat-natp | grep 12000 # # View port # # verify master / slave server-view / var/log/messages file Find keyword: Transition to MASTER STATE from server-find keyword: Entering BACKUP STATEip addr command-make sure the drift address is effective 4 Enable master-slave server memcache master server: [root@master shell] # memcached-m 512k-u root-d-l 192.168.13.128-p 11211 [root@master shell] # netstat-natp | grep 11211 slave server: [root@slave shell] # memcached-m 512k-u root-d-l 192.168.13.129-p 11211 [root@slave shell] # netstat-ntap | grep 112115 Login with client [root@client ~] # yum install telnet-y # # install login tool [root@client ~] # telnet 192.168.13.100 12000 # log in to Trying 192.168.13.100...Connected to 192.168.13.100.Escape character is'^] '.add username 00 7 # # with virtual ip to add a data 1234567STORED6 Check whether master-slave synchronization # # check whether there is written data on the master server [root@master shell] # telnet 192.168.13.128 11211Trying 192.168.13.128...Connected to 192.168.13.128.Escape character is'^] .get usernameVALUE username 0 71234567END## to see if there is written data on the slave server [root@slave shell] # telnet 192.168.13.129 11211Trying 192.168.13.129...Connected To 192.168.13.129.Escape character is'^] '.get usernameVALUE username 0 71234567END7 Crash the main server to see if it is available. To achieve high availability, [root@master shell] # systemctl stop keepalived.service [root@client ~] # telnet 192.168.13.100 12000 # # client can still log in to Trying 192.168.13.100...Connected to 192.168.13.100.Escape character is'^]'. Thank you for reading!
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.