云计算
memcache高可用群集
实验环境:
主服务器192.168.45.132telnet、libevent、memcached、keepalived、magent从服务器
192.168.45.131
telnet、libevent、memcached、keepalived
测试机
192.168.45.135
telnet
实验目的:
实现存储内容的主从备份
实验搭建:
一、主服务器:
1、挂载软件包,
#挂载软件包mount.cifs //192.168.100.3/lzp /mnt#创建目录mkdir /opt/magent #解压必要安装包cd /mnt/memtar zxvf magent-0.5.tar.gz -c /opt/magent/tar zxvf libevent-2.1.8-stable.tar.gz -c /opttar zxvf memcached-1.5.6.tar.gz -c /opt#安装必要组件yum install gcc gcc-c make -y2、对组件进行编译安装
#编译安装libeventcd /opt/libevent-2.1.8-stable/./configure --prefix=/usrmake && make install#编译安装memcachedcd /opt/memcached-1.5.6/./configure --with-libevent=/usrmake && make install#编译安装magentcd /opt/magent/#修改ketama.h文件vim ketama.h#ifndef ssize_max#define ssize_max 32767#将#endif移动到第三行,删除掉末尾的#endifvim makefile#第一行末尾添加-lmlibs = -levent-lm#编译make#编译好的magent文件
3、将编译好的magent文件复制到/usr/bin目录下,并推送给从服务器
#安装openssh推送软件yum install openssh-clients -y#将编译好的magent文件复制到/usr/bin目录下cp magent /usr/bin#推送magent文件scp magent root@192.168.45.131:/usr/binthe authenticity of host \\\'192.168.45.131 (192.168.45.131)\\\' can\\\'t be established.ecdsa key fingerprint is sha256:bw2256ohr5apf7clizv/faoyvnvsmmrn lz5efeqgtg.ecdsa key fingerprint is md5:6f:f6:70:4f:46:64:ec:17:a7:ae:c0:15:1c:8b:55:1c.are you sure you want to continue connecting (yes/no)? yeswarning: permanently added \\\'192.168.45.131\\\' (ecdsa) to the list of known hosts.root@192.168.45.131\\\'s magent 100% 112kb 5.8mb/s 00:00 4、关闭防火墙和安全功能
systemctl stop firewalld.service setenforce 05、安装keepalived,并进行修改
#安装keepalivedyum install keepalived -y#修改配置文件vim /etc/keepalived/keepalived.conf ! configuration file for keepalived#写入下列内容vrrp_script magent { script /opt/shell/magent.sh interval 2}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 #修改route-id router_id magent_ha}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 { magent } virtual_ipaddress { #设置虚拟指向地址 192.168.45.188 }}6、创建magent脚本
mkdir /opt/shellcd /opt/shell/vim magent.sh#!/bin/bashk=`ps -ef | grep keepalived | grep -v grep | wc -l`if [ $k -gt 0 ];then magent -u root -n 51200 -l 192.168.45.188 -p 12000 -s 192.168.45.132:11211 -b 192.168.45.131:11211elsepkill -9 magentfi#给于运行权限chmod x magent.sh7、启动服务,并查看
#启动keepalivedsystemctl start keepalived.service#查看迁移地址ip addr#启动memcached memcached -m 512k -u root -d -l 192.168.45.132 -p 11211
安装telent进行测试
yum install telnet -y
二、从服务器
1、挂载软件包,并关闭防火墙和安全功能
mount.cifs //192.168.100.3/lzp /mnt#关闭防火墙和安全功能systemctl stop firewalld.service setenforce 02、解压安装包,并进行编译
#解压安装包cd /mnt/memtar zxvf libevent-2.1.8-stable.tar.gz -c /opttar zxvf memcached-1.5.6.tar.gz -c /opt#安装必要组件包yum install gcc gcc-c make -y#编译安装libeventcd /opt/libevent-2.1.8-stable/./configure --prefix=/usrmake && make install#编译安装memcachedcd /opt/memcached-1.5.6/./configure --with-libevent=/usrmake && make install3、安装keepalived
#安装keepalivedyum install keepalived -y#修改keepalived文件cd /etc/keepalived/mv keepalived.conf keepalived.conf.bkvim keepalived.conf! configuration file for keepalivedvrrp_script magent { script /opt/shell/magent.sh interval 2}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 router_id magent_hb}vrrp_instance vi_1 { state backup #修改网络接口 interface ens33 #修改virtual_router_id vi
腾讯云服务器买完在哪看到域名怎么样购买 你能想象一个域名的价格有多高吗云服务器cpu哪个好win域名是什么 为何要选择终身域名ssl证书认证机构有哪些?嘉兴网站建设公司谈SEO黑帽优化阿里云服务器五折优惠小型网站如何选阿里云服务器镜像