How it works...

After the last few extensions, using pglogical is almost refreshingly easy. As usual, we start by copying the pgbench table definitions from the origin node to the subscriber. Once that is done, the primary node has only one job: create a subscription set.

The subscription set we create is named pgbench to fit the theme of copying multiple pgbench tables. When defining a replication set with the create_replication_set function, we actually have a few options here that the other replication systems did not offer. In this example, we elected to only replicate INSERT and UPDATE statements. In this scenario, the primary server can delete records from the table, or truncate it entirely, and the copy on the subscriber will remain. ...

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.