keepalived 故障转移停机时间

keepalived 故障转移停机时间

我有一个简单的设置,在 2 个 Ubuntu 16.04 服务器(VMWare VM)上配置了 keepalived

我在主机之间共享了一个 VIP,一切运行正常。当我停止或重新启动一台服务器时,另一台服务器将接管 MASTER 并顺利转移 VIP。

我遇到的问题是这需要多长时间。我对 VIP 进行了连续 ping,我发现 ping 似乎需要大约 3-4 秒才能再次响应。我期望/希望这几乎是即时的,但事实并非如此。

keepalived 版本是 1.2.19,我的配置粘贴在下面。我尝试将 advert_int 减少到小于 1,但执行此操作时收到一条错误消息 - “VRRP_Instance(TEST_LOADBALANCER):版本 2 不支持亚秒级广告间隔!”从我的配置中可以看出,我尝试强制使用 VRRP 版本 3,但这似乎没有效果。

服务器 1-/etc/keepalived/keepalived.conf

global_defs {
        notification_email {
                [email protected]
        }
        notification_email_from [email protected]
        smtp_server emailserver.email.com
        vrrp_version 3
        smtp_connect_timeout 30
        garp_master_delay 0
}

vrrp_instance TEST_LOADBALANCER {
        state MASTER
        smtp_alert
        notify /usr/local/sbin/notify-keepalived.sh
#       Specify the network interface to which the virtual address is assigned
        interface ens160
#       The virtual router ID must be unique to each VRRP instance that you define
        virtual_router_id 61
#       Set the value of priority higher on the master server than on a backup server
        priority 254
#       advert_int 1
    virtual_ipaddress {
        192.168.20.20
      }
}

服务器2-/etc/keepalived/keepalived.conf

global_defs {
        notification_email {
                [email protected]
        }
        notification_email_from [email protected]
        smtp_server emailserver.email.com
        vrrp_version 3
        smtp_connect_timeout 30
        garp_master_delay 0
}

vrrp_instance TEST_LOADBALANCER {
        state BACKUP
        smtp_alert
        notify /usr/local/sbin/notify-keepalived.sh
#       Specify the network interface to which the virtual address is assigned
        interface ens160
#       The virtual router ID must be unique to each VRRP instance that you define
        virtual_router_id 61
#       Set the value of priority higher on the master server than on a backup server
        priority 250
#       advert_int 1
    virtual_ipaddress {
        192.168.20.20
      }
}

notify-keepalived.sh 脚本只是停止并启动使用 VIP 的 HAProxy 服务。

有没有办法实现比现在更快的故障转移?目前,每当在这些服务器上执行操作系统更新或维护时,这都会在我们的生产环境中造成问题。

非常感谢您的帮助!

谢谢,JP

相关内容