How to do it...

For this scenario, assume that we have two servers with the addresses of 192.168.1.10 and 192.168.1.20, where 192.168.1.10 is currently the primary server. In addition, we have a virtual IP address of 192.168.1.30 on the eth0 Ethernet device. To upgrade the PostgreSQL software on both nodes, follow these steps:

  1. Stop the database copy on 192.168.1.20 as the postgres user using this command:
pg_ctl -D /path/to/database stop -m fast
  1. Perform any necessary software upgrades. For example, to upgrade a Debian or Ubuntu server to the latest PostgreSQL 12, use the following command as a root-capable user on 192.168.1.20:
sudo apt-get install postgresql-12
  1. Start the database copy on 192.168.1.20 as the postgres user:
pg_ctl -D ...

Get PostgreSQL 12 High Availability Cookbook 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.