0

I've been researching about Keepalived Virtual IP to make ProxySQL/MaxScale highly available and came across the concept of Virtual IP. All the articles that I've read just mentions a random Virtual IP directly but in no place I was able to find out how it is configured? Like where do we get that IP from?

Here's how keepalived configuration file looks like -

    vrrp_instance VRRP_1 {
    state BACKUP
    interface eth0
    virtual_router_id 101
    priority 100
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass sometext
    }
    virtual_ipaddress {
        192.0.2.123
    }
}

Like here they used the IP 192.0.2.123, but how are we supposed to assign a virtual IP? Any articles or suggestions would be helpful!

Nandni
  • 1
  • Learn how routing works. It's not mentioned explicitly because it's obvious. – Gerald Schneider Jul 06 '22 at 05:46
  • @GeraldSchneider I'm not a networks person & almost a beginner there. I'm definitely learning routing but external help is never bad. So if there are any clear answers you'd give that'd be helpful. – Nandni Jul 06 '22 at 05:52
  • You get the IP wherever you got the IP for the machine you want to configure it on. You can't just make up or use *any* IP, it needs to be routable to your machine. – Gerald Schneider Jul 06 '22 at 06:00

1 Answers1

1

This is kind of funny because the configuration you post is actually where you defined the virtual IP, in this case it is 192.0.2.123.

Keepalived is an implementation of the VRRP protocol, which is mostly used on router to provide redundant gateway for computers.

In this specific case it is used on two or more host to share a virtual IP to expose a service.

Let's say you have 2 two hosts with IP 192.0.2.121 and 192.0.2.122. You install keepalived on both machines and configure it as you posted, with a small difference: host 1 will have priority 100 and host 2 priority 50 for example.

Once configured the host 1 will act as the master (since it has the highest priority) and will respond to both its real IP (.121) and the virtual IP (.123).

As long as the first server is up, he second host will respond only to its real IP. If the first server is down, for any reason, it will stop sending keepalive packets, so the second server will take over and start responding to the virtual IP address.

JFL
  • 2,006
  • 1
  • 11
  • 16