How to do logical replication on cascading standby server on postgres? - postgresql

Is it possible to enable logical replication on standby server which is in cascading replication mode?

According Debezium connector for PostgreSQL docs:
As of release 12, PostgreSQL allows logical replication slots only on primary servers. This means that you can point a Debezium PostgreSQL connector to only the active primary server of a database cluster. Also, replication slots themselves are not propagated to replicas. If the primary server goes down, a new primary must be promoted.
Note.
There are discussions in the PostgreSQL community around a feature called failover slots that would help mitigate this problem, but as of PostgreSQL 12, they have not been implemented.
This feature is not implemented for the latest PostgreSQL release 13.
https://debezium.io/documentation/reference/connectors/postgresql.html

Related

I want to set the Streaming replication between two different postgresql versions

my primary server is Postgresql-9.4 and the secondary server is Postgresql-13, I followed all the steps but while restarting the secondary server, I am facing the error "An old version of the database format was found. You need to dump and reload before using PostgreSQL 13." how I should resolve it.
You cannot have streaming replication between different PostgreSQL versions, and you cannot have logical replication with versions less than v10.
You will have to use trigger-based replication like with Slony-I.

WALs getting pilled up - restart_lsn of logical replication not moving in PostgreSQL

We have a replication setup from AWS RDS PostgreSQL to Kafka. The replication slot's restart_lsn is not moving and WALs keep pilling up.
I tried to remove all the Kafka replications and tried using logical replication and AWS DMS on the same postgreSQL instance, that too doesn't release it's position in WAL,Even though the changes are getting replicated to the target. Why replication slots are holding these WALs?

Is it possible to connect Debezium into Postgres slave in version above 9.6?

I found this limitation in Debezium documentation:
PostgreSQL 9.6 only supports logical replication slots on master servers. This means that a replica in a PostgreSQL cluster cannot be configured for logical replication, and consequently that the Debezium PostgreSQL Connector can only connect and communicate with the master server.
Is this limitation is also apply for PostgreSQL in versions above 9.6?
It is possible use Debezium with PostgreSQL slave in versions: 10.x and 11.x?
This limitation also exists in PostgreSQL 10 and 11. There are plans to remove it, but none have been committed so far.

Replication of AWS RDS Postgresql into On-Premise Postgresql

I have a requirement of replicate data from AWS RDS Postgres(9.6) Database to On-Premise Postgres(9.5) Database. I have found stuff about replication from On-premise to On-premise. But How can we implement it for AWS RDS to On-premise?
I do this using Bucardo.
Check-out this: https://bucardo.org/Bucardo/
With Bucardo you can replicate RDS postgres instance to a slave postgres present somewhere, only configuring slave, so without the needs to configure RDS stuff.
Also you can do this with zero downtime.
Anyway I am not sure this will work using different versions of Postgresql. You should use same version if possible. I tested it with 9.4.x and it is working.
UPDATE
I can confirm that this is working also using different version of Postgres, for example I was able to replicate with these versions:
AWS RDS postgresql 9.4.x
On-premise postgresql 9.6.x
http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_PostgreSQL.html#PostgreSQL.Concepts.General.FeatureSupport.LogicalReplication
Beginning with PostgreSQL version 9.4, PostgreSQL supports the
streaming of WAL changes using logical replication slots. Amazon RDS
supports logical replication for a PostgreSQL DB instance version
9.4.9 and higher and 9.5.4 and higher. Using logical replication, you can set up logical replication slots on your instance and stream
database changes through these slots to a client like pg_recvlogical.
Logical slots are created at the database level and support
replication connections to a single database.
mind possible problems eg https://dba.stackexchange.com/questions/173267/aws-rds-postgres-logical-replication

Postgres Replication Tools for DDL

Is there any tools for replication in postgres which can doing the following :
automatic DDL replication?
when master DB down, then slave will become the master DB immediately.
my company database is +- 5GB size
i have search some tools for replication which is slony and bucardo (and all trigger based replication system cannot doing the DDL replication)(source). and for 9.0 Streaming Replication (built in on postgres),Gabriel Weinberg (DuckDuckGo)said "Steve Signer wrote up some cases where you wouldn't want to/be able to use the built-in replication"
so 3 tools i found (slony,bucardo and 9.0 SR) , doesnt meet my criteria to do the postgres. is there any suggestion?
thanks
automatic DDL replication?
=> Use streaming replication, replicates everything.
when master DB down, then slave will become the master DB immediately.
=> pgPool does it's job over here, works fine.
my company database is +- 5GB size
=> That's very small, don't worry.
You can use debezium for replication transactions (insert, delete and update)... for ddl you can use kafka connect ;)