✓ Solved

How do I setup keepalived for a 2 node cluster with public ip failover

I am setting up a low budget 2 node cluster for testing purposes.

I have 2 Nanodes (primary & secondary) - both have public and private IPs.

I've successfully configured MariaDB on both of them with Galera cluster, and the application filesystem is synced using GlusterFS. So far all looks good.

Later I will be installing Nginx on both as well. The primary server's public IP is shared with the secondary server as well.

So the nodes look like this:

Primary Secondary
nginx nginx
mysql mysql
public IP (public primary) public ip (public secondary)
private IP (private primary) private ip (private secondary)
- public IP (shared from primary to secondary)

All syncing (filesystem and database) happens over private IP.

Though both servers will be up, only primary will always serve.

The application on the primary server will connect to the primary server's DB instance.

The application on the secondary server will connect to the secondary server's DB instance.

The idea is to failover the public IP of primary to secondary if any of the core processes on the primary server fails (MySQL, or Nginx).

How do I configure keepalived such that the public IP is failed over? All guides I've seen fail over the private IP. I need the public IP to be failed over. I know it is possible, but I just can't seem to get my head around it.

1 Reply

✓ Best Answer

Finally got it to work. Everything was the same. I was using local domain name (configured in /etc/hosts) under the unicast sections and hence keepalived was ignoring them.

Changed them to private IP, and used the public IP of Primary server in the virtual ip section and it all worked as expected :)


Please enter an answer

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