How to do it…

The repmgr utility provides a set of single command-line actions that perform all the required activities on one node:

  1. To start a new cluster with repmgr with the current node as its primary, use the following command:
repmgr primary register
  1. To add an existing standby to the cluster with repmgr, use the following command:
repmgr standby register
  1. Use the following command to request repmgr to create a new standby for you by copying node1. This will fail if you specify an existing data directory:
repmgr standby clone node1 -D /path/of_new_data_directory
  1. To reuse an old master as a standby, use the rejoin command:
repmgr node rejoin -d ‘host=node2 user=repmgr’
  1. To switch from one primary to another one, run this command ...

Get PostgreSQL 10 Administration Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.