整体技术方案采用keepalived+drbd主从
1. 准备俩台机器、俩块磁盘 ,机器我用的是腾讯云的 。 因为阿里云的hvip已经下架了,估计是想卖他们的负载均衡
ip 磁盘 hostname
172.17.0.10 /dev/vdb1 VM_0_10_centos 主
172.17.0.15 /dev/vdb1 VM_0_15_centos 从
vip: 172.10.13
这个hvip 必须在先申请,详细请看https://cloud.tencent.com/document/product/215/20129
一、 搭建drbd 主从
1. 修改hosts文件
[root@VM_0_15_centos scripts]# vim /etc/hosts
-
- 172.17.0.10 VM_0_10_centos
172.17.0.15 VM_0_15_centos
[root@VM_0_10_centos scripts]# vim /etc/hosts
172.17.0.10 VM_0_10_centos
172.17.0.15 VM_0_15_centos
2.互相免密登陆
[root@VM_0_10_centos ~]# ssh-keygen
[root@VM_0_10_centos ~]# ssh-copy-id VM_0_15_centos
[root@VM_0_15_centos ~]# ssh-keygen
[root@VM_0_15_centos ~]# ssh-copy-id VM_0_10_centos
3. 时钟同步
[root@VM_0_10_centos ~]# crontab -e
*/5 * * * * ntpdate cn.pool.ntp.org ###添加任务
node2:
[root@VM_0_15_centos ~]# crontab -e
*/5 * * * * ntpdate cn.pool.ntp.org ###添加任务
4.
5、现在我们就要开始安装drbd包在VM_0_10_centos和VM_0_15_centos操作:
VM_0_10_centos上:
[root@VM_0_10_centos ~]# rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
[root@VM_0_10_centos ~]# rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm
[root@VM_0_10_centos ~]#yum install -y kmod-drbd84 drbd84-utils kernel* ##装完重启一下
VM_0_15_centos上:
[root@VM_0_15_centos ~]# rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
[root@VM_0_15_centos ~]# rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm
[root@VM_0_15_centos ~]#yum install -y kmod-drbd84 drbd84-utils kernel*
[root@VM_0_15_centos ~]# vim /etc/drbd.d/global_common.conf
globa