keepalived vip 已删除,并已通过 dhcp 续订

keepalived vip 已删除,并已通过 dhcp 续订

我遇到了一个奇怪的问题,当我收到新的 DHCP 续订请求时,我的 vip 会被从我的界面中删除。日志显示以下内容:

Jun  1 17:00:06 lb1 dhclient: DHCPREQUEST of 10.0.0.2 on eth0 to 10.0.0.3 port 67 (xid=0x6deab016)
Jun  1 17:00:06 lb1 dhclient: DHCPNAK from 10.0.0.3 (xid=0x6deab016)
Jun  1 17:00:06 lb1 dhclient: DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 3 (xid=0x37e1db6a)
Jun  1 17:00:06 lb1 dhclient: DHCPREQUEST of 10.0.0.2 on eth0 to 255.255.255.255 port 67 (xid=0x37e1db6a)
Jun  1 17:00:06 lb1 dhclient: DHCPOFFER of 10.0.0.2 from 10.0.0.3
Jun  1 17:00:06 lb1 dhclient: DHCPACK of 10.0.0.2 from 10.0.0.3
Jun  1 17:00:06 lb1 dhclient: bound to 10.0.0.2 -- renewal in 38223 seconds.
Jun  1 17:00:07 lb1 ntpd[1321]: Deleting interface #8 eth0, 10.0.255.254#123, interface stats: received=7, sent=0, dropped=0, active_time=145198 secs
Jun  1 17:00:07 lb1 ntpd[1321]: peers refreshed

此时,vip ip(10.0.255.254)已从接口中删除,并且不会故障转移到其他 keepalived 实例。

工作ip a命令输出:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
   inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether fa:16:3e:cf:35:ac brd ff:ff:ff:ff:ff:ff
    inet 10.0.0.2/16 brd 10.0.255.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet 10.0.255.254/32 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::f816:3eff:fecf:35ac/64 scope link
       valid_lft forever preferred_lft forever

当 dhcp 更新运行时:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
   inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether fa:16:3e:cf:35:ac brd ff:ff:ff:ff:ff:ff
    inet 10.0.0.2/16 brd 10.0.255.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::f816:3eff:fecf:35ac/64 scope link
       valid_lft forever preferred_lft forever

接口文件:

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet dhcp

当我在实例上重新启动 keepalived 时,vip 会再次添加到接口。那么问题是 dhcp 为什么要删除 vip?

答案1

我最近也遇到了同样的问题。我正在运行两个 OpenStack 实例keepalived。我注意到,当实例更新其 IP 地址时,有时keepalived会认为 IP 地址已被删除,然后片刻后重新添加。这足以释放 VIP,但不会将它们重新添加到主keepalived实例,也不足以让备用实例接管 VIP。

在查看了keepalived的文档后,我发现了一个名为不要跟踪主要可以添加到vrrp实例中。我已将该选项添加到我的所有vrrp实例中,从此再也没有出现过问题。

相关内容