Aqbeż għall-kontenut

Troubleshooting keepalived

Information

The whole procedure must be followed as root. To elevate your privileges to root, you can use the su - command.

keepalived carries the virtual IP address of the PostgreSQL cluster on one of the nodes. It relies on the VRRP protocol: each node regularly sends VRRP announcements on the local network (multicast address 224.0.0.18), and the nodes that receive announcements of the same VRRP identifier (VRID) form a group, in which one node takes the MASTER state and carries the virtual IP address.

Information

The keepalived configuration is stored in the /etc/keepalived/keepalived.conf file on each node.

Only the LEADER node of Patroni can take the MASTER state: the check_patroni_primary script of keepalived queries the Patroni API of the node and fails on the other nodes, which stay in the FAULT state. In normal operation, the logs therefore show Entering MASTER STATE on the LEADER node and Entering FAULT STATE on the two other nodes.

Logs

The procedure relies on the logs of the keepalived service, which you get with the command below:

1
journalctl -u keepalived

Tip

To follow the logs live, add the -f option to the command:

1
journalctl -fu keepalived

The virtual IP address is carried by no node

The virtual IP address does not answer, and none of the three nodes shows it among its addresses (ip -br a). In the logs, the LEADER node stays in the BACKUP state (the two other nodes are in the FAULT state), and the following message appears:

1
2
(VI_1) Entering BACKUP STATE
(VI_1) ip address associated with VRID 100 not present in advert from 10.0.10.99: 10.0.10.50

Here, the machine 10.0.10.99, foreign to the PostgreSQL cluster, sends VRRP announcements with the same identifier (100) on the local network.

The VRID only identifies a VRRP group within a local network (VLAN). When two groups use the same identifier there, each one receives the announcements of the other and considers them as coming from its own group:

  • if the other group announces a priority higher than or equal to that of the nodes, the LEADER node stays in the BACKUP state and the virtual IP address is never carried;
  • otherwise, the two groups claim the same virtual MAC address (00:00:5e:00:01:<VRID>, in hexadecimal), and the network equipment sends the traffic alternately to one or the other, which disrupts both services.

To solve the conflict, give the cluster an identifier that no other VRRP group uses on the local network: see Changing the VRRP identifier.

Checking the VRRP flow

If no foreign machine appears in the logs and several nodes nevertheless take the MASTER state at the same time, the nodes do not receive the announcements of the others. Check that the VRRP flow (IP protocol 112 towards 224.0.0.18) is allowed between the nodes on the network equipment (see the prerequisites).