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.
| Database | Type | Default port |
|---|---|---|
| MySQL | mysql-cdc | 3306 |
| PostgreSQL | postgres-cdc | 5432 |
| Oracle | oracle-cdc | 1521 |
| SQL Server | sqlserver-cdc | 1433 |
| Db2 | db2-cdc | 50000 |
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
| Property | Description |
|---|---|
connector | The type of the connector, from the previous table. |
hostname | The hostname or IP address of the database. |
username | The user that reads the change log. |
password | The password of the user. |
database-name | The database to read. For MySQL, you can use a regular expression. |
schema-name | The schema to read. It does not apply to MySQL. |
table-name | The table to read. You can use a regular expression. |
Optional properties
| Property | Types | Description |
|---|---|---|
port | All | The port of the database. |
scan.startup.mode | PostgreSQL, Oracle, SQL Server, Db2 | Where the source starts. The default is initial, which reads a snapshot and then the changes. |
slot.name | PostgreSQL | The name of the replication slot. Use a different name for each table or job. The template default is flink. |
decoding.plugin.name | PostgreSQL | The logical decoding plugin of the database. The template default is decoderbufs. Use pgoutput for a database that does not have decoderbufs. |
server-id | MySQL | A number or range of numbers that is unique among the clients of the database. |
server-time-zone | MySQL, Oracle | The time zone of the database. The default is UTC. |
scan.incremental.snapshot.enabled | MySQL | Whether the snapshot is read in parallel chunks. |
scan.startup.specific-offset.file and scan.startup.specific-offset.pos | MySQL | The binary log file and the position where the source starts. |
scan.startup.timestamp-millis | MySQL | The time in epoch milliseconds where the source starts. |
debezium.* | All | Any 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
ROWformat, and give the user the privilegesSELECT,RELOAD,SHOW DATABASES,REPLICATION SLAVE, andREPLICATION CLIENT. - PostgreSQL: Set
wal_leveltological, give the user theREPLICATIONattribute, and set the replica identity of the table toFULLif 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.
