How to do it...

For this recipe, we will need two PostgreSQL servers, pg1 and pg2, where pg1 is the currently active node. Follow these steps as the root user on the system indicated to move an active PostgreSQL service from one node to another:

  1. Stop the PostgreSQL service with pg_ctl on pg1:
        pg_ctl -D /db/pgdata stop -m fast
  1. Unmount the /db filesystem on pg1:
        umount /db
  1. Mark the VG_POSTGRES group as inactive using vgchange on pg1:
        vgchange -a n VG_POSTGRES
  1. Demote the DRBD status to secondary with drbdadm on pg1:
        drbdadm secondary pg
  1. Promote the DRBD status to primary with drbdadm on pg2:
        drbdadm primary pg
  1. Mark the VG_POSTGRES group as active using vgchange on pg2:
        vgchange -a y VG_POSTGRES
  1. Mount the /db filesystem ...

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.