How to do it...

As with all of the previous recipes 192.168.56.10 is our origin server and 192.168.56.30 will remain our replication subscriber. Execute all commands in this recipe as the postgres system user. Follow these steps to copy the sample pgbench tables:

  1. Extract the table creation statements from the primary node with the following command:
        pg_dump -s -t 'pgbench*' postgres > /tmp/tables.sql
  1. Create the empty tables on the subscriber node by executing this command on the primary node:
        psql -U rep_user -h 192.168.56.30 -f /tmp/tables.sql postgres
  1. Execute this SQL on the primary server to create a replication set:
        SELECT pglogical.create_replication_set(set_name := 'pgbench',
     replicate_insert := TRUE, replicate_update := ...

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.