Skip to main content
Feedback

Google Cloud PostgreSQL CDC setup guide

Google Cloud SQL is a fully managed database service that streamlines the setup, maintenance, management, and administration of relational databases on the Google Cloud Platform (GCP). With the capability of Change Data Capture (CDC), Cloud SQL enables you to capture and replicate data changes in real-time from your database instances. This feature can be enabled by configuring logical decoding within your Cloud SQL instances.

You can set up and configure logical decoding in Cloud SQL, empowering you to harness the full potential of real-time data replication.

Prerequisites

  • Make sure you are running PostgreSQL 10 or higher.
  • Server and Database permissions to change server configuration (depending on the PostgreSQL cloud/on-prem provider).

Step 1: open Cloud SQL

To configure logical decoding in Cloud SQL, log in to your GCP project and go to the Cloud SQL page.

Step 2: choose the Cloud SQL instances

Choose the Cloud SQL instances that you want to connect to CDC. Open the instance and click Edit.

Step 3: add a flag for logical decoding

Navigate to the Flags section, and select Add Flag. Set up the cloudsql.logical_decoding flag to enable seamless logical WAL level in the background. Also, ensure that the wal_sender_timeout is set to 0 to establish a reliable connection when routing our CDC to a Google Cloud SQL Postgres server.

Step 4: Restart the Cloud SQL instance

After setting up the logical decoding flag, restart the Cloud SQL instance.

Step 5: Create SQL replication user

To enable replication slots, the REPLICATION role must grant permission to the Data Integration user. If the server does not have a REPLICATION role, create one with the following SQL command:

note

The <replication_role_name> must be replaced with a role name of your choice.

CREATE ROLE `<replication_role_name>` REPLICATION LOGIN;

After creating the role, execute the following SQL command to create a new login for Data Integration Log-Based extraction if it does not exist:

CREATE USER data_integration WITH `<replication_role_name>`;

In case the Data Integration user already exists, use the following SQL command to assign the new role to the user:

ALTER USER data_integration WITH `<replication_role_name>`;

Connect to Data Integration

Follow the PostgreSQL Connection documentation to connect to the Data Integration console.

On this Page