三台都是centos7.2系统
关闭firewalld和selinux
注意前端两个服务器的内网网卡都是同一个名称且关闭网卡NetworkManager服务。不然down掉keepalived里面配置的监听网卡,VIP不会漂移到备机上。
Redis集群可以实现能实现高可用、读写分离、读负载均衡功能
大致原理图如下:
![80f7890b7ed68484d325c9d2f5d54f01.png](https://img-blog.csdnimg.cn/img_convert/80f7890b7ed68484d325c9d2f5d54f01.png)
Haproxy监控图如下:
![c20d6e39f9b21a35f7fec9400923fe80.png](https://img-blog.csdnimg.cn/img_convert/c20d6e39f9b21a35f7fec9400923fe80.png)
需要三台服务器搭建此环境。详细信息如下:
Keepalived和haproxy默认从yum源的base源中安装。Redis必须安装remi源,不然最新的安装版本是2.8,这里我们采用3.2最新稳定版本。注意安装remi源必须先要安装epel源
rpm -ivh https://mirrors.tuna.tsinghua.edu.cn/epel/7/x86_64/e/epel-release-7-8.noarch.rpm
rpm -ivh
安装完成后将remi.repo文件里面的epel启用,如下图:
![59189e9779704cedb8743b8826281174.png](https://img-blog.csdnimg.cn/img_convert/59189e9779704cedb8743b8826281174.png)
将enabled=1
然后开始安装上面软件,注意第三台服务器不用安装keepalived和haproxy
yum install keepalived haproxy redis -y
前两台keepalived配置文件如下:
! Configuration File for keepalived
global_defs {
route_id REDIS-HA</