Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 920
YogeshR Avatar asked Sep 26 '17 05:09

YogeshR


People also ask

Can RDS replicate to on premise?

To migrate data from Amazon RDS for MySQL to an on-premises database server, first create a read replica on AWS. Then, switch the replication target from the Amazon RDS for MySQL read replica to the on-premises server.

Can PostgreSQL be replicated?

In PostgreSQL, there are two types of replication features: streaming replication (physical replication) that collectively replicates a database cluster, and logical replication that replicates in units of tables and databases.

How do you replicate an RDS database?

Using the following 3 methods you can set up Replication in AWS RDS easily in real-time: Method 1: Using Multi-AZ (Availability Zone) for RDS Replication. Method 2: Using Read Replicas for RDS Replication. Method 3: Using Hevo Data for RDS Replication.

Can PostgreSQL be replicated across regions?

Most read-heavy, PostgreSQL-backed applications work natively across regions on Fly.io, no architectural changes required. Deploying an app and database in multiple regions takes advantage of two Fly features: Regional read replicas.


2 Answers

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

like image 150
Vao Tsun Avatar answered Oct 28 '22 13:10

Vao Tsun


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
like image 38
Diego D Avatar answered Oct 28 '22 14:10

Diego D