How to do it...

We will assume that the 192.168.56.50 IP address exists as a predefined target for our PostgreSQL cluster. Users and applications will connect to it instead of the actual addresses of pg1 or pg2.

Perform these steps on any Pacemaker node as the root user:

  1. Add an IP address primitive to Pacemaker with crm:
        crm configure primitive pg_vip ocf:heartbeat:IPaddr2 \
            params ip="192.168.56.50" \
                  iflabel="pgvip" \
           op monitor interval="5"
  1. Try to view the IP allocation on pg1 and pg2:
        ifconfig | grep -A3 :pgvip
  1. Clean up any errors that might have accumulated with crm:
        crm resource cleanup pg_vip
  1. Display the status of our new IP address with crm:
        crm resource status

Get PostgreSQL High Availability Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.