CDC - PostgreSQL Setup Documentation
How to setup CDC PostgreSQL
Prerequisites
To setup CDC between your PostgreSQL database and Peaka Big Table, you need:
- PostgreSQL version 10+
- PostgreSQL administrative permissions.
Setup Instructions
Setting up permissions
Create a database user for Peaka’s exclusive use that can perform replication.
( Although, by default, superusers have the necessary REPLICATION and LOGINroles, you can create another user that has the minimum required privileges. )
- To provide a user with replication permissions, define a PostgreSQL role that has at least the REPLICATION and LOGIN permissions, and then grant that role to the user. For example:
CREATE ROLE <role> REPLICATION LOGIN;
Configure the PostgreSQL server to logical replication with the pgoutput plugin
-
Set the wal_level parameter in your database configuration to logical. For a standard PostgreSQL database, do this by adding a wal_level = logical line to the postgresql.conf file. Restart the server for this change to take effect.
-
Ensure that your max_replication_slots value is equal to or higher than the number of PostgreSQL connectors that use WAL plus the number of other replication slots your database uses.
-
Create a publication for your tables.
- If the user you provide the Peaka connection with has superuser permissions, the publication is created at start-up automatically, if it does not already exist.
b. You can create a publication for all of your tables.
CREATE PUBLICATION <publication_name> FOR ALL TABLES;
c. Alternatively, you can create a publication for only tables under the cached schema.
CREATE PUBLICATION <publication_name> FOR TABLES IN SCHEMA <schema_name>;
-
Create a logical replication slot (Optional)
SELECT pg_create_logical_replication_slot(<slot_name>, 'pgoutput');
Note: since a replication slot can only be used by a single connector, it is essential to create a unique replication slot for each CDC connection.