Linode 上 2 个 Web 服务器节点的廉价集群的 Keepalived 配置

Linode 上 2 个 Web 服务器节点的廉价集群的 Keepalived 配置

我的预算有限,因此我只运行 2 个相同的 Linode(Ubuntu 18.x)。我不打算使用 Nodebalancer,因为我一次只需要启动一台服务器。

我已经成功配置了 gluster 和 galera。现在该配置 keepalived 了。

这是我想出的配置。

  1. 有人可以验证一下这是正确的吗?
  2. 使用unicast_peer和下的两个Linode的公网ip正确吗unicast_server_ip
  3. 另外我不确定在virtual_ipaddress

掌握:

! Configuration File for keepalived
global_defs {
    notification_email {
    }

    router_id LVS_DBCLUSTER
}

vrrp_script chk_nginx {
    script "pidof nginx"
    interval 2
}

vrrp_instance VI_1 {
    state MASTER
    interface eth0
    virtual_router_id 51
    priority 101

    track_interface {
        eth0
    }

    track_script {
        chk_nginx
    }

    authentication {
        auth_type PASS
        auth_pass example_password
    }

    unicast_src_ip  <master-server-public-ip, sharing enabled>
    unicast_peer {
    <secondary-server-public-ip>
    }

    virtual_ipaddress {
    <i am not sure what IP comes here>
    }
    notify_master "/bin/echo 'now master' > /tmp/keepalived.state"
    notify_backup "/bin/echo 'now backup' > /tmp/keepalived.state"
    notify_fault "/bin/echo 'now fault' > /tmp/keepalived.state"
}

奴隶:

! Configuration File for keepalived
global_defs {
    notification_email {
    }

    router_id LVS_DBCLUSTER
}

vrrp_script chk_nginx {
    script "pidof nginx"
    interval 2
}

vrrp_instance VI_1 {
    state MASTER
    interface eth0
    virtual_router_id 51
    priority 101

    track_interface {
        eth0
    }

    track_script {
        chk_nginx
    }

    authentication {
        auth_type PASS
        auth_pass example_password
    }

    unicast_src_ip  <secondary-server-public-ip, sharing NOT enabled>
    unicast_peer {
    <master-server-public-ip>
    }

    virtual_ipaddress {
    <i am not sure what IP comes here>
    }
    notify_master "/bin/echo 'now master' > /tmp/keepalived.state"
    notify_backup "/bin/echo 'now backup' > /tmp/keepalived.state"
    notify_fault "/bin/echo 'now fault' > /tmp/keepalived.state"
}

我对此进行了反复试验,最终我的两台服务器都无法访问。所以我不得不重建服务器。我希望有一位 keepalived + linode 专家能提出建议。

相关内容