高可用keepalived的抢占式与非抢占式
#由于节点1的优先级高于节点2,所以VIP在节点1上面
[root@lb01 ~]# ip addr | grep 10.0.0.3
inet 10.0.0.3/32 scope global eth0
[root@lb02 ~]# ip addr | grep 10.0.0.3
[root@lb01 ~]# systemctl stop keepalived
#节点2联系不上节点1,主动接管VIP
[root@lb02 ~]# ip addr | grep 10.0.0.3
inet 10.0.0.3/32 scope global eth0
[root@lb01 ~]# systemctl start keepalived
#由于节点1的优先级高于节点2,所以恢复节点1之后,vip又漂回节点1
[root@lb01 ~]# ip addr | grep 10.0.0.3
inet 10.0.0.3/32 scope global eth0
[root@lb01 ~]# vim /etc/keepalived/keepalived.conf
... ...
vrrp_instance VI_1 {
state BACKUP
nopreempt
......
}
[root@lb01 ~]# systemctl restart keepalived
[root@lb02 ~]# vim /etc/keepalived/keepalived.conf
... ...
vrrp_instance VI_1 {
state BACKUP
nopreempt
......
}
[root@lb02 ~]# systemctl restart keepalived
1.两台机器节点状态都要改成 BACKUP
2.两个节点都要加上 nopreempt
3.优先级不需要改变
#配置hosts
10.0.0.3 linux.blog.com
#访问页面
http://linux.blog.com/
#节点测试
[root@lb01 ~]# ip addr | grep 10.0.0.3
inet 10.0.0.3/32 scope global eth0
#访问网站,并且windows查看mac地址测试
C:\Users\11764>arp -a
VIP VMAC
10.0.0.3 00-0c-29-d7-bc-2c 动态
10.0.0.4 00-0c-29-d7-bc-2c 动态
10.0.0.5 00-0c-29-89-2f-10 动态
#关闭节点1keepalived
[root@lb01 ~]# systemctl stop keepalived.service
[root@lb02 ~]# ip addr | grep 10.0.0.3
inet 10.0.0.3/32 scope global eth0
#访问网站,并且windows查看mac地址测试
C:\Users\11764>arp -a
VIP VMAC
10.0.0.3 00-0c-29-89-2f-10 动态
10.0.0.4 00-0c-29-d7-bc-2c 动态
10.0.0.5 00-0c-29-89-2f-10 动态
本文来自博客园,作者:六月OvO,转载请注明原文链接:https://www.cnblogs.com/chenlifan/p/13652518.html