In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
A brief introduction to the implementation of master-slave synchronization + keepalived high availability cluster with Memcached+magent
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. Memcached is based on a hashmap that stores key / value pairs. Its daemon (daemon) is written in C, but the client can write in any language and communicate with the daemon through the memcached protocol.
Experimental deployment host name IP address main service software memcached master server 172.16.10.138memcachedjournal libeventmagentrekeepalivedMemcached slave server 172.16.10.137memcachedmembevent Keepalived client 172.16.10.134telnet test configuration memcached main cache node server tar xf libevent-2.1.8-stable.tar.gz-C / opttar xf memcached-1.5.6.tar.gz-C / opttar xf magent-0.5.tar.gz-C / optcd / opt/libevent-2.1.8./configure-- prefix=/usr # specify installation path make & & make install # compile and install cd / opt/memcached-1.5 .6. / configure-- with-libevent=/usr # specify the installation path make & & make install # compile and install ln-s / usr/lib/libevent-2.1.so.6 / usr/lib64/libevent-2.1.so.6 # this module is required for the magent service on the master server
Cd / opt/magent
Vim ketama.h # ifndef SSIZE_MAX # modify # define SSIZE_MAX 32767 # modify # endifvim MakefileLIBS =-levent-lm # modify, add-lm make
Cp mgent / usr/bin # let the generated mgent program be recognized by the system
Configure memcached from the cache node server tar xzvf memcached-1.5.6.tar.gz-C / opttar xzvf libevent-2.1.8-stable.tar.gz-C / optcd / opt/libevent-2.1.8./configure-- prefix=/usrmake & & make installcd / opt/memcached-1.5.6./configure-- with-libevent=/usrmake & & make i nstallln-s / usr/lib/libevent-2.1.so.6 / usr/lib64/libevent-2.1. So.6 # the magent service on the master server requires this module the master server to copy the magent file to the slave server
Yum install openssh-clients
Scp magent root@172.16.10.137:/usr/bin/ copies the resulting magent file directly to the slave server.
The master server installs the keepalived service and modifies the configuration file
Yum-y install keepalived
Vim / etc/keepalived/keepalived.conf
Router_id MAGENT_HA # router_id master and slave cannot be the same. To modify vrrp_script magent {script "/ opt/shell/magent.sh" interval 2} # to define a new function, the script vrrp_instance VI_1 {state MASTER # is automatically executed every 2s. Here is the master server. The slave server is BACKUP interface ens33 # network card interface is ens33 virtual_router_id 51 priority 100 # priority The slave server is smaller than the master server advert_int 1authentication {auth_type PASS auth_pass 1111} track_script {magent # triggers the execution of the magent script} virtual_ipaddress {172.16.10.200 # virtual IP (vip)}} delete all the following redundant configurations from the master server install the keepalived service and modify the configuration file
Yum-y install keepalived
Vim / etc/keepalived/keepalived.conf
Router_id MAGENT_HB # router_id master is never the same vrrp_script magent {script "/ opt/shell/magent.sh" interval 2} # defines a new function, and automatically executes this script every 2s vrrp_instance VI_1 {state MASTER # here is the slave server BACKUP interface ens33 # Nic interface is ens33virtual_router_id 51 priority 90 # priority The slave server is smaller than the master server advert_int 1authentication {auth_type PASSauth_pass 1111} track_script {magent # triggers the execution of the magent script} virtual_ipaddress {172.16.10.200 # virtual IP (vip)}} delete all the redundant configurations below and write the magnet script on the master server
Mkdir / opt/shell
Vim / opt/shell/magent.sh #! / bin/bash K = `ps-ef | grep keepalived | grep-v grep | wc-l`if [$K-gt 0] Then magent-u root-n 51200-l 192.168.58.100-p 12000-s 192.168.58.135else pkill 11211-b 192.168.58.132else pkill-9 magent fi-n 51200 # define the maximum number of user connections-l 192.168.58.100 # specify virtual IP-p 12000 # specify port number-s # specify primary cache server -b # specify from cache server # this script means that once a keepalived process is detected in the system process Just execute the magent command, and if not, kill the magent process. To sum up, if there is no keepslived process on the master server, magent will connect to the slave server. Chmod + x / opt/shell/magent.sh # add execute permission to script write magent script from server
Mkdir-p / opt/shell
Vim / optgt grep. Wc-l`if [$K-gt 0] Thenmagent-u root-n 51200-l 192.168.58.100-p 12000-s 192.168.58.135192.168.58.132:11211elsepkill 11211-b 192.168.58.132:11211elsepkill-9 magentfi # the script from the server means to detect whether the virtual ip drift is coming to you. If the VIP drifts to the slave server, it executes the command magent, so that the slave server can start normally when the master server is down. Experimental verification
First, use the client to install telnet, connect to the VIP node remotely, and after writing to the user, the master-slave cache server will automatically get and download the user.
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.