How to do it...

For the purposes of this recipe, we will assume that the /dev/VG_DRBD/LV_DATA device already exists. The two PostgreSQL nodes for this example are named pg1 and pg2 and are located on the 192.168.56.0 subnet. Follow these steps as the root user on each server to add DRBD:

  1. Create a file named /etc/drbd.d/pg.res with the following contents:
        resource pg { 
          device minor 0; 
          disk /dev/VG_DRBD/LV_DATA; 
          meta-disk internal; 
          on pg1 { 
            address 192.168.56.10:7788; 
          } 
         on pg2 { 
           address 192.168.56.20:7788; 
          } 
        } 
  1. Allocate the DRBD storage with this command:
        drbdadm create-md pg
  1. Restart the DRBD service:
        service drbd restart
  1. Use drbdadm on pg1 to invalidate the data on pg2:
        drbdadm invalidate-remote pg
  1. View the status of DRBD from ...

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.