昊鼎王五:如何十分钟内在CentOS7上快速搭建集群mysql双主+keepavlied实现漂移、高可用服务之3:搭建keepalived双机热备

#昊鼎王五:如何十分钟内在CentOS7上快速搭建集群mysql双主+keepavlied实现漂移、高可用服务之3:搭建keepalived双机热备

在上一篇文章《昊鼎王五:如何十分钟内在CentOS7上快速搭建集群mysql双主+keepavlied实现漂移、高可用服务之2:构建主主(互为主从)同步关系》(https://blog.csdn.net/haoding205/article/details/81481492)我们中已经实现了MYSQL双主从同步关系的建立,而且实时同步了。本节主要讲“如何构建keepalived双机热备”。

为了让脉络清晰,阅读方便,本篇的重点内容是:“3:搭建keepalived双机热备”。
昊鼎王五:如何十分钟内在CentOS7上快速搭建集群mysql双主+keepavlied实现漂移、高可用服务之3:搭建keepalived双机热备_第1张图片

假设:
node1机器:192.168.1.101
node2机器:192.168.1.102
VIP(VirtualIP):192.168.1.103

#一、安装依赖包:

yum install -y epel-release.noarch
yum install gcc gcc-c++ patch bc openssl openssl-devel bzip2 zlib-devel unzip -y

#二、获取安装包并解压

cd /root/soft/
ll
tar xf keepalived-1.4.3.tar.gz              

#三、编译安装keepalived

cd /root/soft/keepalived-1.4.3/
ll
./configure --prefix=/hd205/services/keepalived
make -j 8
make
make install

#四、配置keepalived自启动

ln -svf /hd205/services/keepalived/sbin/keepalived /usr/sbin/
cp /hd205/services/keepalived/etc/sysconfig/keepalived /etc/sysconfig/
cp -r /hd205/services/keepalived/etc/keepalived/ /etc/
cp /root/soft/keepalived-1.4.3/keepalived/etc/init.d/keepalived /etc/rc.d/init.d/
chkconfig keepalived on
chkconfig
systemctl list-unit-files | grep keepalived

#五、配置keepalived的VIP及进程自检

cd /etc/keepalived/
ll
cp keepalived.conf keepalived.conf-bak
vim keepalived.conf              #可在文末下载
mkdir /scripts
cd /scripts/
ll
vim keepalived_backup.sh        #可在文末下载
vim keepalived_chk.sh           #可在文末下载
vim keepalived_master.sh        #可在文末下载
vim keepalived_stop.sh          #可在文末下载

cd /scripts/
chmod +x *.sh

#六、确保防火墙没有阻挡双方之间的通信
https://blog.csdn.net/haoding205/article/details/81391179

#七、启动并验证效果
/etc/init.d/keepalived start
ps -ef|grep keepalived
ip a

关闭两台机器中master主机器的keepavlived,看看是否实现了自动漂移,理论是是完全没有问题的。

文中提到的安装包、.conf、.sh等等 文件的可以通过如下链接获取:
昊鼎王五:如何十分钟内在CentOS7上快速搭建集群mysql双主+keepavlied实现漂移、高可用服务之3:搭建keepalived双机热备_第2张图片

网盘下载地址:
链接:https://pan.baidu.com/s/1jV2UaiFwZBEoyYr73tr8RA

OK了,此时搭建keepalived双机热备才算完成。通过这一系列的搭建,我们真正就实现了企业级mysql+keepalived主主、双机热备、高可用、自动漂移架构。

还有其他问题的可以在评论区留言或者如下联系方式扫码向我提问。
昊鼎王五:如何十分钟内在CentOS7上快速搭建集群mysql双主+keepavlied实现漂移、高可用服务之3:搭建keepalived双机热备_第3张图片

你可能感兴趣的:(高可用keepalived,Mysql)