Note:

Migrate Amazon RDS for PostgreSQL Database to OCI Database with PostgreSQL using OCI GoldenGate

Introduction

Oracle Cloud Infrastructure Database with PostgreSQL (OCI Database with PostgreSQL) is a fully managed service that automatically scales storage as database tables are created or dropped. This simplifies management and optimizes storage costs for you. Data is encrypted both in-transit and at rest. OCI GoldenGate supports logical online migration enabling seamless transitions and near zero downtime migration for OCI Database with PostgreSQL service databases.

The following images shows the architecture for migrating an Amazon Relational Database Service PostgreSQL (Amazon RDS for PostgreSQL) database to OCI Database with PostgreSQL service using OCI GoldenGate, the pg_dump and the pg_restore utility.

OCI Database for PostgreSQL currently supports version 14 and 15. In this tutorial, we are using version 15. Metadata migration will be done using the pg_dump and pg_restore utility. Initial load and data replication will be done using OCI GoldenGate.

image

Note: Make sure connectivity is established between OCI GoldenGate deployment, source and target databases.

Objectives

Prerequisites

Task 1: Create Amazon RDS for PostgreSQL Instance

Log in to the AWS console and create RDS instance for PostgreSQL. Enter the required information as shown in the following images.

image

image

image

image

image

Task 2: Create Custom Parameter Group and Modify Required Parameter

Connect to RDS instance and go to the Configuration tab. Find DB instance parameter group, it should be set to default. Now, click Create parameter group to create separate parameter group and enter the required information as shown in the following images.

image

image

image

image

Task 3: Create OCI Database with PostgreSQL Database

Log in to the OCI Console and go to Databases and click Create database.

image

image

image

image

Task 4: Create OCI Compute Instance and Install PostgreSQL Client for Connectivity

We need to create OCI Compute instance in the OCI Console and install PostgreSQL using the following command.

sudo dnf install -y postgresql15*
psql --version

Task 5: Test Connectivity from OCI Compute Instance to both Source and Target

  1. Go to the AWS console and get the AWS Endpoint for connectivity.

    image

  2. Run the following command to connect to Amazon RDS for PostgreSQL instance.

    image

  3. Go to the OCI Console and get the OCI Database with PostgreSQL Endpoint for connectivity.

    image

  4. Run the following command to connect to OCI Database with PostgreSQL instance.

    image

Task 6: Create OCI GoldenGate Deployment and Test Connection

  1. Go to the OCI Console and navigate to Oracle Database and click GoldenGate to create OCI GoldenGate deployment.

    image

  2. Enter the following information and ensure to Select a technology as PostgreSQL.

    image

  3. Select Compartment and private subnet as Subnet. To access the deployment console, make sure you enable public access. This needs to be enabled during deployment creation, else it will be disabled.

    image

  4. Click Create password secret to create password secret in advance. OCI GoldenGate deployment asks for secret instead of plain text password during creation.

    image

    Deployment should be available after creation.

    image

  5. Create connection for both Amazon RDS for PostgreSQL and OCI Database with PostgreSQL databases using the required information as shown in the following images.

    image

    image

    image

    image

  6. Assign these connections to OCI GoldenGate deployment under Assigned connection and test the connection if they are successful.

    image

    image

    image

Task 7: Migrate Schema Metadata from Amazon RDS for PostgreSQL Instance to OCI Database with PostgreSQL

We are using one test schema for testing migration.

  1. Run the pg_dump command to take metadata schema export.

    image

    image

  2. Run the following command to restore this metadata dump to target OCI Database with PostgreSQL database.

    image

  3. Run the following command to check if all objects are created in the target database.

    image

Task 8: Configure OCI GoldenGate Extract and Replicat Process for Migration

  1. Go to the OCI GoldenGate Console, navigate to Administration and click Extracts to create initial load extract process.

    image

  2. In Add Extract, select source as File and Initial load require file as Source type.

    image

    image

  3. Enter and modify the parameter file for filename from 3 character to 2 as Replicat parameter supports 2 character only.

    image

  4. Create extract process for delta sync and register it using the required information as shown in the following images.

    image

    image

  5. Start initial load extract process and check the report file for initial load and LSN.

    image

    image

  6. Start Change Data Capture (CDC) process with the Commit Sequence Number (CSN) obtained from initial load extract.

    image

    image

  7. Create and start Replicate process for initial load using the required information as shown in the following images.

    image

    image

    image

    image

  8. Check report of initial report Replicat process.

    image

  9. Create replicate for data sync after initial load and start using the required information as shown in the following images.

    image

    image

    image

    image

  10. Run the following commands to check on the source and target if data is getting replicated.

    image

    image

    image

    image

    image

Task 9: Issues and Troubleshooting

Acknowledgments

More Learning Resources

Explore other labs on docs.oracle.com/learn or access more free learning content on the Oracle Learning YouTube channel. Additionally, visit education.oracle.com/learning-explorer to become an Oracle Learning Explorer.

For product documentation, visit Oracle Help Center.