您好,登录后才能下订单哦!
密码登录
登录注册
点击 登录注册 即表示同意《亿速云用户服务条款》
本实验实现的是memcached+magent+keepalived高可用群集:
实验要求:
# tar zxvf libevent-2.1.8-stable.tar.gz -C /opt
# tar zxvf memcached-1.5.6.tar.gz -C /opt
# mkdir /opt/magent ==注==从服务器不做
# tar zxvf magent-0.5.tar.gz -C /opt/magent/
# yum install gcc gcc-c++ make -y
---
# cd /opt/libevent-2.1.8-stable/
./configure --prefix=/usr
# make && make install
# cd memcached-1.5.6/
./configure --with-libevent=/usr
# make && make instal
---
只有主:
# cd /opt/magent/
# vim ketama.h
ifndef SSIZE_MAX
define SSIZE_MAX 32767
# vim Makefile
LIBS = -levent -lm
make
主服务器上:
# yum install openssh-clients -y
# cp magent /usr/bin/ //便于使用
# scp magent root@192.168.177.135:/usr/bin //将magent复制到从服务器上
# systemctl stop firewalld.service //关闭防火墙
# setenforce 0 //增强型安全功能
从服务器上:
# yum install openssh-clients
# systemctl stop firewalld.service
# setenforce 0
# cd /usr/bin
# ls
就会发现magent变成一个可执行的文件
主服务器上:
# yum install keepalived -y
# vi /etc/keepalived/keepalived.conf
router_id MAGENT_HA
interface ens33
virtual_router_id 51
priority 100
virtual_ipaddress {
192.168.177.188 //设置的虚拟IP
}
vrrp_script magent {
script "/opt/shell/magent.sh"
interval 2
}
track_script {
magent
}
# scp /etc/keepalived/keepalived.conf root@192.168.177.135:/etc/keepalived/keepalived.conf //将keepalived.conf复制到从服务器上
从服务器上:
# vim /etc/keepalived/keepalived.conf
修改:state :BACKUP
interface ens33
virtual_router_id 52
priority 90
主从一样:
# mkdir /opt/shell
# cd /opt/shell
# vi 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.177.188 -p 12000 -s 192.168.177.140:11211 -b 192.168.177.135:11211
else
pkill -9 magent
fi
# chmod +x magent.sh //为脚本添加执行权限
# systemctl start keepalived.service //开启服务
# memcached -m 512k -u root -d -l 192.168.177.140 -p 11211 //主服务器上
# memcached -m 512k -u root -d -l 192.168.177.135 -p 11211 //从服务器上
ip addr //查看虚拟地址
# yum install telnet -y
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。