From 2088f89ed89540e12f4443d4ee98bbff2cc3ca82 Mon Sep 17 00:00:00 2001 From: Jiabao Sun Date: Thu, 7 Dec 2023 11:18:37 +0800 Subject: [PATCH] [3.0][docs] Add documents for MySql pipeline connector (#2827) --- docs/content/connectors/mongodb-cdc(ZH).md | 3 +- docs/content/connectors/mongodb-cdc.md | 6 +- docs/content/connectors/mysql-cdc(ZH).md | 7 +- docs/content/connectors/mysql-cdc.md | 8 +- docs/content/connectors/oceanbase-cdc.md | 2 +- docs/content/connectors/oracle-cdc.md | 6 +- docs/content/connectors/postgres-cdc.md | 11 + docs/content/connectors/sqlserver-cdc.md | 6 +- docs/content/pipelines/index.md | 8 + docs/content/pipelines/mysql-pipeline(ZH).md | 540 ++++++++++++++++++ docs/content/pipelines/mysql-pipeline.md | 547 +++++++++++++++++++ docs/index.md | 1 + 12 files changed, 1135 insertions(+), 10 deletions(-) create mode 100644 docs/content/pipelines/index.md create mode 100644 docs/content/pipelines/mysql-pipeline(ZH).md create mode 100644 docs/content/pipelines/mysql-pipeline.md diff --git a/docs/content/connectors/mongodb-cdc(ZH).md b/docs/content/connectors/mongodb-cdc(ZH).md index 0b2e29181..baea53a3a 100644 --- a/docs/content/connectors/mongodb-cdc(ZH).md +++ b/docs/content/connectors/mongodb-cdc(ZH).md @@ -282,7 +282,8 @@ upstart 流需要一个唯一的密钥,所以我们必须声明 `_id` 作为 optional false Boolean - 是否在快照结束后关闭空闲的 Reader。 此特性需要 flink 版本大于等于 1.14 并且 'execution.checkpointing.checkpoints-after-tasks-finish.enabled' 需要设置为 true。 + 是否在快照结束后关闭空闲的 Reader。 此特性需要 flink 版本大于等于 1.14 并且 'execution.checkpointing.checkpoints-after-tasks-finish.enabled' 需要设置为 true。
+ 若 flink 版本大于等于 1.15,'execution.checkpointing.checkpoints-after-tasks-finish.enabled' 默认值变更为 true,可以不用显式配置 'execution.checkpointing.checkpoints-after-tasks-finish.enabled' = true。 scan.cursor.no-timeout diff --git a/docs/content/connectors/mongodb-cdc.md b/docs/content/connectors/mongodb-cdc.md index 6b7aa2560..abf10d238 100644 --- a/docs/content/connectors/mongodb-cdc.md +++ b/docs/content/connectors/mongodb-cdc.md @@ -288,7 +288,11 @@ Connector Options optional false Boolean - Whether to close idle readers at the end of the snapshot phase. The flink version is required to be greater than or equal to 1.14 when 'execution.checkpointing.checkpoints-after-tasks-finish.enabled' is set to true. + Whether to close idle readers at the end of the snapshot phase.
+ The flink version is required to be greater than or equal to 1.14 when 'execution.checkpointing.checkpoints-after-tasks-finish.enabled' is set to true.
+ If the flink version is greater than or equal to 1.15, the default value of 'execution.checkpointing.checkpoints-after-tasks-finish.enabled' has been changed to true, + so it does not need to be explicitly configured 'execution.checkpointing.checkpoints-after-tasks-finish.enabled' = 'true' + scan.cursor.no-timeout diff --git a/docs/content/connectors/mysql-cdc(ZH).md b/docs/content/connectors/mysql-cdc(ZH).md index 9f4514498..bd8e1036e 100644 --- a/docs/content/connectors/mysql-cdc(ZH).md +++ b/docs/content/connectors/mysql-cdc(ZH).md @@ -314,7 +314,7 @@ Flink SQL> SELECT * FROM orders; (none) String 将 Debezium 的属性传递给 Debezium 嵌入式引擎,该引擎用于从 MySQL 服务器捕获数据更改。 - For example: 'debezium.snapshot.mode' = 'never'. + 例如: 'debezium.snapshot.mode' = 'never'. 查看更多关于 Debezium 的 MySQL 连接器属性 @@ -322,7 +322,8 @@ Flink SQL> SELECT * FROM orders; optional false Boolean - 是否在快照结束后关闭空闲的 Reader。 此特性需要 flink 版本大于等于 1.14 并且 'execution.checkpointing.checkpoints-after-tasks-finish.enabled' 需要设置为 true。 + 是否在快照结束后关闭空闲的 Reader。 此特性需要 flink 版本大于等于 1.14 并且 'execution.checkpointing.checkpoints-after-tasks-finish.enabled' 需要设置为 true。
+ 若 flink 版本大于等于 1.15,'execution.checkpointing.checkpoints-after-tasks-finish.enabled' 默认值变更为 true,可以不用显式配置 'execution.checkpointing.checkpoints-after-tasks-finish.enabled' = true。 debezium.binary.handling.mode @@ -908,7 +909,7 @@ CREATE TABLE products ( BIT(n) - BINARY(⌈n/8⌉) + BINARY(⌈(n + 7) / 8⌉) diff --git a/docs/content/connectors/mysql-cdc.md b/docs/content/connectors/mysql-cdc.md index 79be00ba2..cd2bd371c 100644 --- a/docs/content/connectors/mysql-cdc.md +++ b/docs/content/connectors/mysql-cdc.md @@ -327,7 +327,11 @@ During a snapshot operation, the connector will query each included table to pro optional false Boolean - Whether to close idle readers at the end of the snapshot phase. The flink version is required to be greater than or equal to 1.14 when 'execution.checkpointing.checkpoints-after-tasks-finish.enabled' is set to true. + Whether to close idle readers at the end of the snapshot phase.
+ The flink version is required to be greater than or equal to 1.14 when 'execution.checkpointing.checkpoints-after-tasks-finish.enabled' is set to true.
+ If the flink version is greater than or equal to 1.15, the default value of 'execution.checkpointing.checkpoints-after-tasks-finish.enabled' has been changed to true, + so it does not need to be explicitly configured 'execution.checkpointing.checkpoints-after-tasks-finish.enabled' = 'true' + debezium.binary.handling.mode @@ -920,7 +924,7 @@ Data Type Mapping BIT(n) - BINARY(⌈n/8⌉) + BINARY(⌈(n + 7) / 8⌉) diff --git a/docs/content/connectors/oceanbase-cdc.md b/docs/content/connectors/oceanbase-cdc.md index 57ae96123..e421df6fd 100644 --- a/docs/content/connectors/oceanbase-cdc.md +++ b/docs/content/connectors/oceanbase-cdc.md @@ -614,7 +614,7 @@ Data Type Mapping BIT(n) - BINARY(⌈n/8⌉) + BINARY(⌈(n + 7) / 8⌉) diff --git a/docs/content/connectors/oracle-cdc.md b/docs/content/connectors/oracle-cdc.md index 24a639622..470805372 100644 --- a/docs/content/connectors/oracle-cdc.md +++ b/docs/content/connectors/oracle-cdc.md @@ -362,7 +362,11 @@ Connector Options optional false Boolean - Whether to close idle readers at the end of the snapshot phase. The flink version is required to be greater than or equal to 1.14 when 'execution.checkpointing.checkpoints-after-tasks-finish.enabled' is set to true. + Whether to close idle readers at the end of the snapshot phase.
+ The flink version is required to be greater than or equal to 1.14 when 'execution.checkpointing.checkpoints-after-tasks-finish.enabled' is set to true.
+ If the flink version is greater than or equal to 1.15, the default value of 'execution.checkpointing.checkpoints-after-tasks-finish.enabled' has been changed to true, + so it does not need to be explicitly configured 'execution.checkpointing.checkpoints-after-tasks-finish.enabled' = 'true' + diff --git a/docs/content/connectors/postgres-cdc.md b/docs/content/connectors/postgres-cdc.md index b7bf1d8ac..364daf8f4 100644 --- a/docs/content/connectors/postgres-cdc.md +++ b/docs/content/connectors/postgres-cdc.md @@ -206,6 +206,17 @@ Connector Options Please see Incremental Snapshot Readingsection for more detailed information. + + scan.incremental.close-idle-reader.enabled + optional + false + Boolean + Whether to close idle readers at the end of the snapshot phase.
+ The flink version is required to be greater than or equal to 1.14 when 'execution.checkpointing.checkpoints-after-tasks-finish.enabled' is set to true.
+ If the flink version is greater than or equal to 1.15, the default value of 'execution.checkpointing.checkpoints-after-tasks-finish.enabled' has been changed to true, + so it does not need to be explicitly configured 'execution.checkpointing.checkpoints-after-tasks-finish.enabled' = 'true' + + diff --git a/docs/content/connectors/sqlserver-cdc.md b/docs/content/connectors/sqlserver-cdc.md index 1a4da0dd2..04a7be967 100644 --- a/docs/content/connectors/sqlserver-cdc.md +++ b/docs/content/connectors/sqlserver-cdc.md @@ -205,7 +205,11 @@ Connector Options optional false Boolean - Whether to close idle readers at the end of the snapshot phase. The flink version is required to be greater than or equal to 1.14 when 'execution.checkpointing.checkpoints-after-tasks-finish.enabled' is set to true. + Whether to close idle readers at the end of the snapshot phase.
+ The flink version is required to be greater than or equal to 1.14 when 'execution.checkpointing.checkpoints-after-tasks-finish.enabled' is set to true.
+ If the flink version is greater than or equal to 1.15, the default value of 'execution.checkpointing.checkpoints-after-tasks-finish.enabled' has been changed to true, + so it does not need to be explicitly configured 'execution.checkpointing.checkpoints-after-tasks-finish.enabled' = 'true' + diff --git a/docs/content/pipelines/index.md b/docs/content/pipelines/index.md new file mode 100644 index 000000000..08ef93197 --- /dev/null +++ b/docs/content/pipelines/index.md @@ -0,0 +1,8 @@ +# Pipeline Connectors + +```{toctree} +:maxdepth: 2 + +mysql-pipeline +mysql-pipeline(ZH) +``` diff --git a/docs/content/pipelines/mysql-pipeline(ZH).md b/docs/content/pipelines/mysql-pipeline(ZH).md new file mode 100644 index 000000000..27ae8d811 --- /dev/null +++ b/docs/content/pipelines/mysql-pipeline(ZH).md @@ -0,0 +1,540 @@ +# MySQL CDC Pipeline 连接器 + +MySQL CDC Pipeline 连接器允许从 MySQL 数据库读取快照数据和增量数据,并提供端到端的整库数据同步能力。 +本文描述了如何设置 MySQL CDC Pipeline 连接器。 + + +如何创建 Pipeline +---------------- + +从 MySQL 读取数据同步到 Doris 的 Pipeline 可以定义如下: + +```yaml +source: + type: mysql + name: MySQL Source + hostname: 127.0.0.1 + port: 3306 + username: admin + password: pass + tables: adb.\.*, bdb.user_table_[0-9]+, [app|web].order_\.* + server-id: 5401-5404 + +sink: + type: doris + name: Doris Sink + fenodes: 127.0.0.1:8030 + username: root + password: pass + +pipeline: + name: MySQL to Doris Pipeline + parallelism: 4 +``` + +Pipeline 连接器选项 +---------------- + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
OptionRequiredDefaultTypeDescription
hostnamerequired(none)String MySQL 数据库服务器的 IP 地址或主机名。
portoptional3306IntegerMySQL 数据库服务器的整数端口号。
usernamerequired(none)String连接到 MySQL 数据库服务器时要使用的 MySQL 用户的名称。
passwordrequired(none)String连接 MySQL 数据库服务器时使用的密码。
tablesrequired(none)String需要监视的 MySQL 数据库的表名。表名支持正则表达式,以监视满足正则表达式的多个表。
+ 需要注意的是,点号(.)被视为数据库和表名的分隔符。 如果需要在正则表达式中使用点(.)来匹配任何字符,必须使用反斜杠对点进行转义。
+ 例如,db0.\.*, db1.user_table_[0-9]+, db[1-2].[app|web]order_\.*
schema-change.enabledoptionaltrueBoolean是否发送模式更改事件,下游 sink 可以响应模式变更事件实现表结构同步,默认为true。
server-idoptional(none)String读取数据使用的 server id,server id 可以是个整数或者一个整数范围,比如 '5400' 或 '5400-5408', + 建议在 'scan.incremental.snapshot.enabled' 参数为启用时,配置成整数范围。因为在当前 MySQL 集群中运行的所有 slave 节点,标记每个 salve 节点的 id 都必须是唯一的。 所以当连接器加入 MySQL 集群作为另一个 slave 节点(并且具有唯一 id 的情况下),它就可以读取 binlog。 默认情况下,连接器会在 5400 和 6400 之间生成一个随机数,但是我们建议用户明确指定 Server id。 +
scan.incremental.snapshot.chunk.sizeoptional8096Integer表快照的块大小(行数),读取表的快照时,捕获的表被拆分为多个块。
scan.snapshot.fetch.sizeoptional1024Integer读取表快照时每次读取数据的最大条数。
scan.startup.modeoptionalinitialString MySQL CDC 消费者可选的启动模式, + 合法的模式为 "initial","earliest-offset","latest-offset","specific-offset" 和 "timestamp"。 + 请查阅 启动模式 章节了解更多详细信息。
scan.startup.specific-offset.fileoptional(none)String在 "specific-offset" 启动模式下,启动位点的 binlog 文件名。
scan.startup.specific-offset.posoptional(none)Long在 "specific-offset" 启动模式下,启动位点的 binlog 文件位置。
scan.startup.specific-offset.gtid-setoptional(none)String在 "specific-offset" 启动模式下,启动位点的 GTID 集合。
scan.startup.specific-offset.skip-eventsoptional(none)Long在指定的启动位点后需要跳过的事件数量。
scan.startup.specific-offset.skip-rowsoptional(none)Long在指定的启动位点后需要跳过的数据行数量。
connect.timeoutoptional30sDuration连接器在尝试连接到 MySQL 数据库服务器后超时前应等待的最长时间。
connect.max-retriesoptional3Integer连接器应重试以建立 MySQL 数据库服务器连接的最大重试次数。
connection.pool.sizeoptional20Integer连接池大小。
jdbc.properties.*optional20String传递自定义 JDBC URL 属性的选项。用户可以传递自定义属性,如 'jdbc.properties.useSSL' = 'false'.
heartbeat.intervaloptional30sDuration用于跟踪最新可用 binlog 偏移的发送心跳事件的间隔。
debezium.*optional(none)String将 Debezium 的属性传递给 Debezium 嵌入式引擎,该引擎用于从 MySQL 服务器捕获数据更改。 + 例如: 'debezium.snapshot.mode' = 'never'. + 查看更多关于 Debezium 的 MySQL 连接器属性
scan.incremental.close-idle-reader.enabledoptionalfalseBoolean是否在快照结束后关闭空闲的 Reader。 此特性需要 flink 版本大于等于 1.14 并且 'execution.checkpointing.checkpoints-after-tasks-finish.enabled' 需要设置为 true。
+ 若 flink 版本大于等于 1.15,'execution.checkpointing.checkpoints-after-tasks-finish.enabled' 默认值变更为 true,可以不用显式配置 'execution.checkpointing.checkpoints-after-tasks-finish.enabled' = true。
+
+ + +启动模式 +-------- + +配置选项```scan.startup.mode```指定 MySQL CDC 使用者的启动模式。有效枚举包括: + +- `initial` (默认):在第一次启动时对受监视的数据库表执行初始快照,并继续读取最新的 binlog。 +- `earliest-offset`:跳过快照阶段,从可读取的最早 binlog 位点开始读取 +- `latest-offset`:首次启动时,从不对受监视的数据库表执行快照, 连接器仅从 binlog 的结尾处开始读取,这意味着连接器只能读取在连接器启动之后的数据更改。 +- `specific-offset`:跳过快照阶段,从指定的 binlog 位点开始读取。位点可通过 binlog 文件名和位置指定,或者在 GTID 在集群上启用时通过 GTID 集合指定。 +- `timestamp`:跳过快照阶段,从指定的时间戳开始读取 binlog 事件。 + +数据类型映射 +---------------- + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
MySQL typeCDC typeNOTE
TINYINT(n)TINYINT
+ SMALLINT
+ TINYINT UNSIGNED
+ TINYINT UNSIGNED ZEROFILL +
SMALLINT
+ INT
+ YEAR
+ MEDIUMINT
+ MEDIUMINT UNSIGNED
+ MEDIUMINT UNSIGNED ZEROFILL
+ SMALLINT UNSIGNED
+ SMALLINT UNSIGNED ZEROFILL +
INT
+ BIGINT
+ INT UNSIGNED
+ INT UNSIGNED ZEROFILL +
BIGINT
+ BIGINT UNSIGNED
+ BIGINT UNSIGNED ZEROFILL
+ SERIAL +
DECIMAL(20, 0)
+ FLOAT
+ FLOAT UNSIGNED
+ FLOAT UNSIGNED ZEROFILL +
FLOAT
+ REAL
+ REAL UNSIGNED
+ REAL UNSIGNED ZEROFILL
+ DOUBLE
+ DOUBLE UNSIGNED
+ DOUBLE UNSIGNED ZEROFILL
+ DOUBLE PRECISION
+ DOUBLE PRECISION UNSIGNED
+ DOUBLE PRECISION UNSIGNED ZEROFILL +
DOUBLE
+ NUMERIC(p, s)
+ NUMERIC(p, s) UNSIGNED
+ NUMERIC(p, s) UNSIGNED ZEROFILL
+ DECIMAL(p, s)
+ DECIMAL(p, s) UNSIGNED
+ DECIMAL(p, s) UNSIGNED ZEROFILL
+ FIXED(p, s)
+ FIXED(p, s) UNSIGNED
+ FIXED(p, s) UNSIGNED ZEROFILL
+ where p <= 38
+
DECIMAL(p, s)
+ NUMERIC(p, s)
+ NUMERIC(p, s) UNSIGNED
+ NUMERIC(p, s) UNSIGNED ZEROFILL
+ DECIMAL(p, s)
+ DECIMAL(p, s) UNSIGNED
+ DECIMAL(p, s) UNSIGNED ZEROFILL
+ FIXED(p, s)
+ FIXED(p, s) UNSIGNED
+ FIXED(p, s) UNSIGNED ZEROFILL
+ where 38 < p <= 65
+
STRING在 MySQL 中,十进制数据类型的精度高达 65,但在 Flink 中,十进制数据类型的精度仅限于 38。所以,如果定义精度大于 38 的十进制列,则应将其映射到字符串以避免精度损失。
+ BOOLEAN
+ TINYINT(1)
+ BIT(1) +
BOOLEAN
DATEDATE
TIME [(p)]TIME [(p)]
TIMESTAMP [(p)] + TIMESTAMP_LTZ [(p)] +
DATETIME [(p)] + TIMESTAMP [(p)] +
+ CHAR(n) + CHAR(n)
+ VARCHAR(n) + VARCHAR(n)
+ BIT(n) + BINARY(⌈(n + 7) / 8⌉)
+ BINARY(n) + BINARY(n)
+ VARBINARY(N) + VARBINARY(N)
+ TINYTEXT
+ TEXT
+ MEDIUMTEXT
+ LONGTEXT
+
STRING
+ TINYBLOB
+ BLOB
+ MEDIUMBLOB
+ LONGBLOB
+
BYTES目前,对于 MySQL 中的 BLOB 数据类型,仅支持长度不大于 2147483647(2**31-1)的 blob。
+ ENUM + STRING
+ JSON + STRING JSON 数据类型将在 Flink 中转换为 JSON 格式的字符串。
+ SET + - 暂不支持
+ GEOMETRY
+ POINT
+ LINESTRING
+ POLYGON
+ MULTIPOINT
+ MULTILINESTRING
+ MULTIPOLYGON
+ GEOMETRYCOLLECTION
+
+ STRING + + MySQL 中的空间数据类型将转换为具有固定 Json 格式的字符串。 + 请参考 MySQL 空间数据类型映射 章节了解更多详细信息。 +
+
+ +### 空间数据类型映射 + +MySQL中除`GEOMETRYCOLLECTION`之外的空间数据类型都会转换为 Json 字符串,格式固定,如:
+```json +{"srid": 0 , "type": "xxx", "coordinates": [0, 0]} +``` +字段`srid`标识定义几何体的 SRS,如果未指定 SRID,则 SRID 0 是新几何体值的默认值。 +由于 MySQL 8+ 在定义空间数据类型时只支持特定的 SRID,因此在版本较低的MySQL中,字段`srid`将始终为 0。 + +字段`type`标识空间数据类型,例如`POINT`/`LINESTRING`/`POLYGON`。 + +字段`coordinates`表示空间数据的`坐标`。 + +对于`GEOMETRYCOLLECTION`,它将转换为 Json 字符串,格式固定,如:
+```json +{"srid": 0 , "type": "GeometryCollection", "geometries": [{"type":"Point","coordinates":[10,10]}]} +``` + +`Geometrics`字段是一个包含所有空间数据的数组。 + +不同空间数据类型映射的示例如下: +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Spatial data in MySQLJson String converted in Flink
POINT(1 1){"coordinates":[1,1],"type":"Point","srid":0}
LINESTRING(3 0, 3 3, 3 5){"coordinates":[[3,0],[3,3],[3,5]],"type":"LineString","srid":0}
POLYGON((1 1, 2 1, 2 2, 1 2, 1 1)){"coordinates":[[[1,1],[2,1],[2,2],[1,2],[1,1]]],"type":"Polygon","srid":0}
MULTIPOINT((1 1),(2 2)){"coordinates":[[1,1],[2,2]],"type":"MultiPoint","srid":0}
MultiLineString((1 1,2 2,3 3),(4 4,5 5)){"coordinates":[[[1,1],[2,2],[3,3]],[[4,4],[5,5]]],"type":"MultiLineString","srid":0}
MULTIPOLYGON(((0 0, 10 0, 10 10, 0 10, 0 0)), ((5 5, 7 5, 7 7, 5 7, 5 5))){"coordinates":[[[[0,0],[10,0],[10,10],[0,10],[0,0]]],[[[5,5],[7,5],[7,7],[5,7],[5,5]]]],"type":"MultiPolygon","srid":0}
GEOMETRYCOLLECTION(POINT(10 10), POINT(30 30), LINESTRING(15 15, 20 20)){"geometries":[{"type":"Point","coordinates":[10,10]},{"type":"Point","coordinates":[30,30]},{"type":"LineString","coordinates":[[15,15],[20,20]]}],"type":"GeometryCollection","srid":0}
+
+ +常见问题 +-------- +* [FAQ(English)](https://github.com/ververica/flink-cdc-connectors/wiki/FAQ) +* [FAQ(中文)](https://github.com/ververica/flink-cdc-connectors/wiki/FAQ(ZH)) diff --git a/docs/content/pipelines/mysql-pipeline.md b/docs/content/pipelines/mysql-pipeline.md new file mode 100644 index 000000000..861c5fd10 --- /dev/null +++ b/docs/content/pipelines/mysql-pipeline.md @@ -0,0 +1,547 @@ +# MySQL CDC Pipeline Connector + +The MySQL CDC Pipeline Connector allows for reading snapshot data and incremental data from MySQL database and provides end-to-end full-database data synchronization capabilities. +This document describes how to setup the MySQL CDC Pipeline connector. + + +How to create Pipeline +---------------- + +The pipeline for reading data from MySQL and sink to Doris can be defined as follows: + +```yaml +source: + type: mysql + name: MySQL Source + hostname: 127.0.0.1 + port: 3306 + username: admin + password: pass + tables: adb.\.*, bdb.user_table_[0-9]+, [app|web].order_\.* + server-id: 5401-5404 + +sink: + type: doris + name: Doris Sink + fenodes: 127.0.0.1:8030 + username: root + password: pass + +pipeline: + name: MySQL to Doris Pipeline + parallelism: 4 +``` + +Pipeline Connector Options +---------------- + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
OptionRequiredDefaultTypeDescription
hostnamerequired(none)StringIP address or hostname of the MySQL database server.
portoptional3306IntegerInteger port number of the MySQL database server.
usernamerequired(none)StringName of the MySQL database to use when connecting to the MySQL database server.
passwordrequired(none)StringPassword to use when connecting to the MySQL database server.
tablesrequired(none)StringTable name of the MySQL database to monitor. The table-name also supports regular expressions to monitor multiple tables that satisfy the regular expressions.
+ It is important to note that the dot (.) is treated as a delimiter for database and table names. + If there is a need to use a dot (.) in a regular expression to match any character, it is necessary to escape the dot with a backslash.
+ eg. db0.\.*, db1.user_table_[0-9]+, db[1-2].[app|web]order_\.*
schema-change.enabledoptionaltrueBooleanWhether to send schema change events, so that downstream sinks can respond to schema changes and achieve table structure synchronization.
server-idoptional(none)StringA 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', The numeric ID range syntax is recommended when 'scan.incremental.snapshot.enabled' enabled. + 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.
scan.incremental.snapshot.chunk.sizeoptional8096IntegerThe chunk size (number of rows) of table snapshot, captured tables are split into multiple chunks when read the snapshot of table.
scan.snapshot.fetch.sizeoptional1024IntegerThe maximum fetch size for per poll when read table snapshot.
scan.startup.modeoptionalinitialStringOptional startup mode for MySQL CDC consumer, valid enumerations are "initial", "earliest-offset", "latest-offset", "specific-offset" and "timestamp". + Please see Startup Reading Position section for more detailed information.
scan.startup.specific-offset.fileoptional(none)StringOptional binlog file name used in case of "specific-offset" startup mode
scan.startup.specific-offset.posoptional(none)LongOptional binlog file position used in case of "specific-offset" startup mode
scan.startup.specific-offset.gtid-setoptional(none)StringOptional GTID set used in case of "specific-offset" startup mode
scan.startup.specific-offset.skip-eventsoptional(none)LongOptional number of events to skip after the specific starting offset
scan.startup.specific-offset.skip-rowsoptional(none)LongOptional number of rows to skip after the specific starting offset
connect.timeoutoptional30sDurationThe maximum time that the connector should wait after trying to connect to the MySQL database server before timing out.
connect.max-retriesoptional3IntegerThe max retry times that the connector should retry to build MySQL database server connection.
connection.pool.sizeoptional20IntegerThe connection pool size.
jdbc.properties.*optional20StringOption to pass custom JDBC URL properties. User can pass custom properties like 'jdbc.properties.useSSL' = 'false'.
heartbeat.intervaloptional30sDurationThe interval of sending heartbeat event for tracing the latest available binlog offsets.
debezium.*optional(none)StringPass-through Debezium's properties to Debezium Embedded Engine which is used to capture data changes from MySQL server. + For example: 'debezium.snapshot.mode' = 'never'. + See more about the Debezium's MySQL Connector properties
scan.incremental.close-idle-reader.enabledoptionalfalseBooleanWhether to close idle readers at the end of the snapshot phase.
+ The flink version is required to be greater than or equal to 1.14 when 'execution.checkpointing.checkpoints-after-tasks-finish.enabled' is set to true.
+ If the flink version is greater than or equal to 1.15, the default value of 'execution.checkpointing.checkpoints-after-tasks-finish.enabled' has been changed to true, + so it does not need to be explicitly configured 'execution.checkpointing.checkpoints-after-tasks-finish.enabled' = 'true' +
+
+ +Startup Reading Position +-------- + +The config option `scan.startup.mode` specifies the startup mode for MySQL CDC consumer. The valid enumerations are: + +- `initial` (default): Performs an initial snapshot on the monitored database tables upon first startup, and continue to read the latest binlog. +- `earliest-offset`: Skip snapshot phase and start reading binlog events from the earliest accessible binlog offset. +- `latest-offset`: Never to perform snapshot on the monitored database tables upon first startup, just read from + the end of the binlog which means only have the changes since the connector was started. +- `specific-offset`: Skip snapshot phase and start reading binlog events from a specific offset. The offset could be + specified with binlog filename and position, or a GTID set if GTID is enabled on server. +- `timestamp`: Skip snapshot phase and start reading binlog events from a specific timestamp. + + +Data Type Mapping +---------------- + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
MySQL typeCDC typeNOTE
TINYINT(n)TINYINT
+ SMALLINT
+ TINYINT UNSIGNED
+ TINYINT UNSIGNED ZEROFILL +
SMALLINT
+ INT
+ YEAR
+ MEDIUMINT
+ MEDIUMINT UNSIGNED
+ MEDIUMINT UNSIGNED ZEROFILL
+ SMALLINT UNSIGNED
+ SMALLINT UNSIGNED ZEROFILL +
INT
+ BIGINT
+ INT UNSIGNED
+ INT UNSIGNED ZEROFILL +
BIGINT
+ BIGINT UNSIGNED
+ BIGINT UNSIGNED ZEROFILL
+ SERIAL +
DECIMAL(20, 0)
+ FLOAT
+ FLOAT UNSIGNED
+ FLOAT UNSIGNED ZEROFILL +
FLOAT
+ REAL
+ REAL UNSIGNED
+ REAL UNSIGNED ZEROFILL
+ DOUBLE
+ DOUBLE UNSIGNED
+ DOUBLE UNSIGNED ZEROFILL
+ DOUBLE PRECISION
+ DOUBLE PRECISION UNSIGNED
+ DOUBLE PRECISION UNSIGNED ZEROFILL +
DOUBLE
+ NUMERIC(p, s)
+ NUMERIC(p, s) UNSIGNED
+ NUMERIC(p, s) UNSIGNED ZEROFILL
+ DECIMAL(p, s)
+ DECIMAL(p, s) UNSIGNED
+ DECIMAL(p, s) UNSIGNED ZEROFILL
+ FIXED(p, s)
+ FIXED(p, s) UNSIGNED
+ FIXED(p, s) UNSIGNED ZEROFILL
+ where p <= 38
+
DECIMAL(p, s)
+ NUMERIC(p, s)
+ NUMERIC(p, s) UNSIGNED
+ NUMERIC(p, s) UNSIGNED ZEROFILL
+ DECIMAL(p, s)
+ DECIMAL(p, s) UNSIGNED
+ DECIMAL(p, s) UNSIGNED ZEROFILL
+ FIXED(p, s)
+ FIXED(p, s) UNSIGNED
+ FIXED(p, s) UNSIGNED ZEROFILL
+ where 38 < p <= 65
+
STRINGThe precision for DECIMAL data type is up to 65 in MySQL, but the precision for DECIMAL is limited to 38 in Flink. + So if you define a decimal column whose precision is greater than 38, you should map it to STRING to avoid precision loss.
+ BOOLEAN
+ TINYINT(1)
+ BIT(1) +
BOOLEAN
DATEDATE
TIME [(p)]TIME [(p)]
TIMESTAMP [(p)] + TIMESTAMP_LTZ [(p)] +
DATETIME [(p)] + TIMESTAMP [(p)] +
+ CHAR(n) + CHAR(n)
+ VARCHAR(n) + VARCHAR(n)
+ BIT(n) + BINARY(⌈(n + 7) / 8⌉)
+ BINARY(n) + BINARY(n)
+ VARBINARY(N) + VARBINARY(N)
+ TINYTEXT
+ TEXT
+ MEDIUMTEXT
+ LONGTEXT
+
STRING
+ TINYBLOB
+ BLOB
+ MEDIUMBLOB
+ LONGBLOB
+
BYTESCurrently, for BLOB data type in MySQL, only the blob whose length isn't greater than 2,147,483,647(2 ** 31 - 1) is supported.
+ ENUM + STRING
+ JSON + STRINGThe JSON data type will be converted into STRING with JSON format in Flink.
+ SET + -Not supported yet.
+ GEOMETRY
+ POINT
+ LINESTRING
+ POLYGON
+ MULTIPOINT
+ MULTILINESTRING
+ MULTIPOLYGON
+ GEOMETRYCOLLECTION
+
+ STRING + + The spatial data types in MySQL will be converted into STRING with a fixed Json format. + Please see MySQL Spatial Data Types Mapping section for more detailed information. +
+
+ +### MySQL Spatial Data Types Mapping +The spatial data types except for `GEOMETRYCOLLECTION` in MySQL will be converted into Json String with a fixed format like:
+```json +{"srid": 0 , "type": "xxx", "coordinates": [0, 0]} +``` +The field `srid` identifies the SRS in which the geometry is defined, SRID 0 is the default for new geometry values if no SRID is specified. +As only MySQL 8+ support to specific SRID when define spatial data type, the field `srid` will always be 0 in MySQL with a lower version. + +The field `type` identifies the spatial data type, such as `POINT`/`LINESTRING`/`POLYGON`. + +The field `coordinates` represents the `coordinates` of the spatial data. + +For `GEOMETRYCOLLECTION`, it will be converted into Json String with a fixed format like:
+```json +{"srid": 0 , "type": "GeometryCollection", "geometries": [{"type":"Point","coordinates":[10,10]}]} +``` + +The field `geometries` is an array contains all spatial data. + +The example for different spatial data types mapping is as follows: +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Spatial data in MySQLJson String converted in Flink
POINT(1 1){"coordinates":[1,1],"type":"Point","srid":0}
LINESTRING(3 0, 3 3, 3 5){"coordinates":[[3,0],[3,3],[3,5]],"type":"LineString","srid":0}
POLYGON((1 1, 2 1, 2 2, 1 2, 1 1)){"coordinates":[[[1,1],[2,1],[2,2],[1,2],[1,1]]],"type":"Polygon","srid":0}
MULTIPOINT((1 1),(2 2)){"coordinates":[[1,1],[2,2]],"type":"MultiPoint","srid":0}
MultiLineString((1 1,2 2,3 3),(4 4,5 5)){"coordinates":[[[1,1],[2,2],[3,3]],[[4,4],[5,5]]],"type":"MultiLineString","srid":0}
MULTIPOLYGON(((0 0, 10 0, 10 10, 0 10, 0 0)), ((5 5, 7 5, 7 7, 5 7, 5 5))){"coordinates":[[[[0,0],[10,0],[10,10],[0,10],[0,0]]],[[[5,5],[7,5],[7,7],[5,7],[5,5]]]],"type":"MultiPolygon","srid":0}
GEOMETRYCOLLECTION(POINT(10 10), POINT(30 30), LINESTRING(15 15, 20 20)){"geometries":[{"type":"Point","coordinates":[10,10]},{"type":"Point","coordinates":[30,30]},{"type":"LineString","coordinates":[[15,15],[20,20]]}],"type":"GeometryCollection","srid":0}
+
+ +FAQ +-------- +* [FAQ(English)](https://github.com/ververica/flink-cdc-connectors/wiki/FAQ) +* [FAQ(中文)](https://github.com/ververica/flink-cdc-connectors/wiki/FAQ(ZH)) \ No newline at end of file diff --git a/docs/index.md b/docs/index.md index eb6ad01c3..fc1ca34ab 100644 --- a/docs/index.md +++ b/docs/index.md @@ -7,6 +7,7 @@ content/overview/index content/quickstart/index content/快速上手/index content/connectors/index +content/pipelines/index content/formats/index content/downloads content/githublink