How to do it...

For this, we will assume pg1 is our current primary node and VG_POSTGRES/LV_DATA is the principal data volume. Follow these steps as the root user to create and use an LVM snapshot:

  1. Create the snapshot with lvcreate:
        lvcreate -l 100%FREE -s -n snap VG_POSTGRES/LV_DATA
  1. Create a directory on which to mount the snapshot using this command:
        mkdir /mnt/db_snap
  1. Mount the snapshot as a regular XFS filesystem using this command:
        mount -t xfs -o nouuid /dev/VG_POSTGRES/snap /mnt/db_snap
  1. Enter the snapshot pgdata directory using this command:
        cd /mnt/db_snap/pgdata
  1. Examine snapshot information with lvdisplay:
        lvdisplay VG_POSTGRES/snap | grep snap

 

Follow these steps as the root user to unmount and remove an LVM ...

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.