Keri sisuni

Changing the VRRP identifier

The virtual IP address of the PostgreSQL cluster is carried by one of the nodes through keepalived, which relies on the VRRP protocol. All the nodes of the cluster belong to the same VRRP group, identified by its VRRP identifier (VRID), a value between 1 and 255.

By default, the appliance uses the VRID 100. This identifier must be unique on the local network (VLAN) of the nodes: another VRRP group using the same identifier (another PostgreSQL cluster, a firewall, a router or a load balancer) prevents the virtual IP address from being carried (see Troubleshooting keepalived).

Choosing the identifier

Choose with the team in charge of the network a VRID that no other VRRP group uses on the local network of the PostgreSQL nodes. The same VRID is used on the three nodes.

Applying the identifier

Run the following commands as root on each PostgreSQL node:

Value Variable Definition
NEW_VRID New VRRP identifier chosen for the cluster (1 to 255).
1
2
sed -i "s/virtual_router_id [0-9]*/virtual_router_id NEW_VRID/" /etc/keepalived/keepalived.conf
systemctl restart keepalived

Example

To use the identifier 173:

1
2
sed -i "s/virtual_router_id [0-9]*/virtual_router_id 173/" /etc/keepalived/keepalived.conf
systemctl restart keepalived

Configuration utility

The /etc/keepalived/keepalived.conf file is written by the configuration utility of the appliance (ConfigureSystanciaVault.py) from its model, with the VRID 100. If the utility is run again on a node, apply the identifier again on that node.

Checking the virtual IP address

Once the three nodes are modified, one of them carries the virtual IP address. On each node, the keepalived logs show the state taken by the node:

1
journalctl -u keepalived -n 20

The LEADER node of the cluster displays Entering MASTER STATE; the two other nodes stay in the FAULT state, because the check_patroni_primary script of keepalived only succeeds on the LEADER node: the virtual IP address thus follows the LEADER node of Patroni.

On the node in the MASTER state, the virtual IP address appears among the addresses of the network interface:

1
ip -br a | grep -ve "^lo"

Example

For a node of address 10.0.10.51 carrying the virtual IP address 10.0.10.50:

1
ens192      UP      10.0.10.51/24 10.0.10.50/32