您好,登錄后才能下訂單哦!
本實驗實現的是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進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。