Migrate from PostgreSQL on Amazon EC2 to Amazon RDS for PostgreSQL using pglogical
Created by Rajesh Madiwale (AWS)
Environment: PoC or pilot | Source: Amazon EC2 | Target: Amazon RDS for PostgreSQL |
R Type: Replatform | Workload: Open-source | Technologies: Migration; Databases |
AWS services: Amazon RDS |
Summary
This pattern outlines steps for migrating a PostgreSQL database (version 9.5 and later) from Amazon Elastic Compute Cloud (Amazon EC2) to Amazon Relational Database Service (Amazon RDS) for PostgreSQL by using the PostgreSQL pglogical extension. Amazon RDS now supports the pglogical extension for PostgreSQL version 10.
Prerequisites and limitations
Prerequisites
Choose the right type of Amazon RDS instance. For more information, see Amazon RDS Instance Types
. Make sure that the source and target versions of PostgreSQL are the same.
Install and integrate the pglogical extension with PostgreSQL
on Amazon EC2.
Product versions
PostgreSQL version 10 and later on Amazon RDS, with the features supported on Amazon RDS (see PostgreSQL on Amazon RDS in the AWS documentation). This pattern was tested by migrating PostgreSQL 9.5 to PostgreSQL version 10 on Amazon RDS, but it also applies to later versions of PostgreSQL on Amazon RDS.
Architecture
Data migration architecture
Tools
pglogical
extension PostgreSQL native utilities: pg_dump
and pg_restore
Epics
Task | Description | Skills required |
---|---|---|
Create an Amazon RDS PostgreSQL DB instance. | Set up a PostgreSQL DB instance in Amazon RDS. For instructions, see the Amazon RDS for PostgreSQL documentation. | DBA |
Obtain a schema dump from the source PostgreSQL database and restore it into the target PostgreSQL database. | DBA | |
Turn on logical decoding. | In the Amazon RDS DB parameter group, set the | DBA |
Create the pglogical extension on the source and target databases. |
| DBA |
Create a publisher on the source PostgreSQL database. | To create a publisher, run:
| DBA |
Create a replication set, add tables and sequences. | To create a replication set on the source PostgreSQL database, and to add tables and sequences to the replication set, run:
| DBA |
Create a subscriber. | To create a subscriber on the target PostgreSQL database, run:
| DBA |
Create a subscription. | To create a subscription on the target PostgreSQL database, run:
| DBA |
Task | Description | Skills required |
---|---|---|
Check source and target databases. | Check the source and target databases to confirm that data is being replicated successfully. You can perform basic validation by using | DBA |
Related resources
Logical replication for PostgreSQL on Amazon RDS (Amazon RDS documentation)
pglogical
(GitHub repository) Limitations of pglogical
(GitHub repository README file) Migrating PostgreSQL from on-premises or Amazon EC2 to Amazon RDS using logical replication
(AWS Database blog)