Postgresql – Postgres 9.6 Physical and Logical replication

clusteringpostgresqlreplication

I am working with Postgres9.6 with a Master/Slave cluster replication using Streaming replication (physical).

I would like to add a new Slave server database but this database with logical replication.

I tried with some configurations but it was not possible 🙁
https://github.com/guedim/postgres-streaming-replication

Here is the image of what is in my mind:

Added picture inline

Best Answer

I would suggest having the same wal_level on all servers, as as it defines the amount of information you will have when WAL is created (on the primary, these files are then streamed to the standbys).

The available wal_level settings (with each setting writing more information to each WAL, as well as all that of lower levels) from low to high are:

  • minimal
  • replica (older values archive and hot_standby are mapped to this)
  • logical

In this case I would set wal_level = logical for all. As WAL is only created in one place this won't hurt, and it has the added benefit of keeping working if you ever promote a standby to a master.

You mention hot_standby in the diagram, this has now been renamed replica (although both still work).

Other than that this topology should be fine, we use something like this - although you have logical replication from the standby, you'll need to move this to coming from the master. There was a rejected patch to allow this to come from a standby in PostgreSQL 10, hopefully this comes through in PostgreSQL 11.