1

我需要 Keepalived 在具有 2 个接口的 2 个负载平衡器 (NGINX) 上运行 VRRP - eth0(外部)和 eth1(内部)。我正在尝试配置一个设置,其中所有 VRRP 流量(最好是单播)都通过专用的内部 eth1 接口运行,以降低出现脑裂情况的风险。但是,浮动 IP 地址 (VRRP IP) 将位于 eth0(外部)网络上。

我正在查看 [https://github.com/acassen/keepalived/issues/637] 并尝试做类似的事情。我的配置如下:

global_defs {
   notification_email_from myadmin@myserver
   smtp_server localhost
   smtp_connect_timeout 30
   router_id LVS_DEVEL
}

vrrp_script check_nginx {
    script "/usr/libexec/keepalived/check_nginx.sh"
    interval 3
}

vrrp_sync_group link_instances {
    group {
        real
        stop_duplicate
    }
}

vrrp_instance real {
    state BACKUP
    interface eth0
    virtual_router_id 1
    priority 250               # This will be a lower value on the other router
    version 3                  # not necessary, but you may as well use the current protocol
    advert_int 1
    nopreempt

    track_interface {
        eth1
    }

    track_script {
        check_nginx
    }

    unicast_src_ip 115.197.1.166
    unicast_peer {
    115.197.1.167
    }

     virtual_ipaddress {
          115.197.1.170/32 dev eth0
    }
}

vrrp_instance stop_duplicate {
    state BACKUP
    interface eth1
    virtual_router_id 1
    priority 255             
    version 3
    advert_int 1
    nopreempt

    unicast_src_ip 192.168.0.3
    unicast_peer {
    192.168.0.4
    }

    virtual_ipaddress {
        192.168.0.5/29         
  }
}

到目前为止,我在此设置中遇到的问题:

  1. 在master上,我强行关闭了eth1(内部接口)。这随后触发了 keepalived 的故障转移,并且状态转换为故障。这并不是我所期待的行为,因为我认为这个想法是让它在这种情况下“使用”外部 eth0 进行通信(它仍然启动并运行外部 VRRP),因此这将提供弹性。是否有可能,当检测到 eth1 关闭时,不触发故障转移,而是等待 eth1 也失败,以便它进行故障转移?

  2. check_nginx我收到未使用我的 track_script 的警告。是否track_scripts仍然不允许在内部使用vrrp_sync_group?因为在 NGINX 失败的情况下我仍然需要它来工作。

  3. 我可以在内部使用抢占vrrc_sync_group吗?因为我想在它移动后防止故障回复。

  4. 有没有更好的方法来做到这一点?我想要实现的是:a。确保 VRRP 流量用于内部(专用)接口eth1和浮动 VRRP IP 驻留eth0。这样我们就不需要依赖外部网络来进行心跳。湾。如果 eth0 发生故障,如果 eth1 仍然存在,则不要故障转移到 BACKUP 节点。只有当那个也关闭时才进行故障转移(应该如此)。
    C。但是,如果check_nginx失败,这将触发故障转移。d。一旦故障转移,它就不会故障恢复——除非发生相同的故障情况(例如 NGINX 宕机)

想知道我想要实现的目标是否可行?

谢谢J

4

0 回答 0