1

Is it possible in PostgreSQL to set up the following replication scenarios?

  1. Replication between 2 servers with different database name. For example, replicate FROM server_A (primary) database name primary_product TO server_B (slave) database name primary_product_analytics

  2. Replication between 2 servers which consist of several databases in Server_A, need to be transferred into single database with multiple schemas (custom schema name) on Server_B.

I have successfully setup replication using WAL but I would like guidance on implementing the above scenarios if possible.

1 Answer 1

4

WAL-based replication is physical replication, i.e., it replicates all the changes made on the disk of a database cluster. In other words, all databases and their contents are exactly the same.

If you want replicate with different database names, you can use logical replication, which replicates changes made to specified tables.

However, logical replication cannot change the schema name. If you want to copy changes to a table in a different schema, you could do it manually with triggers and postgres_fdw.

2
  • Can please you elaborate on how to "do it manually with triggers and postgres_fdw"? Commented Mar 24, 2022 at 18:00
  • @GunarGessner "Manually" means that you have to write and add triggers for every operation on every table.
    – CL.
    Commented Mar 24, 2022 at 19:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.