In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-13 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Magent Cache Proxy Introduction
Because there is no communication between Memcached servers, there is a single point of failure when any server node fails. Prevent single-point phenomena with Magent cache proxy. By connecting clients to the cache proxy server, the cache proxy server can connect multiple Memcached machines and synchronize data from each Memcached machine simultaneously. If one of the cache servers goes down, the system can still work, and if one of the Memcached machines goes down, the data will not be lost and the integrity of the data can be guaranteed.
Principle demonstration diagram:
Introduction to experimental environment:
Three servers:
master/slave/client
experimental procedure
Install libevent, memcached on both master and slave
master&&slave:
systemctl stop firewalld.service
setenforce 0
tar zxvf memcached-1.5.6.tar.gz -C /opt
tar zxvf libevent-2.1.8-stable.tar.gz -C /opt
yum install gcc gcc-c++ -y
cd /opt/libevent-2.1.8-stable/
./ configure --prefix=/usr/local
make && make install
cp /usr/local/lib/libevent-2.1.so.6 /usr/lib64/
cd /opt/memcached-1.5.6/
./ configure --with-libevent=/usr/local
make && make install
Install and configure magent on master
master:
mkdir /opt/magent
tar zxvf magent-0.5.tar.gz -C /opt
vim /opt/magent/ketama.h
#ifndef SSIZE_MAX
#define SSIZE_MAX 32767
#endif
vim /opt/magent/Makefile
LIBS = -levent -lm Here is the English word 'l', not 1
make
Copy magent command to slave server
Note: Marked places are locations to be changed
yum install openssl-clients -y
cp magent /usr/bin
scp magent root@192.168.218.157:/usr/bin
yum install keepalived -y
vim /etc/keepalived/keepalived.conf
! Configuration File for keepalived
global_defs {
notification_email {
acassen@firewall.loc
failover@firewall.loc
sysadmin@firewall.loc
}
notification_email_from Alexandre.Cassen@firewall.loc
smtp_server 192.168.200.1
smtp_connect_timeout 30
router_id MAGENT_HA
}
vrrp_script magent {
script "/opt/shell/magent.sh" Script location
interval 2 detection script is 2 seconds
}
vrrp_instance VI_1 {
state MASTER
interface ens33
virtual_router_id 51
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
track_script {call vrrp_script magent
magent
}
virtual_ipaddress {
192.168.218.16
}
}
Install configuration keepalived from server
slave:
yum install openssl-clients -y
yum install keepalived -y
cd /etc/keepalived/
mv keepalived.conf keepalived.conf.bk
master:
cd /etc/keepalived/
scp keepalived.conf root@192.168.218.157:/etc/keepalived/keepalived.conf
slave:
vim /etc/keepalived/keepalived.conf
global_defs {
router_id MAGENT_HB
vrrp_instance VI_1 {
state BACKUP
virtual_router_id 52
priority 90
master:
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.218.16 -p 12000 -s 192.168.218.130:11211 -b 192.168.218.157:11211 else pkill -9 magent fi
chmod +x /opt/shell/magent.sh
systemctl start keepalived.servic
netstat -ntap |grep 12000 #At this time check that there should be 12000 port number
slave:
mkdir /opt/shell
vim /opt/shell/magent.sh
#!/ bin/bash K=`ip addr | grep 192.168.218.16 | grep -v grep | wc -l` if [ $K -gt 0 ];then magent -u root -n 51200 -l 192.168.218.16 -p 12000 -s 192.168.218.130:11211 -b 192.168.218.157:11211 else pkill -9 magent fi
#magent -u specifies user, -n specifies number of connections, -l specifies drift address, -p specifies port, -s specifies master server address, -b specifies slave server address
chmod +x /opt/shell/magent.sh
systemctl start keepalived.servic
netstat -ntap |grep 12000 #At this time check that there should be 12000 port number
master:
memcached -m 512k -u root -d -l 192.168.218.130 -p 11211
netstat -ntap | grep 11211
slave:
memcached -m 512k -u root -d -l 192.168.218.157 -p 11211
netstat -ntap | grep 11211
Testing:
master:
yum install telnet -y
telnet 192.168.218.130 11211
slave:
yum install telnet -y
telnet 192.168.218.157 11211
client:
yum install telnet -y
telnet 192.168.218.16 12000
Trying 192.168.218.16...
Connected to 192.168.218.16.
Escape character is '^]'.
add username 0 0 7 #Write a piece of data
1231231
STORED
slave:
telnet 192.168.218.157 11211
Trying 192.168.218.157...
Connected to 192.168.218.157.
Escape character is '^]'.
get username
VALUE username 0 7
1231231 #Synchronized data can be seen on master and slave servers
END
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: 245
*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.