PostgreSQL Replication – Replicating Multiple Instances to One Standby Host

postgresqlreplicationrepmgr

My setup has 2 Postgres hosts:

  • host SRV1 as primary with 2 instances and IP 192.168.1.241

    • Instance A listening on port 5432
    • Instance B listening on port 5433
  • host SRV2 as standby with instance C and IP 192.168.1.243 using default port.

I'd configured sucessfully replication from instace A to instance C using repmgr.

I'm using PostgreSQL 10 and rempgr 4.

How could I configure replication from new instances, e.g. B, to a new instance on host SRV2 (standby) using repmgr?

Best Answer

You can do that , just treat your instances as if they where separate nodes. In your case you will end up with 3 instances on the standby server.

In repmgr you will need to create a cluster for A, B and C. Let's call them CA, CB and CC, then you start by adding the nodes A and B and C as a primary node. Your layout on SRV2 will have to allow those instances to live next to eachother. Since you don't really mention what OS/flavor you are using it's hard to give specific advice there.

afaik you will most probably need to run several repmgr daemons if you use them in conjunction with different repmgr.conf config files which is probably the biggest hassle.

CORRECTIONS:

I seem to have misunderstood it a bit, you seem to have 2 clusters, with 4 instances (3 existing and 1 pending), Instances SRV1/A + SRV2/C make up cluster CA , then you just need to add instance D to cluster SRV1/B , making SRV1B + SRV2/D cluster number 2. In any case, you need 2 repmgr.conf files, I've checked the docs and it never talks about multiple cluster support. But nothing would stop you from running 2 repmgrd deamons with different config files.