Configure an Amazon RDS PostgreSQL database for CDC Stay organized with collections Save and categorize content based on your preferences.
This page describes how to configure change data capture (CDC) tostream data from an Amazon RDS for PostgreSQL database to asupported destination,such as BigQuery or Cloud Storage.
Create a parameter group
Launch your Amazon RDS Dashboard.
In theNavigation Drawer, clickParameter Groups, and then clickCreate Parameter Group. TheCreate Parameter Group page appears.
Select the database family that matches your database, provide a name and description for the parameter group, and then clickCreate.
Select the checkbox to the left of your newly created parameter group, and then, underParameter group actions, clickEdit.
Set the following parameter for your group.
Parameter Value rds.logical_replication 1ClickSave Changes.
For PostgreSQL 13 and later, it is recommended that you also set themax_slot_wal_keep_sizeparameter in thepostgresql.conffile to limit the amount of storage used by replication slots. For more information, seeWork with PostgreSQL database WAL log files.
Configure the source database
Launch your Amazon RDS Dashboard.
In theNavigation Drawer, clickDatabases.
Select your source, and then clickModify.
Go to theAdditional configuration section.
Select the parameter group that youcreated.
ClickContinue.
UnderScheduling of modifications, selectApply immediately.
Because you modified your source, you must wait until the changes to your parameter group are applied before proceeding.
Verify that the parameter group is assigned to the database instance
Launch your Amazon RDS Dashboard.
In theNavigation Drawer, clickDatabases, and then select your database instance.
Click theConfigurations tab.
Verify that you see the parameter group that youcreated, and that its status ispending-reboot.
Reboot your database instance to complete the configuration. To reboot the instance:
- In theNavigation Drawer, clickInstances.
- Select your database instance.
- From theInstance Actions menu, selectReboot.
Create a publication and a replication slot
Create a publication. We recommend that you create a publication only for thetables that you want to replicate. This allows Datastream to read-onlythe relevant data, and lowers the load on the database and Datastream:
CREATE PUBLICATIONPUBLICATION_NAMEFOR TABLESCHEMA1.TABLE1,SCHEMA2.TABLE2;
Replace the following:
- PUBLICATION_NAME: The name of your publication. You'llneed to provide this name when you create a stream in the Datastreamstream creation wizard.
- SCHEMA: The name of the schema that contains the table.
- TABLE: The name of the table that you want to replicate.
You can also create a publication for all tables in your database. Note thatthis approach increases the load on both the source database and Datastream:
For PostgreSQL 15 and later, you can create a publication for all tablesin a schema. This approach lets you replicate changes for tables in thespecified list of schemas, including tables that you create in the future:CREATE PUBLICATIONPUBLICATION_NAME FOR ALL TABLES;
CREATE PUBLICATIONPUBLICATION_NAMEFOR TABLES IN SCHEMASCHEMA1,SCHEMA2;
Create a replication slot by entering the following PostgreSQL command:
SELECT PG_CREATE_LOGICAL_REPLICATION_SLOT('REPLICATION_SLOT_NAME', 'pgoutput');Replace the following:
- REPLICATION_SLOT_NAME: The name of your replication slot. You'llneed to provide this name when you create a stream in the Datastreamstream creation wizard.
Create a Datastream user
To create a Datastream user, enter the following PostgreSQL command:
CREATE USERUSER_NAME WITH ENCRYPTED PASSWORD 'USER_PASSWORD';
Replace the following:
- USER_NAME: The name of the Datastream user that youwant to create.
- USER_PASSWORD: The login password for the Datastreamuser that you want to create.
Grant the following privileges to the user you created:
GRANT RDS_REPLICATION TOUSER_NAME;GRANT SELECT ON ALL TABLES IN SCHEMASCHEMA_NAME TOUSER_NAME;GRANT USAGE ON SCHEMASCHEMA_NAME TOUSER_NAME;ALTER DEFAULT PRIVILEGES IN SCHEMASCHEMA_NAME GRANT SELECT ON TABLES TOUSER_NAME;
Replace the following:
- USER_NAME: The user to whom you want to grant the privileges.
- SCHEMA_NAME: The name of the schema to which you want to grantthe privileges.
What's next
- Learn more about how Datastream works withPostgreSQL sources.
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-12-15 UTC.