1.两个节点都启动
#由于节点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
2.停止主节点
[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
3.重新启动主节点
[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
4.配置非抢占式
1)节点一修改
[root@lb01 ~]# vim /etc/keepalived/keepalived.conf
... ...
vrrp_instance VI_1 {
state BACKUP
nopreempt
......
}
[root@lb01 ~]# systemctl restart keepalived
2)节点2修改
[root@lb02 ~]# vim /etc/keepalived/keepalived.conf
... ...
vrrp_instance VI_1 {
state BACKUP
nopreempt
......
}
[root@lb02 ~]# systemctl restart keepalived
3)配置注意事项
1.两台机器节点状态都要改成 BACKUP
2.两个节点都要加上 nopreempt
3.优先级不需要改变
5.访问页面测试
#配置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:Users11764>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:Users11764>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 动态