Configuring Keepalived for budget friendly 2 node setup

I am on a low budget - so I am running just 2 identical linodes (Ubuntu 18.x). I don't plan to use Nodebalancer, since I need only one server to be up at a time.

I have been able to successfully configure gluster and galera. Now it is time for keepalived.

This is the configuration I came up with. Could you please validate to confirm this is correct?

MASTER:

! 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"
}

SLAVE:

! 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"
}

1 Reply

It's difficult for us to say for sure whether your Keepalived configuration is adequate since it depends on your specific needs. We typically recommend the configurations listed in this guide for getting started with Keepalived. Something I noticed is that you have your public IP address listed under the unicast_src_ip variable; this should be your secondary Linode's private IP address. In unicast_peer, you'll want to list your master server's private IP address.

The IP address that will go where virtual_ipaddress is indicated will be the floating IP address that you configured when you set up IP Sharing. In short, your virtual IP address is the IP address that will be shared between your Linodes.

Keepalived also has a great resource for configurations and settings that you may find helpful! You can also always tweak your configurations as needed.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct