Skip to main content
Version: 2.3.0

MySQL CDC

MySQL CDC source connector

Description

The MySQL CDC connector allows for reading snapshot data and incremental data from MySQL database. This document describes how to setup the MySQL CDC connector to run SQL queries against MySQL databases.

Key features

Options

nametyperequireddefault value
hostnameStringYes-
portIntegerNo3306
usernameStringYes-
passwordStringYes-
database-nameStringYes-
table-nameStringYes-
base-urlStringYes-
startup.modeEnumNoINITIAL
startup.timestampLongNo-
startup.specific-offset.fileStringNo-
startup.specific-offset.posLongNo-
stop.modeEnumNoNEVER
stop.timestampLongNo-
stop.specific-offset.fileStringNo-
stop.specific-offset.posLongNo-
incremental.parallelismIntegerNo1
snapshot.split.sizeIntegerNo8096
snapshot.fetch.sizeIntegerNo1024
server-idStringNo-
server-time-zoneStringNoUTC
connect.timeoutDurationNo30s
connect.max-retriesIntegerNo3
connection.pool.sizeIntegerNo20
chunk-key.even-distribution.factor.upper-boundDoubleNo1000
chunk-key.even-distribution.factor.lower-boundDoubleNo0.05
debezium.*configNo-
common-optionsno-

hostname [String]

IP address or hostname of the database server.

port [Integer]

Integer port number of the database server.

username [String]

Name of the database to use when connecting to the database server.

password [String]

Password to use when connecting to the database server.

database-name [String]

Database name of the database to monitor.

table-name [String]

Table name of the database to monitor.

base-url [String]

URL has to be without database, like "jdbc:mysql://localhost:5432/" or "jdbc:mariadb://localhost:5432" rather than " jdbc:polardb://localhost:5432/db"

startup.mode [Enum]

Optional startup mode for MySQL CDC consumer, valid enumerations are "initial", "earliest", "latest" and "specific".

startup.timestamp [Long]

Start from the specified epoch timestamp (in milliseconds).

Note, This option is required when the "startup.mode" option used 'timestamp'.

startup.specific-offset.file [String]

Start from the specified binlog file name.

Note, This option is required when the "startup.mode" option used 'specific'.

startup.specific-offset.pos [Long]

Start from the specified binlog file position.

Note, This option is required when the "startup.mode" option used 'specific'.

stop.mode [Enum]

Optional stop mode for MySQL CDC consumer, valid enumerations are "never".

stop.timestamp [Long]

Stop from the specified epoch timestamp (in milliseconds).

Note, This option is required when the "stop.mode" option used 'timestamp'.

stop.specific-offset.file [String]

Stop from the specified binlog file name.

Note, This option is required when the "stop.mode" option used 'specific'.

stop.specific-offset.pos [Long]

Stop from the specified binlog file position.

Note, This option is required when the "stop.mode" option used 'specific'.

incremental.parallelism [Integer]

The number of parallel readers in the incremental phase.

snapshot.split.size [Integer]

The split size (number of rows) of table snapshot, captured tables are split into multiple splits when read the snapshot of table.

snapshot.fetch.size [Integer]

The maximum fetch size for per poll when read table snapshot.

server-id [String]

A numeric ID or a numeric ID range of this database client, The numeric ID syntax is like '5400', the numeric ID range syntax is like '5400-5408'.

Every ID must be unique across all currently-running database processes in the MySQL cluster. This connector joins the MySQL cluster as another server (with this unique ID) so it can read the binlog.

By default, a random number is generated between 5400 and 6400, though we recommend setting an explicit value.

server-time-zone [String]

The session time zone in database server.

connect.timeout [Duration]

The maximum time that the connector should wait after trying to connect to the database server before timing out.

connect.max-retries [Integer]

The max retry times that the connector should retry to build database server connection.

connection.pool.size [Integer]

The connection pool size.

debezium [Config]

Pass-through Debezium's properties to Debezium Embedded Engine which is used to capture data changes from MySQL server.

See more about the Debezium's MySQL Connector properties

example

source {
MySQL-CDC {
debezium {
snapshot.mode = "never"
decimal.handling.mode = "double"
}
}
}

common options

Source plugin common parameters, please refer to Source Common Options for details.

Example

source {
MySQL-CDC {
result_table_name = "fake"
parallelism = 1
server-id = 5656
port = 56725
hostname = "127.0.0.1"
username = "mysqluser"
password = "mysqlpw"
database-name = "inventory_vwyw0n"
table-name = "products"
base-url = "jdbc:mysql://localhost:56725"
}
}

Changelog

2.3.0 2022-12-30

  • Add MySQL CDC Source Connector