How to do it...

For this recipe, 192.168.56.30 will remain our subscriber. Follow these instructions to copy the pgbench tables and all future changes from pg1 to pg2:

  1. Extract the table creation statements from the primary database with the following command as the postgres user:
        pg_dump -s -t 'pgbench*' postgres > /tmp/tables.sql
  1. Create the empty tables on the subscriber node by executing this command as the postgres user on the primary node:
        psql -U rep_user -h 192.168.56.30 -f /tmp/tables.sql postgres
  1. Confirm that the tables exist on the subscriber node by executing the following SQL statement on that system:
        SELECT schemaname, tablename FROM pg_tables
          WHERE tablename LIKE 'pgbench%';
  1. Create a file named pgbench_set.slonik ...

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.