CDC connectors

The CDC connectors are based on Flink CDC 3.7.0. They read the change log of a database and produce a changelog stream. A CDC table is a source only.

Table 1. CDC connector types
DatabaseTypeDefault port
MySQLmysql-cdc3306
PostgreSQLpostgres-cdc5432
Oracleoracle-cdc1521
SQL Serversqlserver-cdc1433
Db2db2-cdc50000

Example

The following example creates a table for a PostgreSQL table:

CREATE TABLE customers_cdc (
  id INT,
  name STRING,
  country STRING,
  PRIMARY KEY (id) NOT ENFORCED
) WITH (
  'connector' = 'postgres-cdc',
  'hostname' = '<database-host>',
  'port' = '5432',
  'username' = '<user>',
  'password' = '<password>',
  'database-name' = 'shop',
  'schema-name' = 'public',
  'table-name' = 'customers',
  'slot.name' = 'ssb_customers',
  'decoding.plugin.name' = 'pgoutput'
);

Mandatory properties

Table 2. Mandatory properties of the CDC connectors
PropertyDescription
connectorThe type of the connector, from the previous table.
hostnameThe hostname or IP address of the database.
usernameThe user that reads the change log.
passwordThe password of the user.
database-nameThe database to read. For MySQL, you can use a regular expression.
schema-nameThe schema to read. It does not apply to MySQL.
table-nameThe table to read. You can use a regular expression.

Optional properties

Table 3. Optional properties of the CDC connectors
PropertyTypesDescription
portAllThe port of the database.
scan.startup.modePostgreSQL, Oracle, SQL Server, Db2Where the source starts. The default is initial, which reads a snapshot and then the changes.
slot.namePostgreSQLThe name of the replication slot. Use a different name for each table or job. The template default is flink.
decoding.plugin.namePostgreSQLThe logical decoding plugin of the database. The template default is decoderbufs. Use pgoutput for a database that does not have decoderbufs.
server-idMySQLA number or range of numbers that is unique among the clients of the database.
server-time-zoneMySQL, OracleThe time zone of the database. The default is UTC.
scan.incremental.snapshot.enabledMySQLWhether the snapshot is read in parallel chunks.
scan.startup.specific-offset.file and scan.startup.specific-offset.posMySQLThe binary log file and the position where the source starts.
scan.startup.timestamp-millisMySQLThe time in epoch milliseconds where the source starts.
debezium.*AllAny Debezium property, for example debezium.snapshot.mode.

Prerequisites in the database

Prepare the database before you run a job. For the complete steps, see the Debezium documentation for your database. The main steps are as follows:

  • MySQL: Turn on the binary log in ROW format, and give the user the privileges SELECT, RELOAD, SHOW DATABASES, REPLICATION SLAVE, and REPLICATION CLIENT.
  • PostgreSQL: Set wal_level to logical, give the user the REPLICATION attribute, and set the replica identity of the table to FULL if you need the old values of updates and deletes.
  • Oracle: Turn on archive log mode and supplemental logging, and give the user the privileges for LogMiner.
  • SQL Server: Turn on CDC for the database and for each table.
  • Db2: Turn on the capture of changes for the table.