之前是单实例,主备模式的高可用VIP飘逸
keepalived还支持多实例,双向主备模式
A业务在lb01上是主模式,在lb02上是备模式
B业务在lb01上是备模式,在lb02上是主模式
lb01 192.168.178.123 VIP:192.168.178.3,绑定A业务 www.yu.com
lb02 192.168.178.124 VIP:192.168.178.4,绑定B业务 bbs.yu.com
lb01
此处的配置,在lb01机器VI_1实例属于MASTER角色,VI_2实例属于BACKUP角色
global_defs {
router_id lb01
}
vrrp_instance VI_1 {
state MASTER
interface ens33
virtual_router_id 51
priority 150
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
priority 150
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.178.3/24 dev ens33 label ens33:3
}
}
vrrp_instance VI_2 {
state BACKUP
interface ens33
virtual_router_id 52
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.178.4/24 dev ens33 label ens33:4
}
}
lb02
global_defs {
router_id lb02
}
vrrp_instance VI_1 {
state BACKUP
interface ens33
virtual_router_id 51
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.178.3/24 dev ens33 label ens33:3
}
}
vrrp_instance VI_2 {
state MASTER
interface ens33
virtual_router_id 52
priority 150
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.178.4/24 dev ens33 label ens33:4
}
}
分别重启lb01,lb02 查看两个实例的vip状态
先记录当前的vip状态
lb01
inet 192.168.178.123/24 brd 192.168.178.255 scope global noprefixroute ens33
valid_lft forever preferred_lft forever
inet 192.168.178.3/24 scope global secondary ens33:3
valid_lft forever preferred_lft forever
lb02
inet 192.168.178.124/24 brd 192.168.178.255 scope global noprefixroute ens33
valid_lft forever preferred_lft forever
inet 192.168.178.4/24 scope global secondary ens33:4
valid_lft forever preferred_lft forever
1、lb01是vrrp实例1的master,因此一定会有192.168.178.3这个ip
2、lb01是vrrp实例2的backup,当实例2宕机或者没有启动,就会出现192.168.178.4。
lb02是vrrp1的backup,是vrrp的master
记住如因素即可
谁是vrrp实例的master,谁就优先得到vip
lb01得到的是vrrp1的vip,因此是3
lb02是vrrp2的master,因此得到的是4
网友评论