Enable CDC for PostgreSQL

Enable CDC for PostgreSQL with Patroni

# Check cluster
/usr/local/bin/patronictl -c /etc/patroni/patroni.yml list
 
# Edit configuration
/usr/local/bin/patronictl -c /etc/patroni/patroni.yml edit-config

Add a permanent slot:

slots:
  permanent_logical_slot_<db name>:
    database: <db name>
    plugin: pgoutput
    type: logical

Exit text editor and validate change.

# Check if a reboot is required
/usr/local/bin/patronictl -c /etc/patroni/patroni.yml list
 
# Restart the cluster
/usr/local/bin/patronictl -c /etc/patroni/patroni.yml restart <cluster-name>
 
# Check cluster
/usr/local/bin/patronictl -c /etc/patroni/patroni.yml list
 
# Check log
tail -f /data/postgres/pg_log/postgresql-*.log

Create a PostgreSQL user for accessing the database:

GRANT CREATE ON DATABASE <db> TO debezium;
 
-- connect to correct database
\c <db name> --switch to correct db
GRANT ALL ON SCHEMA public TO debezium_group;
 
GRANT debezium_group TO <current object owner>;

Validate the replication slots and publication:

-- check output of the command
\c postgres
select * from pg_replication_slots;
 
\c <db name>
select * from pg_publication;
select * from pg_publication_tables;



    Enjoy Reading This Article?

    Here are some more articles you might like to read next:

  • KakfaConnect SQL Server configuration
  • KakfaConnect MariaDB configuration
  • access a kafka topic with kafka-console-consumer
  • Enable CDC for Oracle
  • How to change Kafka SSL certificat in OpenShift (AMQ Streams)