How to do it...

For these steps, assume that  eth0 is the primary interface and 127.0.0.10 is the IP we are trying to claim. Follow these steps to move or create a virtual IP:

  1. First, connect to the PostgreSQL node that had the IP address earlier. This is often the primary server.
  2. Release the IP address with the following command:
        sudo ifconfig eth0:pgvip down
  1. Ping the desired IP address with this command:
         ping -c 3 127.0.0.10
  1. If the preceding command reaches any PostgreSQL server, restart from the beginning with this system instead.
  2. Next, connect to the new server that should own the IP address.
  3. Claim the IP address with the following command:
         sudo ifconfig eth0:pgvip 127.0.0.10
  1. Tell the network about the location of the new ...

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.