You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by yu...@apache.org on 2026/10/10 03:11:34 UTC
(flink-cdc) branch master updated: [FLINK-40951][docs] Translate Flink source connector docs into Chinese (#4567)
This is an automated email from the ASF dual-hosted git repository.
yuxiqian pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink-cdc.git
The following commit(s) were added to refs/heads/master by this push:
new c87d80ce6 [FLINK-40951][docs] Translate Flink source connector docs into Chinese (#4567)
c87d80ce6 is described below
commit c87d80ce68c29a437b3a8b99c73e304028bdbc56
Author: Pei Yu <12...@qq.com>
AuthorDate: Sat Oct 10 11:11:29 2026 +0800
[FLINK-40951][docs] Translate Flink source connector docs into Chinese (#4567)
---
.../datastream-api-package-guidance.md | 10 +-
.../docs/connectors/flink-sources/db2-cdc.md | 222 ++++++++-------
.../docs/connectors/flink-sources/mongodb-cdc.md | 191 +++++++------
.../docs/connectors/flink-sources/mysql-cdc.md | 288 +++++++++++---------
.../docs/connectors/flink-sources/oceanbase-cdc.md | 168 +++++++-----
.../docs/connectors/flink-sources/oracle-cdc.md | 242 ++++++++---------
.../docs/connectors/flink-sources/overview.md | 90 +++----
.../docs/connectors/flink-sources/postgres-cdc.md | 300 +++++++++++----------
.../docs/connectors/flink-sources/sqlserver-cdc.md | 223 ++++++++-------
.../docs/connectors/flink-sources/tidb-cdc.md | 90 +++----
.../docs/connectors/flink-sources/vitess-cdc.md | 90 +++----
11 files changed, 991 insertions(+), 923 deletions(-)
diff --git a/docs/content.zh/docs/connectors/flink-sources/datastream-api-package-guidance.md b/docs/content.zh/docs/connectors/flink-sources/datastream-api-package-guidance.md
index a38e4c4fa..59abf33c9 100644
--- a/docs/content.zh/docs/connectors/flink-sources/datastream-api-package-guidance.md
+++ b/docs/content.zh/docs/connectors/flink-sources/datastream-api-package-guidance.md
@@ -25,11 +25,11 @@ specific language governing permissions and limitations
under the License.
-->
-# DataStream API Package Guidance
+# DataStream API 打包指南
-This guide provides a simple `pom.xml` example for packaging DataStream job JARs with MySQL CDC source.
+本指南提供一个简单的 `pom.xml` 示例,用于打包带有 MySQL CDC source 的 DataStream 作业 JAR。
-## Example for `pom.xml` with Flink 1.20.x
+## Flink 1.20.x 的 `pom.xml` 示例
```xml
<?xml version="1.0" encoding="UTF-8"?>
@@ -238,7 +238,7 @@ This guide provides a simple `pom.xml` example for packaging DataStream job JARs
</project>
```
-## Example for `pom.xml` with Flink 2.2.x
+## Flink 2.2.x 的 `pom.xml` 示例
```xml
<?xml version="1.0" encoding="UTF-8"?>
@@ -445,7 +445,7 @@ This guide provides a simple `pom.xml` example for packaging DataStream job JARs
</project>
```
-## Example for Code
+## 代码示例
```java
package org.apache.flink.flink.cdc;
diff --git a/docs/content.zh/docs/connectors/flink-sources/db2-cdc.md b/docs/content.zh/docs/connectors/flink-sources/db2-cdc.md
index 5557fdba0..6a3efc2ad 100644
--- a/docs/content.zh/docs/connectors/flink-sources/db2-cdc.md
+++ b/docs/content.zh/docs/connectors/flink-sources/db2-cdc.md
@@ -24,23 +24,21 @@ specific language governing permissions and limitations
under the License.
-->
-# Db2 CDC Connector
+# Db2 CDC 连接器
-The Db2 CDC connector allows for reading snapshot data and incremental data from Db2 database. This document
-describes how to setup the db2 CDC connector to run SQL queries against Db2 databases.
+Db2 CDC 连接器允许从 Db2 数据库读取快照数据和增量数据。本文描述了如何设置 Db2 CDC 连接器来对 Db2 数据库运行 SQL 查询。
-## Supported Databases
+## 支持的数据库
| Connector | Database | Driver |
|-----------|----------------------------------------------------|----------------------|
| Db2-cdc | <li> [Db2](https://www.ibm.com/products/db2): 11.5 | Db2 Driver: 11.5.0.0 |
-Dependencies
+依赖
------------
-In order to set up the Db2 CDC connector, the following table provides dependency information for both projects
-using a build automation tool (such as Maven or SBT) and SQL Client with SQL JAR bundles.
+为了设置 Db2 CDC 连接器,下表提供了使用构建自动化工具(如 Maven 或 SBT )和带有 SQL JAR 包的 SQL 客户端的两个项目的依赖关系信息。
### Maven dependency
@@ -48,12 +46,9 @@ using a build automation tool (such as Maven or SBT) and SQL Client with SQL JAR
### SQL Client JAR
-Download [flink-sql-connector-db2-cdc](https://mvnrepository.com/artifact/org.apache.flink/flink-sql-connector-db2-cdc) and
-put it under `<FLINK_HOME>/lib/`.
+下载 [flink-sql-connector-db2-cdc](https://mvnrepository.com/artifact/org.apache.flink/flink-sql-connector-db2-cdc) 到 `<FLINK_HOME>/lib/` 目录下。
-**Note:** Refer to
-[flink-sql-connector-db2-cdc](https://mvnrepository.com/artifact/org.apache.flink/flink-sql-connector-db2-cdc),
-more released versions will be available in the Maven central warehouse.
+**注意:** 参考 [flink-sql-connector-db2-cdc](https://mvnrepository.com/artifact/org.apache.flink/flink-sql-connector-db2-cdc) 当前已发布的所有版本都可以在 Maven 中央仓库获取。
由于 Db2 Connector 采用的 IPLA 协议与 Flink CDC 项目不兼容,我们无法在 jar 包中提供 Db2 连接器。
您可能需要手动配置以下依赖:
@@ -75,25 +70,25 @@ more released versions will be available in the Maven central warehouse.
</table>
</div>
-Setup Db2 server
+设置 Db2 服务器
----------------
-Follow the steps in the [Debezium Db2 Connector](https://debezium.io/documentation/reference/1.9/connectors/db2.html#setting-up-db2).
+按照 [Debezium Db2 Connector](https://debezium.io/documentation/reference/1.9/connectors/db2.html#setting-up-db2) 中的步骤进行操作。
-Notes
+注意事项
----------------
-### Not support BOOLEAN type in SQL Replication on Db2
+### Db2 的 SQL Replication 不支持 BOOLEAN 类型
-Only snapshots can be taken from tables with BOOLEAN type columns. Currently, SQL Replication on Db2 does not support BOOLEAN, so Debezium can not perform CDC on those tables.
-Consider using another type to replace BOOLEAN type.
+包含 BOOLEAN 类型列的表只能执行快照读取。目前 Db2 上的 SQL Replication 不支持 BOOLEAN 类型,因此 Debezium 无法对这些表执行 CDC。
+请考虑使用其他类型来替代 BOOLEAN 类型。
-How to create a Db2 CDC table
+如何创建 Db2 CDC 表
----------------
-The Db2 CDC table can be defined as following:
+Db2 CDC 表可以定义如下:
```sql
-- checkpoint every 3 seconds
@@ -119,7 +114,7 @@ Flink SQL> CREATE TABLE products (
Flink SQL> SELECT * FROM products;
```
-Connector Options
+连接器配置项
----------------
<div class="highlight">
@@ -139,68 +134,67 @@ Connector Options
<td>required</td>
<td style="word-wrap: break-word;">(none)</td>
<td>String</td>
- <td>Specify what connector to use, here should be <code>'db2-cdc'</code>.</td>
+ <td>指定要使用的连接器, 这里应该是 <code>'db2-cdc'</code>.</td>
</tr>
<tr>
<td>hostname</td>
<td>required</td>
<td style="word-wrap: break-word;">(none)</td>
<td>String</td>
- <td>IP address or hostname of the Db2 database server.</td>
+ <td> Db2 数据库服务器的 IP 地址或主机名。</td>
</tr>
<tr>
<td>username</td>
<td>required</td>
<td style="word-wrap: break-word;">(none)</td>
<td>String</td>
- <td>Name of the Db2 database to use when connecting to the Db2 database server.</td>
+ <td>连接到 Db2 数据库服务器时要使用的 Db2 用户的名称。</td>
</tr>
<tr>
<td>password</td>
<td>required</td>
<td style="word-wrap: break-word;">(none)</td>
<td>String</td>
- <td>Password to use when connecting to the Db2 database server.</td>
+ <td>连接 Db2 数据库服务器时使用的密码。</td>
</tr>
<tr>
<td>database-name</td>
<td>required</td>
<td style="word-wrap: break-word;">(none)</td>
<td>String</td>
- <td>Database name of the Db2 server to monitor.</td>
+ <td>要监视的 Db2 服务器的数据库名称。</td>
</tr>
<tr>
<td>table-name</td>
<td>required</td>
<td style="word-wrap: break-word;">(none)</td>
<td>String</td>
- <td>Table name of the Db2 database to monitor, e.g.: "db1.table1"</td>
+ <td>需要监视的 Db2 数据库的表名,例如:"db1.table1"</td>
</tr>
<tr>
<td>port</td>
<td>optional</td>
<td style="word-wrap: break-word;">50000</td>
<td>Integer</td>
- <td>Integer port number of the Db2 database server.</td>
+ <td> Db2 数据库服务器的整数端口号。</td>
</tr>
<tr>
<td>scan.startup.mode</td>
<td>optional</td>
<td style="word-wrap: break-word;">initial</td>
<td>String</td>
- <td>Optional startup mode for Db2 CDC consumer, valid enumerations are "initial"
- and "latest-offset". Please see <a href="#startup-reading-position">Startup Reading Position</a> section
-for more detailed information.</td>
+ <td>Db2 CDC 消费者可选的启动模式,合法的模式为 "initial"
+ 和 "latest-offset"。请查阅 <a href="#启动模式">启动模式</a> 章节了解更多详细信息。</td>
</tr>
<tr>
<td>server-time-zone</td>
<td>optional</td>
<td style="word-wrap: break-word;">(none)</td>
<td>String</td>
- <td>The session time zone in database server, e.g. "Asia/Shanghai".
- It controls how the TIMESTAMP type in Db2 converted to STRING.
- See more <a href="https://debezium.io/documentation/reference/1.9/connectors/db2.html#db2-temporal-types">here</a>.
- If not set, then ZoneId.systemDefault() is used to determine the server time zone.
+ <td>数据库服务器中的会话时区, 例如: "Asia/Shanghai".
+ 它控制 Db2 中的 TIMESTAMP 类型如何转换为 STRING。
+ 更多请参考 <a href="https://debezium.io/documentation/reference/1.9/connectors/db2.html#db2-temporal-types"> 这里</a>.
+ 如果没有设置,则使用ZoneId.systemDefault()来确定服务器时区。
</td>
</tr>
<tr>
@@ -208,60 +202,59 @@ for more detailed information.</td>
<td>optional</td>
<td style="word-wrap: break-word;">true</td>
<td>Boolean</td>
- <td>Whether enable parallelism snapshot.</td>
+ <td>是否启用并行快照。</td>
</tr>
<tr>
<td>chunk-meta.group.size</td>
<td>optional</td>
<td style="word-wrap: break-word;">1000</td>
<td>Integer</td>
- <td>The group size of chunk meta, if the meta size exceeds the group size, the meta will be divided into multiple groups.</td>
+ <td>分片元数据的分组大小,如果元数据大小超过分组大小,则元数据将被划分为多个分组。</td>
</tr>
<tr>
<td>chunk-key.even-distribution.factor.lower-bound</td>
<td>optional</td>
<td style="word-wrap: break-word;">0.05d</td>
<td>Double</td>
- <td>The lower bound of chunk key distribution factor. The distribution factor is used to determine whether the table is evenly distribution or not.
- The table chunks would use evenly calculation optimization when the data distribution is even, and the query for splitting would happen when it is uneven.
- The distribution factor could be calculated by (MAX(id) - MIN(id) + 1) / rowCount.</td>
+ <td>分片键分布因子的下界。分布因子用于判断表的数据分布是否均匀。
+ 当数据分布均匀时,表分片会使用均匀计算优化;当数据分布不均匀时,则会通过查询进行拆分。
+ 分布因子可通过 (MAX(id) - MIN(id) + 1) / rowCount 计算。</td>
</tr>
<tr>
<td>chunk-key.even-distribution.factor.upper-bound</td>
<td>optional</td>
<td style="word-wrap: break-word;">1000.0d</td>
<td>Double</td>
- <td>The upper bound of chunk key distribution factor. The distribution factor is used to determine whether the table is evenly distribution or not.
- The table chunks would use evenly calculation optimization when the data distribution is even, and the query for splitting would happen when it is uneven.
- The distribution factor could be calculated by (MAX(id) - MIN(id) + 1) / rowCount.</td>
+ <td>分片键分布因子的上界。分布因子用于判断表的数据分布是否均匀。
+ 当数据分布均匀时,表分片会使用均匀计算优化;当数据分布不均匀时,则会通过查询进行拆分。
+ 分布因子可通过 (MAX(id) - MIN(id) + 1) / rowCount 计算。</td>
</tr>
<tr>
<td>scan.incremental.snapshot.chunk.key-column</td>
<td>optional</td>
<td style="word-wrap: break-word;">(none)</td>
<td>String</td>
- <td>The chunk key of table snapshot, captured tables are split into multiple chunks by a chunk key when read the snapshot of table.
- By default, the chunk key is the first column of the primary key. A column that is not part of the primary key can be used as a chunk key, but this may lead to slower query performance.</td>
+ <td>表快照的分片键,在读取表的快照时,被捕获的表会按分片键拆分为多个分片。
+ 默认情况下,分片键是主键的第一列。可以使用非主键列作为分片键,但这可能会导致查询性能下降。</td>
</tr>
<tr>
<td>debezium.*</td>
<td>optional</td>
<td style="word-wrap: break-word;">(none)</td>
<td>String</td>
- <td>Pass-through Debezium's properties to Debezium Embedded Engine which is used to capture data changes from
-Db2 server.
- For example: <code>'debezium.snapshot.mode' = 'never'</code>.
- See more about the <a href="https://debezium.io/documentation/reference/1.9/connectors/db2.html#db2-connector-properties">Debezium's Db2 Connector properties</a></td>
+ <td>将 Debezium 的属性传递给 Debezium 嵌入式引擎,该引擎用于从 Db2 服务器捕获数据更改。
+ 例如:<code>'debezium.snapshot.mode' = 'never'</code>.
+ 查看更多关于 <a href="https://debezium.io/documentation/reference/1.9/connectors/db2.html#db2-connector-properties"> Debezium 的 Db2 连接器属性</a></td>
</tr>
<tr>
<td>scan.incremental.close-idle-reader.enabled</td>
<td>optional</td>
<td style="word-wrap: break-word;">false</td>
<td>Boolean</td>
- <td>Whether to close idle readers at the end of the snapshot phase. <br>
- 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.<br>
- 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'
+ <td>是否在快照阶段结束后关闭空闲的 Reader。 <br>
+ 当 'execution.checkpointing.checkpoints-after-tasks-finish.enabled' 设置为 true 时,要求 flink 版本大于等于 1.14。<br>
+ 如果 flink 版本大于等于 1.15,'execution.checkpointing.checkpoints-after-tasks-finish.enabled' 的默认值已变更为 true,
+ 因此不需要显式配置 'execution.checkpointing.checkpoints-after-tasks-finish.enabled' = 'true'
</td>
</tr>
<tr>
@@ -271,24 +264,24 @@ Db2 server.
<td>Boolean</td>
<td>是否在 source 进入增量阶段后,释放 source coordinator 持有的快照分片元数据(已分配的分片、已完成分片的位点以及表结构),以降低快照分片数量非常大的作业的 JobManager 内存占用。默认关闭。仅在成功完成一次 checkpoint 后才会释放;若未开启 checkpoint 或没有 checkpoint 完成,则会保留该元数据,因此该配置项在未开启 checkpoint 时不生效。开启该配置项后生成的 checkpoint 或 savepoint,无法在降级到 Flink CDC 3.6.0 及更早版本后用于恢复作业。</td>
</tr>
- <tr>
+ <tr>
<td>scan.incremental.snapshot.unbounded-chunk-first.enabled</td>
<td>optional</td>
<td style="word-wrap: break-word;">true</td>
<td>Boolean</td>
<td>
- Whether to assign the unbounded chunks first during snapshot reading phase.<br>
- This might help reduce the risk of the TaskManager experiencing an out-of-memory (OOM) error when taking a snapshot of the largest unbounded chunk.<br>
+ 快照读取阶段是否先分配 UnboundedChunk。<br>
+ 这可能有助于降低 TaskManager 在对最大的 UnboundedChunk 执行快照时出现内存溢出 (OOM) 错误的风险。<br>
</td>
</tr>
</tbody>
</table>
</div>
-Available Metadata
+可用的元数据
----------------
-The following format metadata can be exposed as read-only (VIRTUAL) columns in a table definition.
+下表中的元数据可以在 DDL 中作为只读(虚拟)meta 列声明。
<table class="colwidths-auto docutils">
<thead>
@@ -302,37 +295,36 @@ The following format metadata can be exposed as read-only (VIRTUAL) columns in a
<tr>
<td>table_name</td>
<td>STRING NOT NULL</td>
- <td>Name of the table that contain the row.</td>
+ <td>当前记录所属的表名称。</td>
</tr>
<tr>
<td>schema_name</td>
<td>STRING NOT NULL</td>
- <td>Name of the schema that contain the row.</td>
+ <td>当前记录所属的 schema 名称。</td>
</tr>
<tr>
<td>database_name</td>
<td>STRING NOT NULL</td>
- <td>Name of the database that contain the row.</td>
+ <td>当前记录所属的库名称。</td>
</tr>
<tr>
<td>op_ts</td>
<td>TIMESTAMP_LTZ(3) NOT NULL</td>
- <td>It indicates the time that the change was made in the database. <br>If the record is read from snapshot of the table instead of the change stream, the value is always 0.</td>
+ <td>当前记录表在数据库中更新的时间。 <br>如果从表的快照而不是更改流读取记录,该值将始终为0。</td>
</tr>
</tbody>
</table>
-Features
+特性
--------
-### Startup Reading Position
+### 启动模式
-The config option `scan.startup.mode` specifies the startup mode for DB2 CDC consumer. The valid enumerations are:
+配置选项`scan.startup.mode`指定 DB2 CDC 使用者的启动模式。有效枚举包括:
-- `initial` (default): Performs an initial snapshot on the monitored database tables upon first startup, and continue to read the latest redo logs.
-- `latest-offset`: Never to perform snapshot on the monitored database tables upon first startup, just read from
- the end of the redo logs which means only have the changes since the connector was started.
+- `initial` (默认):在第一次启动时对受监视的数据库表执行初始快照,并继续读取最新的 redo logs。
+- `latest-offset`:首次启动时,从不对受监视的数据库表执行快照, 连接器仅从 redo logs 的结尾处开始读取,这意味着连接器只能读取在连接器启动之后的数据更改。
-_Note: the mechanism of `scan.startup.mode` option relying on Debezium's `snapshot.mode` configuration. So please do not using them together. If you speicifying both `scan.startup.mode` and `debezium.snapshot.mode` options in the table DDL, it may make `scan.startup.mode` doesn't work._
+_注意:`scan.startup.mode` 选项的机制依赖于 Debezium 的 `snapshot.mode` 配置,因此请不要同时使用它们。如果在表 DDL 中同时指定 `scan.startup.mode` 和 `debezium.snapshot.mode` 选项,可能会导致 `scan.startup.mode` 失效。_
### DataStream Source
@@ -371,27 +363,7 @@ public class Db2SourceExample {
}
```
-### 可用的指标
-
-指标系统能够帮助了解分片分发的进展, 下面列举出了支持的 Flink 指标 [Flink metrics](https://nightlies.apache.org/flink/flink-docs-master/docs/ops/metrics/):
-
-| Group | Name | Type | Description |
-|------------------------|----------------------------|-------|----------------|
-| namespace.schema.table | isSnapshotting | Gauge | 表是否在快照读取阶段 |
-| namespace.schema.table | isStreamReading | Gauge | 表是否在增量读取阶段 |
-| namespace.schema.table | numTablesSnapshotted | Gauge | 已经被快照读取完成的表的数量 |
-| namespace.schema.table | numTablesRemaining | Gauge | 还没有被快照读取的表的数据 |
-| namespace.schema.table | numSnapshotSplitsProcessed | Gauge | 正在处理的分片的数量 |
-| namespace.schema.table | numSnapshotSplitsRemaining | Gauge | 还没有被处理的分片的数量 |
-| namespace.schema.table | numSnapshotSplitsFinished | Gauge | 已经处理完成的分片的数据 |
-| namespace.schema.table | snapshotStartTime | Gauge | 快照读取阶段开始的时间 |
-| namespace.schema.table | snapshotEndTime | Gauge | 快照读取阶段结束的时间 |
-
-注意:
-1. Group 名称是 `namespace.schema.table`,这里的 `namespace` 是实际的数据库名称, `schema` 是实际的 schema 名称, `table` 是实际的表名称。
-2. 对于 DB2,Group 的名称会类似于 `test_database.test_schema.test_table`。
-
-The DB2 CDC incremental connector (since 3.1.0) can be used as the following shows:
+DB2 CDC 增量连接器(自 3.1.0 版本起)可以按如下方式使用:
```java
import org.apache.flink.api.common.eventtime.WatermarkStrategy;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
@@ -431,42 +403,64 @@ public class Db2ParallelSourceExample {
}
```
-### Tables Without primary keys
+### 可用的指标
+
+指标系统能够帮助了解分片分发的进展, 下面列举出了支持的 Flink 指标 [Flink metrics](https://nightlies.apache.org/flink/flink-docs-master/docs/ops/metrics/):
+
+| Group | Name | Type | Description |
+|------------------------|----------------------------|-------|----------------|
+| namespace.schema.table | isSnapshotting | Gauge | 表是否在快照读取阶段 |
+| namespace.schema.table | isStreamReading | Gauge | 表是否在增量读取阶段 |
+| namespace.schema.table | numTablesSnapshotted | Gauge | 已经被快照读取完成的表的数量 |
+| namespace.schema.table | numTablesRemaining | Gauge | 还没有被快照读取的表的数据 |
+| namespace.schema.table | numSnapshotSplitsProcessed | Gauge | 正在处理的分片的数量 |
+| namespace.schema.table | numSnapshotSplitsRemaining | Gauge | 还没有被处理的分片的数量 |
+| namespace.schema.table | numSnapshotSplitsFinished | Gauge | 已经处理完成的分片的数据 |
+| namespace.schema.table | snapshotStartTime | Gauge | 快照读取阶段开始的时间 |
+| namespace.schema.table | snapshotEndTime | Gauge | 快照读取阶段结束的时间 |
+
+注意:
+1. Group 名称是 `namespace.schema.table`,这里的 `namespace` 是实际的数据库名称, `schema` 是实际的 schema 名称, `table` 是实际的表名称。
+2. 对于 DB2,Group 的名称会类似于 `test_database.test_schema.test_table`。
+
+### 关于无主键表
+
+从3.4.0 版本开始支持无主键表,使用无主键表必须设置 `scan.incremental.snapshot.chunk.key-column`,且只能选择非空类型的一个字段。
+
+在使用无主键表时,需要注意以下两种情况。
-Starting from version 3.4.0, DB2 CDC support tables that do not have a primary key. To use a table without primary keys, you must configure the `scan.incremental.snapshot.chunk.key-column` option and specify one non-null field.
+1. 配置 `scan.incremental.snapshot.chunk.key-column` 时,如果表中存在索引,请尽量使用索引中的列来加快 select 速度。
+2. 无主键表的处理语义由 `scan.incremental.snapshot.chunk.key-column` 指定的列的行为决定:
+* 如果指定的列不存在更新操作,此时可以保证 Exactly once 语义。
+* 如果指定的列存在更新操作,此时只能保证 At least once 语义。但可以结合下游,通过指定下游主键,结合幂等性操作来保证数据的正确性。
-There are two places that need to be taken care of.
+#### 警告
-1. If there is an index in the table, try to use a column which is contained in the index in `scan.incremental.snapshot.chunk.key-column`. This will increase the speed of select statement.
-2. The processing semantics of a DB2 CDC table without primary keys is determined based on the behavior of the column that are specified by the `scan.incremental.snapshot.chunk.key-column`.
-* If no update operation is performed on the specified column, the exactly-once semantics is ensured.
-* If the update operation is performed on the specified column, only the at-least-once semantics is ensured. However, you can specify primary keys at downstream and perform the idempotence operation to ensure data correctness.
+在 DB2 表中,若使用 **非主键列** 作为有主键表的 `scan.incremental.snapshot.chunk.key-column`,可能导致**数据不一致**。以下为可能出现的问题及其缓解方案。
-#### Warning
+#### 问题场景
-Using a **non-primary key column** as the `scan.incremental.snapshot.chunk.key-column` for a DB2 table with primary keys may lead to data inconsistencies. Below is a scenario illustrating this issue and recommendations to mitigate potential problems.
+- **表结构:**
+ - **主键:** `id`
+ - **分片键列 :** `pid`(非主键)
-#### Problem Scenario
+- **快照分片 :**
+ - **分片 0:** `1 < pid <= 3`
+ - **分片 1:** `3 < pid <= 5`
-- **Table Structure:**
- - **Primary Key:** `id`
- - **Chunk Key Column:** `pid` (Not a primary key)
+- **操作 :**
+ - 两个子任务并行读取 **分片 0** 和 **分片 1**。
+ - 在读取过程中,发生了一次 **更新** 操作,使 `id=0` 的 `pid` 从 `2` 变为 `4`,在两个分片的**高低水位**间都包含此次变更,导致该更新操作在增量阶段不会被处理。
-- **Snapshot Splits:**
- - **Split 0:** `1 < pid <= 3`
- - **Split 1:** `3 < pid <= 5`
+- **结果 :**
+ - **分片 0:** 记录 `[id=0, pid=2]`
+ - **分片 1:** 记录 `[id=0, pid=4]`
-- **Operation:**
- - Two different subtasks are reading Split 0 and Split 1 concurrently.
- - An update operation changes `pid` from `2` to `4` for `id=0` while both splits are being read. This update occurs between the low and high watermark of both splits.
+由于**处理顺序**无法保证,最终 `id=0` 的 `pid` 可能为 `2` 或 `4`,从而导致数据不一致。
-- **Result:**
- - **Split 0:** Contains the record `[id=0, pid=2]`
- - **Split 1:** Contains the record `[id=0, pid=4]`
-Since the order of processing these records cannot be guaranteed, the final value of `pid` for `id=0` may end up being either `2` or `4`, leading to potential data inconsistencies.
-Data Type Mapping
+数据类型映射
----------------
<div class="wy-table-responsive">
diff --git a/docs/content.zh/docs/connectors/flink-sources/mongodb-cdc.md b/docs/content.zh/docs/connectors/flink-sources/mongodb-cdc.md
index 02a0cb345..d3367d90c 100644
--- a/docs/content.zh/docs/connectors/flink-sources/mongodb-cdc.md
+++ b/docs/content.zh/docs/connectors/flink-sources/mongodb-cdc.md
@@ -31,25 +31,19 @@ MongoDB CDC 连接器允许从 MongoDB 读取快照数据和增量数据。 本
依赖
------------
-为了设置 MongoDB CDC 连接器, 下表提供了使用构建自动化工具(如 Maven 或 SBT )和带有 SQLJar 捆绑包的 SQLClient 的两个项目的依赖关系信息。
+为了设置 MongoDB CDC 连接器,下表提供了使用构建自动化工具(如 Maven 或 SBT )和带有 SQL JAR 包的 SQL 客户端的两个项目的依赖关系信息。
### Maven dependency
-```
-<dependency>
- <groupId>org.apache.flink</groupId>
- <artifactId>flink-connector-mongodb-cdc</artifactId>
- <!-- 请使用已发布的版本依赖,snapshot 版本的依赖需要本地自行编译。 -->
- <version>3.3-SNAPSHOT</version>
-</dependency>
-```
+
+{{< artifact flink-connector-mongodb-cdc >}}
### SQL Client JAR
```下载链接仅适用于稳定版本。```
-下载 [flink-sql-connector-mongodb-cdc](https://mvnrepository.com/artifact/org.apache.flink/flink-sql-connector-mongodb-cdc), 把它放在 `<FLINK_HOME>/lib/`.
+下载 [flink-sql-connector-mongodb-cdc](https://mvnrepository.com/artifact/org.apache.flink/flink-sql-connector-mongodb-cdc) 到 `<FLINK_HOME>/lib/` 目录下。
-**注意:** 参考 [flink-sql-connector-mongodb-cdc](https://mvnrepository.com/artifact/org.apache.flink/flink-sql-connector-mongodb-cdc), 当前已发布的版本将在 Maven 中央仓库中提供。
+**注意:** 参考 [flink-sql-connector-mongodb-cdc](https://mvnrepository.com/artifact/org.apache.flink/flink-sql-connector-mongodb-cdc) 当前已发布的所有版本都可以在 Maven 中央仓库获取。
设置 MongoDB
----------------
@@ -75,7 +69,7 @@ MongoDB CDC 连接器允许从 MongoDB 读取快照数据和增量数据。 本
- 权限
- `changeStream` and `read` 是 MongoDB Kafka Connector 必需权限。
+ `changeStream` 和 `read` 权限是 MongoDB Kafka Connector 所必需的。
你可以使用以下示例进行简单的授权。<br>
有关更详细的授权, 请参照 [MongoDB 数据库用户角色](https://docs.mongodb.com/manual/reference/built-in-roles/#database-user-roles).
@@ -86,7 +80,7 @@ MongoDB CDC 连接器允许从 MongoDB 读取快照数据和增量数据。 本
{
role: "flinkrole",
privileges: [{
- // 所有数据库中所有非系统集合的 grant 权限
+ // Grant privileges on all non-system collections in all databases
resource: { db: "", collection: "" },
actions: [
"splitVector",
@@ -97,8 +91,8 @@ MongoDB CDC 连接器允许从 MongoDB 读取快照数据和增量数据。 本
"changeStream" ]
}],
roles: [
- // 阅读 config.collections 和 config.chunks
- // 用于分片集群快照拆分。
+ // Read config.collections and config.chunks
+ // for sharded cluster snapshot splitting.
{ role: 'read', db: 'config' }
]
}
@@ -146,7 +140,7 @@ SELECT * FROM products;
**请注意**
-MongoDB 的更改事件记录在消息之前没有更新。因此,我们只能将其转换为 Flink 的 UPSERT 更改日志流。
+MongoDB 的更改事件记录没有 UPDATE_BEFORE 消息。因此,我们只能将其转换为 Flink 的 UPSERT 更改日志流。
因为 upsert 流需要唯一键,所以我们必须声明 `_id` 作为主键。
我们不能将其他列声明为主键, 因为删除操作不包含除 `_id` 和 `sharding key` 之外的键和值。
@@ -304,6 +298,13 @@ MongoDB 的更改事件记录在消息之前没有更新。因此,我们只能
<td>Integer</td>
<td>心跳间隔(毫秒)。使用 0 禁用。</td>
</tr>
+ <tr>
+ <td>scan.full-changelog</td>
+ <td>optional</td>
+ <td style="word-wrap: break-word;">false</td>
+ <td>Boolean</td>
+ <td>是否尝试基于 MongoDB 中的前镜像和后镜像生成 full-mode changelog。详情请参阅 <a href="#a-name-id-003-a">Full Changelog</a>。仅支持 MongoDB 6.0 及以上版本。</td>
+ </tr>
<tr>
<td>scan.incremental.snapshot.enabled</td>
<td>optional</td>
@@ -316,14 +317,25 @@ MongoDB 的更改事件记录在消息之前没有更新。因此,我们只能
<td>optional</td>
<td style="word-wrap: break-word;">64</td>
<td>Integer</td>
- <td>增量快照的区块大小 mb。</td>
+ <td>增量快照的分片大小 mb。</td>
+ </tr>
+ <tr>
+ <td>scan.incremental.snapshot.chunk.samples</td>
+ <td>optional</td>
+ <td style="word-wrap: break-word;">20</td>
+ <td>Integer</td>
+ <td>增量快照期间使用 sample 分区策略时每个分片的采样数量。</td>
</tr>
<tr>
<td>scan.incremental.close-idle-reader.enabled</td>
<td>optional</td>
<td style="word-wrap: break-word;">false</td>
<td>Boolean</td>
- <td>是否在快照结束后关闭空闲的 Reader。 此特性需要 flink 版本大于等于 1.14 并且 'execution.checkpointing.checkpoints-after-tasks-finish.enabled' 需要设置为 true。</td>
+ <td>是否在快照阶段结束后关闭空闲的 Reader。 <br>
+ 当 'execution.checkpointing.checkpoints-after-tasks-finish.enabled' 设置为 true 时,要求 flink 版本大于等于 1.14。<br>
+ 如果 flink 版本大于等于 1.15,'execution.checkpointing.checkpoints-after-tasks-finish.enabled' 的默认值已变更为 true,
+ 因此不需要显式配置 'execution.checkpointing.checkpoints-after-tasks-finish.enabled' = 'true'
+ </td>
</tr>
<tr>
<td>scan.incremental.snapshot.metadata.release.enabled</td>
@@ -332,6 +344,13 @@ MongoDB 的更改事件记录在消息之前没有更新。因此,我们只能
<td>Boolean</td>
<td>是否在 source 进入增量阶段后,释放 source coordinator 持有的快照分片元数据(已分配的分片、已完成分片的位点以及表结构),以降低快照分片数量非常大的作业的 JobManager 内存占用。默认关闭。与 scan.newly-added-table.enabled 不兼容:同时开启两者会导致作业启动失败,且已释放元数据的作业无法再开启动态加表功能。仅在成功完成一次 checkpoint 后才会释放;若未开启 checkpoint 或没有 checkpoint 完成,则会保留该元数据,因此该配置项在未开启 checkpoint 时不生效。开启该配置项后生成的 checkpoint 或 savepoint,无法在降级到 Flink CDC 3.6.0 及更早版本后用于恢复作业。</td>
</tr>
+ <tr>
+ <td>scan.cursor.no-timeout</td>
+ <td>optional</td>
+ <td style="word-wrap: break-word;">true</td>
+ <td>Boolean</td>
+ <td>MongoDB 服务器通常会在空闲一段时间(10 分钟)后使游标超时,以防止占用过多内存。将该选项设置为 true 可以避免游标超时。仅在启用并行快照时可用。</td>
+ </tr>
<tr>
<td>scan.incremental.snapshot.unbounded-chunk-first.enabled</td>
<td>optional</td>
@@ -339,7 +358,7 @@ MongoDB 的更改事件记录在消息之前没有更新。因此,我们只能
<td>Boolean</td>
<td>
快照读取阶段是否先分配 UnboundedChunk。<br>
- 这有助于降低 TaskManager 在快照阶段同步最后一个chunk时遇到内存溢出 (OOM) 的风险。<br>
+ 这可能有助于降低 TaskManager 在对最大的 UnboundedChunk 执行快照时出现内存溢出 (OOM) 错误的风险。<br>
</td>
</tr>
<tr>
@@ -348,10 +367,10 @@ MongoDB 的更改事件记录在消息之前没有更新。因此,我们只能
<td style="word-wrap: break-word;">false</td>
<td>Boolean</td>
<td>
- Whether to skip backfill in snapshot reading phase.<br>
- If backfill is skipped, changes on captured tables during snapshot phase will be consumed later in change log reading phase instead of being merged into the snapshot.<br>
- WARNING: Skipping backfill might lead to data inconsistency because some change log events happened within the snapshot phase might be replayed (only at-least-once semantic is promised).
- For example updating an already updated value in snapshot, or deleting an already deleted entry in snapshot. These replayed change log events should be handled specially.
+ 是否在快照读取阶段跳过 backfill 。<br>
+ 如果跳过 backfill ,快照阶段捕获表的更改将在稍后的 changelog 读取阶段被回放,而不是合并到快照中。<br>
+ 警告:跳过 backfill 可能会导致数据不一致,因为快照阶段发生的某些 changelog 事件可能会被重放(仅保证 at-least-once )。
+ 例如,更新快照阶段已更新的值,或删除快照阶段已删除的数据。这些重放的 changelog 事件应进行特殊处理。
</td>
</tr>
<tr>
@@ -415,7 +434,7 @@ MongoDB 的更改事件记录在消息之前没有更新。因此,我们只能
</div>
注意: `heartbeat.interval.ms` 强烈建议设置一个大于 0 的适当值 **如果集合更改缓慢**.
-当我们从检查点或保存点恢复 Flink 作业时,心跳事件可以向前推送 `resumeToken`,以避免 `resumeToken` 过期。
+当我们从 checkpoint 或 savepoint 恢复 Flink 作业时,心跳事件可以向前推送 `resumeToken`,以避免 `resumeToken` 过期。
注意: `mongodb.ssl.*` 相关配置仅在开启增量快照(`scan.incremental.snapshot.enabled` = `true`)时才会生效,非增量快照的数据源会忽略这些配置。
@@ -446,7 +465,7 @@ MongoDB 的更改事件记录在消息之前没有更新。因此,我们只能
<tr>
<td>op_ts</td>
<td>TIMESTAMP_LTZ(3) NOT NULL</td>
- <td>它指示在数据库中进行更改的时间。 <br>如果记录是从表的快照而不是改变流中读取的,该值将始终为0。</td>
+ <td>当前记录表在数据库中更新的时间。 <br>如果从表的快照而不是更改流读取记录,该值将始终为0。</td>
</tr>
<tr>
<td>row_kind</td>
@@ -484,13 +503,13 @@ CREATE TABLE products (
特性
--------
-### 精确一次处理
+### Exactly-Once 处理
-MongoDB CDC 连接器是一个 Flink Source 连接器,它将首先读取数据库快照,然后在处理**甚至失败时继续读取带有**的更改流事件。
+MongoDB CDC 连接器是一个 Flink Source 连接器,它将首先读取数据库快照,然后继续读取更改流事件,即使在处理时出现故障,也能**准确读取数据**。
### 启动模式
-配置选项```scan.startup.mode```指定 MongoDB CDC 消费者的启动模式。有效枚举包括:
+配置选项`scan.startup.mode`指定 MongoDB CDC 消费者的启动模式。有效枚举包括:
- `initial` (默认):在第一次启动时对受监视的数据库表执行初始快照,并继续读取最新的 oplog。
- `latest-offset`:首次启动时,从不对受监视的数据库表执行快照, 连接器仅从 oplog 的结尾处开始读取,这意味着连接器只能读取在连接器启动之后的数据更改。
@@ -504,23 +523,19 @@ MongoDBSource.builder()
.build()
```
-and with SQL:
+使用 SQL:
```SQL
CREATE TABLE mongodb_source (...) WITH (
'connector' = 'mongodb-cdc',
- 'scan.startup.mode' = 'latest-offset', -- 从最晚位点启动
+ 'scan.startup.mode' = 'latest-offset', -- Start from latest offset
...
- 'scan.incremental.snapshot.enabled' = 'true', -- 指定时间戳启动,需要开启增量快照读
- 'scan.startup.mode' = 'timestamp', -- 指定时间戳启动模式
- 'scan.startup.timestamp-millis' = '1667232000000' -- 启动毫秒时间
+ 'scan.startup.mode' = 'timestamp', -- Start from timestamp
+ 'scan.startup.timestamp-millis' = '1667232000000' -- Timestamp under timestamp startup mode
...
)
```
-**Notes:**
-- 'timestamp' 指定时间戳启动模式,需要开启增量快照读。
-
### 快照数据筛选器
配置选项 `initial.snapshotting.pipeline` 描述复制现有数据时的筛选器。<br>
@@ -534,31 +549,31 @@ CREATE TABLE mongodb_source (...) WITH (
### 更改流
-我们将 [MongoDB's official Kafka Connector](https://docs.mongodb.com/kafka-connector/current/kafka-source/) 从 MongoDB 中读取快照或更改事件,并通过 Debezium 的 `EmbeddedEngine` 进行驱动。
+我们集成了 [MongoDB's official Kafka Connector](https://docs.mongodb.com/kafka-connector/current/kafka-source/),从 MongoDB 中读取快照或更改事件,并通过 Debezium 的 `EmbeddedEngine` 进行驱动。
Debezium 的 `EmbeddedEngine` 提供了一种在应用程序进程中运行单个 Kafka Connect `SourceConnector` 的机制,并且它可以正确地驱动任何标准的 Kafka Connect `SourceConnector`,即使它不是由 Debezium 提供的。
我们选择 **MongoDB 的官方 Kafka连接器**,而不是 **Debezium 的MongoDB 连接器**,因为它们使用了不同的更改数据捕获机制。
-- 对于 Debezium 的 MongoDB 连接器,它读取每个复制集主节点的 `oplog.rs` 集合。
+- 对于 Debezium 的 MongoDB 连接器,它读取每个副本集主节点的 `oplog.rs` 集合。
- 对于 MongoDB 的 Kafka 连接器,它订阅了 MongoDB 的 `更改流`。
-MongoDB 的`oplog.rs` 集合没有在状态之前保持更改记录的更新, 因此,很难通过单个 `oplog.rs` 记录提取完整的文档状态,并将其转换为 Flink 接受的更改日志流(Insert Only,Upsert,All)。
+MongoDB 的 `oplog.rs` 集合不会保留更改记录的更新前状态,因此很难通过单个 `oplog.rs` 记录提取完整的文档状态,并将其转换为 Flink 接受的更改日志流(Insert Only,Upsert,All)。
此外,MongoDB 5(2021 7月发布)改变了 oplog 格式,因此当前的 Debezium 连接器不能与其一起使用。
-**Change Stream**是 MongoDB 3.6 为副本集和分片集群提供的一项新功能,它允许应用程序访问实时数据更改,而不会带来跟踪操作日志的复杂性和风险。<br>
-应用程序可以使用更改流来订阅单个集合上的所有数据更改, 数据库或整个部署,并立即对其做出反应。
+**Change Stream**是 MongoDB 3.6 为副本集和分片集群提供的一项新功能,它允许应用程序访问实时数据更改,而不会带来跟踪 oplog 的复杂性和风险。<br>
+应用程序可以使用更改流来订阅单个集合、数据库或整个部署上的所有数据更改,并立即对其做出反应。
-**查找更新操作的完整文档**是**变更流**提供的一项功能,它可以配置变更流以返回更新文档的最新多数提交版本。由于该功能,我们可以轻松收集最新的完整文档,并将更改日志转换为 Flink 的**Upsert Changelog Stream**。
+**查找更新操作的完整文档**是**更改流**提供的一项功能,它可以配置更改流以返回更新文档的最新多数提交版本。由于该功能,我们可以轻松收集最新的完整文档,并将更改日志转换为 Flink 的**Upsert Changelog Stream**。
-顺便说一句,[DBZ-435](https://issues.redhat.com/browse/DBZ-435)提到的Debezium的MongoDB变更流探索,正在制定路线图。<br>
+顺便说一句,[DBZ-435](https://issues.redhat.com/browse/DBZ-435)提到的Debezium的MongoDB更改流探索,正在制定路线图。<br>
如果完成了,我们可以考虑集成两种源连接器供用户选择。
### 动态加表
**注意:** 该功能从 Flink CDC 3.1.0 版本开始支持。
-动态加表功能使你可以为正在运行的作业添加新集合进行监控。新添加的集合将首先读取其快照数据,然后自动读取其变更流。
+动态加表功能使你可以为正在运行的作业添加新集合进行监控。新添加的集合将首先读取其快照数据,然后自动读取其更改流。
想象一下这个场景:一开始,Flink 作业监控集合 `[product, user, address]`,但几天后,我们希望这个作业还可以监控集合 `[order, custom]`,这些集合包含历史数据,我们需要作业仍然可以复用作业的已有状态。动态加表功能可以优雅地解决此问题。
@@ -567,14 +582,14 @@ MongoDB 的`oplog.rs` 集合没有在状态之前保持更改记录的更新,
```java
MongoDBSource<String> mongoSource = MongoDBSource.<String>builder()
.hosts("yourHostname:27017")
- .databaseList("db") // 设置捕获的数据库
- .collectionList("db.product", "db.user", "db.address") // 设置捕获的集合
+ .databaseList("db") // set captured database
+ .collectionList("db.product", "db.user", "db.address") // set captured collections
.username("yourUsername")
.password("yourPassword")
- .scanNewlyAddedTableEnabled(true) // 启用扫描新添加的表功能
- .deserializer(new JsonDebeziumDeserializationSchema()) // 将 SourceRecord 转换为 JSON 字符串
+ .scanNewlyAddedTableEnabled(true) // enable scan the newly added collections feature
+ .deserializer(new JsonDebeziumDeserializationSchema()) // converts SourceRecord to JSON String
.build();
- // 你的业务代码
+ // your business code
```
如果我们想添加新集合 `[order, custom]` 到现有的 Flink 作业,只需更新作业的 `collectionList()` 将新增集合 `[order, custom]` 加入并从已有的 savepoint 恢复作业。
@@ -594,13 +609,13 @@ _Step 2_: 更新现有 Flink 作业的集合列表选项。
MongoDBSource<String> mongoSource = MongoDBSource.<String>builder()
.hosts("yourHostname:27017")
.databaseList("db")
- .collectionList("db.product", "db.user", "db.address", "db.order", "db.custom") // 设置捕获的集合 [product, user, address, order, custom]
+ .collectionList("db.product", "db.user", "db.address", "db.order", "db.custom") // set captured collections [product, user, address, order, custom]
.username("yourUsername")
.password("yourPassword")
- .scanNewlyAddedTableEnabled(true)
- .deserializer(new JsonDebeziumDeserializationSchema()) // 将 SourceRecord 转换为 JSON 字符串
+ .scanNewlyAddedTableEnabled(true) // enable scan newly added tables feature
+ .deserializer(new JsonDebeziumDeserializationSchema()) // converts SourceRecord to JSON String
.build();
- // 你的业务代码
+ // your business code
```
_Step 3_: 从 savepoint 还原更新后的 Flink 作业。
```shell
@@ -627,15 +642,15 @@ public class MongoDBSourceExample {
.hosts("localhost:27017")
.username("flink")
.password("flinkpw")
- .databaseList("inventory") // 设置捕获的数据库,支持正则表达式
- .collectionList("inventory.products", "inventory.orders") //设置捕获的集合,支持正则表达式
+ .databaseList("inventory") // set captured database, support regex
+ .collectionList("inventory.products", "inventory.orders") //set captured collections, support regex
.deserializer(new JsonDebeziumDeserializationSchema())
.build();
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
env.addSource(sourceFunction)
- .print().setParallelism(1); // 对 sink 使用并行度 1 以保持消息顺序
+ .print().setParallelism(1); // use parallelism 1 for sink to keep message ordering
env.execute();
}
@@ -654,17 +669,17 @@ public class MongoDBIncrementalSourceExample {
MongoDBSource<String> mongoSource =
MongoDBSource.<String>builder()
.hosts("localhost:27017")
- .databaseList("inventory") // 设置捕获的数据库,支持正则表达式
- .collectionList("inventory.products", "inventory.orders") //设置捕获的集合,支持正则表达式
+ .databaseList("inventory") // set captured database, support regex
+ .collectionList("inventory.products", "inventory.orders") //set captured collections, support regex
.username("flink")
.password("flinkpw")
.deserializer(new JsonDebeziumDeserializationSchema())
.build();
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
- // 启用检查点
+ // enable checkpoint
env.enableCheckpointing(3000);
- // 将 source 并行度设置为 2
+ // set the source parallelism to 2
env.fromSource(mongoSource, WatermarkStrategy.noWatermarks(), "MongoDBIncrementalSource")
.setParallelism(2)
.print()
@@ -679,41 +694,20 @@ public class MongoDBIncrementalSourceExample {
- 如果使用数据库正则表达式,则需要 `readAnyDatabase` 角色。
- 增量快照功能仅支持 MongoDB 4.0 之后的版本。
-### 可用的指标
-
-指标系统能够帮助了解分片分发的进展, 下面列举出了支持的 Flink 指标 [Flink metrics](https://nightlies.apache.org/flink/flink-docs-master/docs/ops/metrics/):
-
-| Group | Name | Type | Description |
-|------------------------|----------------------------|-------|----------------|
-| namespace.schema.table | isSnapshotting | Gauge | 表是否在快照读取阶段 |
-| namespace.schema.table | isStreamReading | Gauge | 表是否在增量读取阶段 |
-| namespace.schema.table | numTablesSnapshotted | Gauge | 已经被快照读取完成的表的数量 |
-| namespace.schema.table | numTablesRemaining | Gauge | 还没有被快照读取的表的数据 |
-| namespace.schema.table | numSnapshotSplitsProcessed | Gauge | 正在处理的分片的数量 |
-| namespace.schema.table | numSnapshotSplitsRemaining | Gauge | 还没有被处理的分片的数量 |
-| namespace.schema.table | numSnapshotSplitsFinished | Gauge | 已经处理完成的分片的数据 |
-| namespace.schema.table | snapshotStartTime | Gauge | 快照读取阶段开始的时间 |
-| namespace.schema.table | snapshotEndTime | Gauge | 快照读取阶段结束的时间 |
-
-注意:
-1. Group 名称是 `namespace.schema.table`,这里的 `namespace` 是实际的数据库名称, `schema` 是实际的 schema 名称, `table` 是实际的表名称。
-2. 对于 MongoDB,这里的 `namespace` 会被设置成默认值 "",也就是一个空字符串,Group 名称的格式会类似于 `test_database.test_table`。
-
-### 完整的 Changelog
+### 完整的 Changelog<a name="Full Changelog" id="003" ></a>
-MongoDB 6.0 以及更高的版本支持发送变更流事件,其中包含文档的更新前和更新后的内容(或者说数据的前后镜像)。
+MongoDB 6.0 以及更高的版本支持发送更改流事件,其中包含文档的更新前和更新后的内容(或者说数据的前后镜像)。
- 前镜像是指被替换、更新或删除之前的文档。对于插入操作没有前镜像。
-- 后镜像是指被替换、更新或删除之后的文档。对于删除操作没有后镜像。
+- 后镜像是指被插入、替换或更新之后的文档。对于删除操作没有后镜像。
-MongoDB CDC 能够使用前镜像和后镜像来生成完整的变更日志流,包括插入、更新前、更新后和删除的数据行,从而避免了额外的 `ChangelogNormalize` 下游节点。
+MongoDB CDC 能够使用前镜像和后镜像来生成完整的更改日志流,包括插入、更新前、更新后和删除的数据行,从而避免了额外的 `ChangelogNormalize` 下游节点。
为了启用此功能,你需要满足以下条件:
- MongoDB 的版本必须为 6.0 或更高版本。
-- 启用 `preAndPostImages` 功能。
-
+- 在数据库级别启用 `preAndPostImages` 功能:
```javascript
db.runCommand({
setClusterParameter: {
@@ -725,7 +719,6 @@ db.runCommand({
}
})
```
-
- 为希望监控的 collection 启用 `changeStreamPreAndPostImages` 功能:
```javascript
db.runCommand({
@@ -735,8 +728,7 @@ db.runCommand({
}
})
```
-
-在 DataStream 中开启 MongoDB CDC 的 `scan.full-changelog` 功能:
+- 启用 MongoDB CDC 的 `scan.full-changelog` 功能:
```java
MongoDBSource.builder()
@@ -755,6 +747,26 @@ CREATE TABLE mongodb_source (...) WITH (
)
```
+### 可用的指标
+
+指标系统能够帮助了解分片分发的进展, 下面列举出了支持的 Flink 指标 [Flink metrics](https://nightlies.apache.org/flink/flink-docs-master/docs/ops/metrics/):
+
+| Group | Name | Type | Description |
+|------------------------|----------------------------|-------|----------------|
+| namespace.schema.table | isSnapshotting | Gauge | 表是否在快照读取阶段 |
+| namespace.schema.table | isStreamReading | Gauge | 表是否在增量读取阶段 |
+| namespace.schema.table | numTablesSnapshotted | Gauge | 已经被快照读取完成的表的数量 |
+| namespace.schema.table | numTablesRemaining | Gauge | 还没有被快照读取的表的数据 |
+| namespace.schema.table | numSnapshotSplitsProcessed | Gauge | 正在处理的分片的数量 |
+| namespace.schema.table | numSnapshotSplitsRemaining | Gauge | 还没有被处理的分片的数量 |
+| namespace.schema.table | numSnapshotSplitsFinished | Gauge | 已经处理完成的分片的数据 |
+| namespace.schema.table | snapshotStartTime | Gauge | 快照读取阶段开始的时间 |
+| namespace.schema.table | snapshotEndTime | Gauge | 快照读取阶段结束的时间 |
+
+注意:
+1. Group 名称是 `namespace.schema.table`,这里的 `namespace` 是实际的数据库名称, `schema` 是实际的 schema 名称, `table` 是实际的表名称。
+2. 对于 MongoDB,这里的 `namespace` 会被设置成默认值 "",也就是一个空字符串,Group 名称的格式会类似于 `test_database.test_table`。
+
数据类型映射
----------------
[BSON](https://docs.mongodb.com/manual/reference/bson-types/) **二进制 JSON**的缩写是一种类似 JSON 格式的二进制编码序列,用于在 MongoDB 中存储文档和进行远程过程调用。
@@ -876,6 +888,7 @@ CREATE TABLE mongodb_source (...) WITH (
- [WiredTiger](https://docs.mongodb.com/manual/core/wiredtiger/#std-label-storage-wiredtiger)
- [Replica set protocol](https://docs.mongodb.com/manual/reference/replica-configuration/#mongodb-rsconf-rsconf.protocolVersion)
- [Connection String Options](https://docs.mongodb.com/manual/reference/connection-string/#std-label-connections-connection-options)
+- [Document Pre- and Post-Images](https://www.mongodb.com/docs/v6.0/changeStreams/#change-streams-with-document-pre--and-post-images)
- [BSON Types](https://docs.mongodb.com/manual/reference/bson-types/)
- [Flink DataTypes](https://nightlies.apache.org/flink/flink-docs-release-1.20/docs/dev/table/types/)
diff --git a/docs/content.zh/docs/connectors/flink-sources/mysql-cdc.md b/docs/content.zh/docs/connectors/flink-sources/mysql-cdc.md
index c09ba3d4a..a039bfd26 100644
--- a/docs/content.zh/docs/connectors/flink-sources/mysql-cdc.md
+++ b/docs/content.zh/docs/connectors/flink-sources/mysql-cdc.md
@@ -41,14 +41,7 @@ MySQL CDC 连接器允许从 MySQL 数据库读取快照数据和增量数据。
### Maven dependency
-```
-<dependency>
- <groupId>org.apache.flink</groupId>
- <artifactId>flink-connector-mysql-cdc</artifactId>
- <!-- 请使用已发布的版本依赖,snapshot 版本的依赖需要本地自行编译。 -->
- <version>3.3-SNAPSHOT</version>
-</dependency>
-```
+{{< artifact flink-connector-mysql-cdc >}}
### SQL Client JAR
@@ -109,7 +102,7 @@ mysql> FLUSH PRIVILEGES;
### 为每个 Reader 设置不同的 Server id
每个用于读取 binlog 的 MySQL 数据库客户端都应该有一个唯一的 id,称为 Server id。 MySQL 服务器将使用此 id 来维护网络连接和 binlog 位置。 因此,如果不同的作业共享相同的 Server id, 则可能导致从错误的 binlog 位置读取数据。
-因此,建议通过为每个 Reader 设置不同的 Server id [SQL Hints](https://nightlies.apache.org/flink/flink-docs-release-1.20/zh/docs/dev/table/sql/queries/hints/),
+因此,建议通过 [SQL Hints](https://nightlies.apache.org/flink/flink-docs-release-1.20/zh/docs/dev/table/sql/queries/hints/) 为每个 Reader 设置不同的 Server id,
假设 Source 并行度为 4, 我们可以使用 `SELECT * FROM source_table /*+ OPTIONS('server-id'='5401-5404') */ ;` 来为 4 个 Source readers 中的每一个分配唯一的 Server id。
@@ -231,7 +224,7 @@ Flink SQL> SELECT * FROM orders;
<td style="word-wrap: break-word;">(none)</td>
<td>String</td>
<td>读取数据使用的 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.enabled' 参数为启用时,配置成整数范围。每个 id 在 MySQL 集群中当前运行的所有数据库进程之间必须是唯一的。该连接器以另一个 server 的身份(具有此唯一 id)加入 MySQL 集群,从而可以读取 binlog。 默认情况下,连接器会在 5400 和 6400 之间生成一个随机数,但是我们建议用户明确指定 Server id。
</td>
</tr>
<tr>
@@ -242,8 +235,8 @@ Flink SQL> SELECT * FROM orders;
<td>增量快照是一种读取表快照的新机制,与旧的快照机制相比,
增量快照有许多优点,包括:
(1)在快照读取期间,Source 支持并发读取,
- (2)在快照读取期间,Source 支持进行 chunk 粒度的 checkpoint,
- (3)在快照读取之前,Source 不需要数据库锁权限。
+ (2)在快照读取期间,Source 支持进行分片粒度的 checkpoint,
+ (3)在快照读取之前,Source 不需要获取全局读锁(FLUSH TABLES WITH READ LOCK)。
如果希望 Source 并行运行,则每个并行 Readers 都应该具有唯一的 Server id,所以
Server id 必须是类似 `5400-6400` 的范围,并且该范围必须大于并行度。
请查阅 <a href="#增量快照读取">增量快照读取</a> 章节了解更多详细信息。
@@ -254,7 +247,7 @@ Flink SQL> SELECT * FROM orders;
<td>optional</td>
<td style="word-wrap: break-word;">8096</td>
<td>Integer</td>
- <td>表快照的块大小(行数),读取表的快照时,捕获的表被拆分为多个块。</td>
+ <td>表快照的分片大小(行数),读取表的快照时,捕获的表被拆分为多个分片。</td>
</tr>
<tr>
<td>scan.snapshot.fetch.size</td>
@@ -337,8 +330,7 @@ Flink SQL> SELECT * FROM orders;
</td>
</tr>
<tr>
- <td>debezium.min.row.
- count.to.stream.result</td>
+ <td>debezium.min.row.count.to.stream.result</td>
<td>optional</td>
<td style="word-wrap: break-word;">1000</td>
<td>Integer</td>
@@ -369,7 +361,7 @@ Flink SQL> SELECT * FROM orders;
<tr>
<td>jdbc.properties.*</td>
<td>optional</td>
- <td style="word-wrap: break-word;"></td>
+ <td style="word-wrap: break-word;">(none)</td>
<td>String</td>
<td>传递自定义 JDBC URL 属性的选项。用户可以传递自定义属性,如 'jdbc.properties.useSSL' = 'false'.</td>
</tr>
@@ -378,7 +370,7 @@ Flink SQL> SELECT * FROM orders;
<td>optional</td>
<td style="word-wrap: break-word;">30s</td>
<td>Duration</td>
- <td>用于跟踪最新可用 binlog 偏移的发送心跳事件的间隔。</td>
+ <td>用于跟踪最新可用 binlog 位点的发送心跳事件的间隔。</td>
</tr>
<tr>
<td>debezium.*</td>
@@ -386,7 +378,7 @@ Flink SQL> SELECT * FROM orders;
<td style="word-wrap: break-word;">(none)</td>
<td>String</td>
<td>将 Debezium 的属性传递给 Debezium 嵌入式引擎,该引擎用于从 MySQL 服务器捕获数据更改。
- For example: <code>'debezium.snapshot.mode' = 'never'</code>.
+ 例如:<code>'debezium.snapshot.mode' = 'never'</code>.
查看更多关于 <a href="https://debezium.io/documentation/reference/1.9/connectors/mysql.html#mysql-connector-properties"> Debezium 的 MySQL 连接器属性</a></td>
</tr>
<tr>
@@ -401,7 +393,22 @@ Flink SQL> SELECT * FROM orders;
<td>optional</td>
<td style="word-wrap: break-word;">false</td>
<td>Boolean</td>
- <td>是否在快照结束后关闭空闲的 Reader。 此特性需要 flink 版本大于等于 1.14 并且 'execution.checkpointing.checkpoints-after-tasks-finish.enabled' 需要设置为 true。</td>
+ <td>是否在快照阶段结束后关闭空闲的 Reader。 <br>
+ 当 'execution.checkpointing.checkpoints-after-tasks-finish.enabled' 设置为 true 时,要求 flink 版本大于等于 1.14。<br>
+ 如果 flink 版本大于等于 1.15,'execution.checkpointing.checkpoints-after-tasks-finish.enabled' 的默认值已变更为 true,
+ 因此不需要显式配置 'execution.checkpointing.checkpoints-after-tasks-finish.enabled' = 'true'
+ </td>
+ </tr>
+ <tr>
+ <td>debezium.binary.handling.mode</td>
+ <td>optional</td>
+ <td style="word-wrap: break-word;">(none)</td>
+ <td>String</td>
+ <td>debezium.binary.handling.mode 可以设置为以下值之一:
+ none:不做任何处理,binary 数据类型以字节数组(byte array)的形式传输。
+ base64:将 binary 数据类型转换为 Base64 编码的字符串进行传输。
+ hex:将 binary 数据类型转换为十六进制字符串进行传输。
+ 默认值为 none。可以根据需求和数据类型选择合适的处理模式。如果数据库中包含大量 binary 数据类型,建议使用 base64 或 hex 模式,以便在传输过程中更易于处理。</td>
</tr>
<tr>
<td>scan.parse.online.schema.changes.enabled</td>
@@ -412,7 +419,19 @@ Flink SQL> SELECT * FROM orders;
是否尝试解析由 <a href="https://github.com/github/gh-ost">gh-ost</a> 或 <a href="https://docs.percona.com/percona-toolkit/pt-online-schema-change.html">pt-osc</a> 工具生成的表结构变更事件。
这些工具会在变更表结构时,将变更语句应用到“影子表”之上,并稍后将其与主表进行交换,以达到表结构变更的目的。
<br>
- 这是一项实验性功能。
+ 这是一项实验性功能,未来可能会发生变化。
+ </td>
+ </tr>
+ <tr>
+ <td>use.legacy.json.format</td>
+ <td>optional</td>
+ <td style="word-wrap: break-word;">true</td>
+ <td>Boolean</td>
+ <td>是否使用 legacy JSON 格式来转换 Binlog 中的 JSON 类型的数据。 <br>
+ 这代表着是否使用 legacy JSON 格式来转换 Binlog 中的 JSON 类型的数据。
+ 如果用户配置 'use.legacy.json.format' = 'true',则从 Binlog 中转换 JSON 类型的数据时,会移除值之前的空格和逗号之后的空格。例如,
+ Binlog 中 JSON 类型的数据 {"key1": "value1", "key2": "value2"} 会被转换为 {"key1":"value1","key2":"value2"}。
+ 如果设置 'use.legacy.json.format' = 'false', 这条数据会被转换为 {"key1": "value1", "key2": "value2"}, 也就是 key 和 value 前的空格都会被保留。
</td>
</tr>
<tr>
@@ -422,7 +441,7 @@ Flink SQL> SELECT * FROM orders;
<td>Boolean</td>
<td>
快照读取阶段是否先分配 UnboundedChunk。<br>
- 这有助于降低 TaskManager 在快照阶段同步最后一个chunk时遇到内存溢出 (OOM) 的风险。<br>
+ 这可能有助于降低 TaskManager 在对最大的 UnboundedChunk 执行快照时出现内存溢出 (OOM) 错误的风险。<br>
</td>
</tr>
<tr>
@@ -448,17 +467,6 @@ Flink SQL> SELECT * FROM orders;
如果跳过 backfill ,快照阶段捕获表的更改将在稍后的 binlog 读取阶段被回放,而不是合并到快照中。<br>
警告:跳过 backfill 可能会导致数据不一致,因为快照阶段发生的某些 binlog 事件可能会被重放(仅保证 at-least-once )。
例如,更新快照阶段已更新的值,或删除快照阶段已删除的数据。这些重放的 binlog 事件应进行特殊处理。
- </tr>
- <tr>
- <td>use.legacy.json.format</td>
- <td>optional</td>
- <td style="word-wrap: break-word;">true</td>
- <td>Boolean</td>
- <td>是否使用 legacy JSON 格式来转换 Binlog 中的 JSON 类型的数据。 <br>
- 这代表着是否使用 legacy JSON 格式来转换 Binlog 中的 JSON 类型的数据。
- 如果用户配置 'use.legacy.json.format' = 'true',则从 Binlog 中转换 JSON 类型的数据时,会移除值之前的空格和逗号之后的空格。例如,
- Binlog 中 JSON 类型的数据 {"key1": "value1", "key2": "value2"} 会被转换为 {"key1":"value1","key2":"value2"}。
- 如果设置 'use.legacy.json.format' = 'false', 这条数据会被转换为 {"key1": "value1", "key2": "value2"}, 也就是 key 和 value 前的空格都会被保留。
</td>
</tr>
</tbody>
@@ -498,60 +506,64 @@ Flink SQL> SELECT * FROM orders;
<td>row_kind</td>
<td>STRING NOT NULL</td>
<td>当前记录的变更类型。<br>
- 注意:如果 Source 算子选择为每条记录输出 row_kind 列,则下游 SQL 操作符在处理回撤时可能会由于此新添加的列而无法比较,导致出现非确定性更新问题。建议仅在简单的同步作业中使用此元数据列。<br>
+ 注意:如果 Source 算子选择为每条记录输出 row_kind 列,则下游 SQL 操作符在处理回撤时可能会由于此新添加的列而无法比较。建议仅在简单的同步作业中使用此元数据列。<br>
'+I' 表示 INSERT 消息,'-D' 表示 DELETE 消息,'-U' 表示 UPDATE_BEFORE 消息,'+U' 表示 UPDATE_AFTER 消息。</td>
</tr>
</tbody>
</table>
下述创建表示例展示元数据列的用法:
+
```sql
-CREATE TABLE products (
- db_name STRING METADATA FROM 'database_name' VIRTUAL,
- table_name STRING METADATA FROM 'table_name' VIRTUAL,
- operation_ts TIMESTAMP_LTZ(3) METADATA FROM 'op_ts' VIRTUAL,
- operation STRING METADATA FROM 'row_kind' VIRTUAL,
- order_id INT,
- order_date TIMESTAMP(0),
+CREATE TABLE products
+(
+ db_name STRING METADATA FROM 'database_name' VIRTUAL,
+ table_name STRING METADATA FROM 'table_name' VIRTUAL,
+ operation_ts TIMESTAMP_LTZ(3) METADATA FROM 'op_ts' VIRTUAL,
+ operation STRING METADATA FROM 'row_kind' VIRTUAL,
+ order_id INT,
+ order_date TIMESTAMP(0),
customer_name STRING,
- price DECIMAL(10, 5),
- product_id INT,
- order_status BOOLEAN,
- PRIMARY KEY(order_id) NOT ENFORCED
+ price DECIMAL(10, 5),
+ product_id INT,
+ order_status BOOLEAN,
+ PRIMARY KEY (order_id) NOT ENFORCED
) WITH (
- 'connector' = 'mysql-cdc',
- 'hostname' = 'localhost',
- 'port' = '3306',
- 'username' = 'root',
- 'password' = '123456',
- 'database-name' = 'mydb',
- 'table-name' = 'orders'
-);
+ 'connector' = 'mysql-cdc',
+ 'hostname' = 'localhost',
+ 'port' = '3306',
+ 'username' = 'root',
+ 'password' = '123456',
+ 'database-name' = 'mydb',
+ 'table-name' = 'orders'
+ );
```
下述创建表示例展示使用正则表达式匹配多张库表的用法:
+
```sql
-CREATE TABLE products (
- db_name STRING METADATA FROM 'database_name' VIRTUAL,
- table_name STRING METADATA FROM 'table_name' VIRTUAL,
- operation_ts TIMESTAMP_LTZ(3) METADATA FROM 'op_ts' VIRTUAL,
- operation STRING METADATA FROM 'row_kind' VIRTUAL,
- order_id INT,
- order_date TIMESTAMP(0),
+CREATE TABLE products
+(
+ db_name STRING METADATA FROM 'database_name' VIRTUAL,
+ table_name STRING METADATA FROM 'table_name' VIRTUAL,
+ operation_ts TIMESTAMP_LTZ(3) METADATA FROM 'op_ts' VIRTUAL,
+ operation STRING METADATA FROM 'row_kind' VIRTUAL,
+ order_id INT,
+ order_date TIMESTAMP(0),
customer_name STRING,
- price DECIMAL(10, 5),
- product_id INT,
- order_status BOOLEAN,
- PRIMARY KEY(order_id) NOT ENFORCED
+ price DECIMAL(10, 5),
+ product_id INT,
+ order_status BOOLEAN,
+ PRIMARY KEY (order_id) NOT ENFORCED
) WITH (
- 'connector' = 'mysql-cdc',
- 'hostname' = 'localhost',
- 'port' = '3306',
- 'username' = 'root',
- 'password' = '123456',
- 'database-name' = '(^(test).*|^(tpc).*|txc|.*[p$]|t{2})',
- 'table-name' = '(t[5-8]|tt)'
-);
+ 'connector' = 'mysql-cdc',
+ 'hostname' = 'localhost',
+ 'port' = '3306',
+ 'username' = 'root',
+ 'password' = '123456',
+ 'database-name' = '(^(test).*|^(tpc).*|txc|.*[p$]|t{2})',
+ 'table-name' = '(t[5-8]|tt)'
+ );
```
<table class="colwidths-auto docutils">
<thead>
@@ -589,17 +601,17 @@ CREATE TABLE products (
增量快照读取是一种读取表快照的新机制。与旧的快照机制相比,增量快照具有许多优点,包括:
* (1)在快照读取期间,Source 支持并发读取,
-* (2)在快照读取期间,Source 支持进行 chunk 粒度的 checkpoint,
-* (3)在快照读取之前,Source 不需要数据库锁权限。
+* (2)在快照读取期间,Source 支持进行分片粒度的 checkpoint,
+* (3)在快照读取之前,Source 不需要获取全局读锁(FLUSH TABLES WITH READ LOCK)。
如果希望 source 并行运行,则每个并行 reader 都应该具有唯一的 server id,因此`server id`的范围必须类似于 `5400-6400`,
-且范围必须大于并行度。在增量快照读取过程中,MySQL CDC Source 源首先会根据您指定的表块键将表分块(chunk)
-然后 MySQL CDC Source 将多个块分配给多个 reader 以并行读取表的数据。
+且范围必须大于并行度。在增量快照读取过程中,MySQL CDC Source 首先会根据您指定的分片键将表拆分为多个分片(chunk),
+然后 MySQL CDC Source 将多个分片分配给多个 reader 以并行读取表的数据。
#### 并发读取
增量快照读取提供了并行读取快照数据的能力。
-你可以通过设置作业并行度的方式来控制 Source 的并行度 `parallelism.default`. For example, in SQL CLI:
+你可以通过设置作业并行度的方式来控制 Source 的并行度 `parallelism.default`。例如,在 SQL CLI 中:
```sql
Flink SQL> SET 'parallelism.default' = 8;
@@ -607,22 +619,22 @@ Flink SQL> SET 'parallelism.default' = 8;
#### 全量阶段支持 checkpoint
-增量快照读取提供了在区块级别执行检查点的能力。它使用新的快照读取机制解决了以前版本中的检查点超时问题。
+增量快照读取提供了在分片级别执行 checkpoint 的能力。它使用新的快照读取机制解决了以前版本中的 checkpoint 超时问题。
#### 无锁算法
-MySQL CDC source 使用 增量快照算法, 避免了数据库锁的使用,因此不需要 “RELOAD” 权限。
+MySQL CDC source 使用**增量快照算法**,避免了获取全局读锁(FLUSH TABLES WITH READ LOCK),因此不需要 `RELOAD` 权限。
#### MySQL高可用性支持
-```mysql cdc``` 连接器通过使用 [GTID](https://dev.mysql.com/doc/refman/5.7/en/replication-gtids-concepts.html) 提供 MySQL 高可用集群的高可用性信息。为了获得高可用性, MySQL集群需要启用 GTID 模式,MySQL 配置文件中的 GTID 模式应该包含以下设置:
+```mysql-cdc``` 连接器通过使用 [GTID](https://dev.mysql.com/doc/refman/5.7/en/replication-gtids-concepts.html) 信息提供 MySQL 高可用集群的高可用性。为了获得高可用性, MySQL集群需要启用 GTID 模式,MySQL 配置文件中的 GTID 模式应该包含以下设置:
```yaml
gtid_mode = on
enforce_gtid_consistency = on
```
-如果监控的MySQL服务器地址包含从实例,则需要对MySQL配置文件设置以下设置。设置 ```log slave updates=1``` 允许从实例也将从主实例同步的数据写入其binlog, 这确保了```mysql cdc```连接器可以使用从实例中的全部数据。
+如果监控的MySQL服务器地址包含从实例,则需要对MySQL配置文件设置以下设置。设置 ```log-slave-updates = 1``` 允许从实例也将从主实例同步的数据写入其binlog, 这确保了```mysql-cdc```连接器可以使用从实例中的全部数据。
```yaml
gtid_mode = on
@@ -630,41 +642,41 @@ enforce_gtid_consistency = on
log-slave-updates = 1
```
-MySQL 集群中你监控的服务器出现故障后, 你只需将受监视的服务器地址更改为其他可用服务器,然后从最新的检查点/保存点重新启动作业, 作业将从 checkpoint/savepoint 恢复,不会丢失任何记录。
+MySQL 集群中你监控的服务器出现故障后, 你只需将受监视的服务器地址更改为其他可用服务器,然后从最新的 checkpoint/savepoint 重新启动作业, 作业将从 checkpoint/savepoint 恢复,不会丢失任何记录。
-建议为 MySQL 集群配置 DNS(域名服务)或 VIP(虚拟 IP 地址), 使用```mysql cdc```连接器的 DNS 或 VIP 地址, DNS或VIP将自动将网络请求路由到活动MySQL服务器。 这样,你就不再需要修改地址和重新启动管道。
+建议为 MySQL 集群配置 DNS(域名服务)或 VIP(虚拟 IP 地址), 使用```mysql-cdc```连接器的 DNS 或 VIP 地址, DNS或VIP将自动将网络请求路由到活动MySQL服务器。 这样,你就不再需要修改地址和重新启动管道。
#### MySQL心跳事件支持
如果表不经常更新,则 binlog 文件或 GTID 集可能已在其最后提交的 binlog 位置被清理。
-在这种情况下,CDC 作业可能会重新启动失败。因此心跳事件将帮助更新 binlog 位置。 默认情况下,MySQL CDC Source 启用心跳事件,间隔设置为30秒。 可以使用表选项```heartbeat```指定间隔。或将选项设置为```0s```以禁用心跳事件。
+在这种情况下,CDC 作业可能会重新启动失败。因此心跳事件将帮助更新 binlog 位置。 默认情况下,MySQL CDC Source 启用心跳事件,间隔设置为30秒。 可以使用表选项```heartbeat.interval```指定间隔。或将选项设置为`0s`以禁用心跳事件。
#### 增量快照读取的工作原理
当 MySQL CDC Source 启动时,它并行读取表的快照,然后以单并行度的方式读取表的 binlog。
-在快照阶段,快照会根据表的分块键和表行的大小切割成多个快照块。
-快照块被分配给多个快照读取器。每个快照读取器使用 [区块读取算法](#区块读取算法) 并将读取的数据发送到下游。
-Source 会管理块的进程状态(完成或未完成),因此快照阶段的 Source 可以支持块级别的 checkpoint。
-如果发生故障,可以恢复 Source 并继续从最后完成的块中读取块。
+在快照阶段,快照会根据表的分片键和表行的大小切割成多个快照分片。
+快照分片被分配给多个快照读取器。每个快照读取器使用 [分片读取算法](#分片读取算法) 读取其接收到的分片,并将读取的数据发送到下游。
+Source 会管理分片的进程状态(完成或未完成),因此快照阶段的 Source 可以支持分片级别的 checkpoint。
+如果发生故障,可以恢复 Source 并继续从最后完成的分片中读取分片。
-所有快照块完成后,Source 将继续在单个任务中读取 binlog。
-为了保证快照记录和 binlog 记录的全局数据顺序,binlog reader 将开始读取数据直到快照块完成后并有一个完整的 checkpoint,以确保所有快照数据已被下游消费。
+所有快照分片完成后,Source 将继续在单个任务中读取 binlog。
+为了保证快照记录和 binlog 记录的全局数据顺序,binlog reader 将开始读取数据直到快照分片完成后并有一个完整的 checkpoint,以确保所有快照数据已被下游消费。
binlog reader 在状态中跟踪所使用的 binlog 位置,因此 binlog 阶段的 Source 可以支持行级别的 checkpoint。
-Flink 定期为 Source 执行 checkpoint,在故障转移的情况下,作业将重新启动并从最后一个成功的 checkpoint 状态恢复,并保证只执行一次语义。
+Flink 定期为 Source 执行 checkpoint,在故障转移的情况下,作业将重新启动并从最后一个成功的 checkpoint 状态恢复,并保证 Exactly once 语义。
##### 全量阶段分片算法
-在执行增量快照读取时,MySQL CDC source 需要一个用于分片的的算法。
-MySQL CDC Source 使用主键列将表划分为多个分片(chunk)。 默认情况下,MySQL CDC source 会识别表的主键列,并使用主键中的第一列作为用作分片列。
-如果表中没有主键,用户必须指定 `scan.incremental.snapshot.chunk.key-column`、
+在执行增量快照读取时,MySQL CDC source 需要一个用于分片的算法。
+MySQL CDC Source 使用拆分列将表划分为多个分片(chunk)。 默认情况下,MySQL CDC source 会识别表的主键列,并使用主键中的第一列作为拆分列。
+如果表中没有主键,用户必须指定 `scan.incremental.snapshot.chunk.key-column`,
否则增量快照读取将失败,你可以禁用 `scan.incremental.snapshot.enabled` 恢复到旧的快照读取机制。
-请注意,使用不在主键中的列作为分块键可能会降低表的查询性能。
+请注意,使用不在主键中的列作为分片键可能会降低表的查询性能。
-对于数值和自动增量拆分列,MySQL CDC Source 按固定步长高效地拆分块。
+对于数值和自动增量拆分列,MySQL CDC Source 按固定步长高效地拆分分片。
例如,如果你有一个主键列为`id`的表,它是自动增量 BIGINT 类型,最小值为`0`,最大值为`100`,
-和表选项 `scan.incremental.snapshot.chunk.size` 大小 `value`为`25`,表将被拆分为以下块:
+且表选项 `scan.incremental.snapshot.chunk.size` 的值为 `25`,则表将被拆分为以下分片:
```
(-∞, 25),
@@ -674,8 +686,8 @@ MySQL CDC Source 使用主键列将表划分为多个分片(chunk)。 默认
[100, +∞)
```
-对于其他主键列类型, MySQL CDC Source 将以下形式执行语句: `SELECT MAX(STR_ID) AS chunk_high FROM (SELECT * FROM TestTable WHERE STR_ID > 'uuid-001' ORDER BY STR_ID ASC LIMIT 25)` 来获得每个区块的低值和高值,
-分割块集如下所示:
+对于其他主键列类型, MySQL CDC Source 将以以下形式执行语句: `SELECT MAX(STR_ID) AS chunk_high FROM (SELECT * FROM TestTable WHERE STR_ID > 'uuid-001' ORDER BY STR_ID ASC LIMIT 25)` 来获得每个分片的低值和高值,
+分割后的分片集如下所示:
```
(-∞, 'uuid-001'),
@@ -685,36 +697,37 @@ MySQL CDC Source 使用主键列将表划分为多个分片(chunk)。 默认
[uuid-def, +∞).
```
-##### 区块读取算法
+##### 分片读取算法
-对于上面的示例`MyTable`,如果 MySQL CDC Source 并行度设置为 4,MySQL CDC Source 将在每一个 executes 运行 4 个 Readers **通过偏移信号算法**
-获取快照区块的最终一致输出。 **偏移信号算法**简单描述如下:
+对于上面的示例`MyTable`,如果 MySQL CDC Source 并行度设置为 4,MySQL CDC Source 将运行 4 个 reader,每个 reader 都执行**偏移信号算法**
+来获取快照分片的最终一致输出。 **偏移信号算法**简单描述如下:
* (1) 将当前 binlog 位置记录为`LOW`偏移量
-* (2) 通过执行语句读取并缓冲快照区块记录 `SELECT * FROM MyTable WHERE id > chunk_low AND id <= chunk_high`
+* (2) 通过执行语句读取并缓冲快照分片记录 `SELECT * FROM MyTable WHERE id > chunk_low AND id <= chunk_high`
* (3) 将当前 binlog 位置记录为`HIGH`偏移量
-* (4) 从`LOW`偏移量到`HIGH`偏移量读取属于快照区块的 binlog 记录
-* (5) 将读取的 binlog 记录向上插入缓冲区块记录,并发出缓冲区中的所有记录作为快照区块的最终输出(全部作为插入记录)
-* (6) 继续读取并发出属于 *单个 binlog reader* 中`HIGH`偏移量之后的区块的 binlog 记录。
+* (4) 从`LOW`偏移量到`HIGH`偏移量读取属于快照分片的 binlog 记录
+* (5) 将读取的 binlog 记录 Upsert 到缓冲分片记录中,并发出缓冲区中的所有记录作为快照分片的最终输出(全部作为插入记录)
+* (6) 继续读取并发出属于 *单个 binlog reader* 中`HIGH`偏移量之后的分片的 binlog 记录。
-该算法的是基于 [DBLog Paper](https://arxiv.org/pdf/2010.12597v1.pdf) 并结合 Flink 的一个变种, 请参考它了解更多详细信息。
+该算法受 [DBLog Paper](https://arxiv.org/pdf/2010.12597v1.pdf) 的启发,请参考该论文了解更多细节。
**注意:** 如果主键的实际值在其范围内分布不均匀,则在增量快照读取时可能会导致任务不平衡。
### Exactly-Once 处理
-MySQL CDC 连接器是一个 Flink Source 连接器,它将首先读取表快照块,然后继续读取 binlog,
+MySQL CDC 连接器是一个 Flink Source 连接器,它将首先读取表快照分片,然后继续读取 binlog,
无论是在快照阶段还是读取 binlog 阶段,MySQL CDC 连接器都会在处理时**准确读取数据**,即使任务出现了故障。
### 启动模式
-配置选项```scan.startup.mode```指定 MySQL CDC 使用者的启动模式。有效枚举包括:
+配置选项`scan.startup.mode`指定 MySQL CDC 使用者的启动模式。有效枚举包括:
- `initial` (默认):在第一次启动时对受监视的数据库表执行初始快照,并继续读取最新的 binlog。
- `earliest-offset`:跳过快照阶段,从可读取的最早 binlog 位点开始读取
- `latest-offset`:首次启动时,从不对受监视的数据库表执行快照, 连接器仅从 binlog 的结尾处开始读取,这意味着连接器只能读取在连接器启动之后的数据更改。
- `specific-offset`:跳过快照阶段,从指定的 binlog 位点开始读取。位点可通过 binlog 文件名和位置指定,或者在 GTID 在集群上启用时通过 GTID 集合指定。
- `timestamp`:跳过快照阶段,从指定的时间戳开始读取 binlog 事件。
+- `snapshot`:仅执行快照阶段,并在快照阶段读取完成后退出。
例如使用 DataStream API:
```java
@@ -734,15 +747,15 @@ MySQLSource.builder()
```SQL
CREATE TABLE mysql_source (...) WITH (
'connector' = 'mysql-cdc',
- 'scan.startup.mode' = 'earliest-offset', -- 从最早位点启动
- 'scan.startup.mode' = 'latest-offset', -- 从最晚位点启动
- 'scan.startup.mode' = 'specific-offset', -- 从特定位点启动
- 'scan.startup.mode' = 'timestamp', -- 从特定位点启动
- 'scan.startup.mode' = 'snapshot', -- 仅读取快照
- 'scan.startup.specific-offset.file' = 'mysql-bin.000003', -- 在特定位点启动模式下指定 binlog 文件名
- 'scan.startup.specific-offset.pos' = '4', -- 在特定位点启动模式下指定 binlog 位置
- 'scan.startup.specific-offset.gtid-set' = '24DA167-0C0C-11E8-8442-00059A3C7B00:1-19', -- 在特定位点启动模式下指定 GTID 集合
- 'scan.startup.timestamp-millis' = '1667232000000' -- 在时间戳启动模式下指定启动时间戳
+ 'scan.startup.mode' = 'earliest-offset', -- Start from earliest offset
+ 'scan.startup.mode' = 'latest-offset', -- Start from latest offset
+ 'scan.startup.mode' = 'specific-offset', -- Start from specific offset
+ 'scan.startup.mode' = 'timestamp', -- Start from timestamp
+ 'scan.startup.mode' = 'snapshot', -- Read snapshot only
+ 'scan.startup.specific-offset.file' = 'mysql-bin.000003', -- Binlog filename under specific offset startup mode
+ 'scan.startup.specific-offset.pos' = '4', -- Binlog position under specific offset mode
+ 'scan.startup.specific-offset.gtid-set' = '24DA167-0C0C-11E8-8442-00059A3C7B00:1-19', -- GTID set under specific offset startup mode
+ 'scan.startup.timestamp-millis' = '1667232000000' -- Timestamp under timestamp startup mode
...
)
```
@@ -881,6 +894,35 @@ $ ./bin/flink run \
由于**处理顺序**无法保证,最终 `id=0` 的 `pid` 可能为 `2` 或 `4`,从而导致数据不一致。
+### 关于将 binary 类型数据转换为 base64 编码数据
+
+```sql
+CREATE TABLE products (
+ db_name STRING METADATA FROM 'database_name' VIRTUAL,
+ table_name STRING METADATA FROM 'table_name' VIRTUAL,
+ operation_ts TIMESTAMP_LTZ(3) METADATA FROM 'op_ts' VIRTUAL,
+ order_id INT,
+ order_date TIMESTAMP(0),
+ customer_name STRING,
+ price DECIMAL(10, 5),
+ product_id INT,
+ order_status BOOLEAN,
+ binary_data STRING,
+ PRIMARY KEY(order_id) NOT ENFORCED
+) WITH (
+ 'connector' = 'mysql-cdc',
+ 'hostname' = 'localhost',
+ 'port' = '3306',
+ 'username' = 'root',
+ 'password' = '123456',
+ 'database-name' = 'test_db',
+ 'table-name' = 'test_tb',
+ 'debezium.binary.handling.mode' = 'base64'
+);
+```
+
+数据库中的 `binary_data` 字段类型为 VARBINARY(N)。在某些场景中,我们需要将 binary 数据转换为 base64 编码的字符串数据。可以通过添加参数 'debezium.binary.handling.mode'='base64' 来启用此功能,
+添加该参数后,我们可以在 Flink SQL 中将 binary 字段类型映射为 'STRING',从而获得 base64 编码的字符串数据。
### 可用的指标
@@ -1013,7 +1055,7 @@ $ ./bin/flink run \
where 38 < p <= 65<br>
</td>
<td>STRING</td>
- <td>在 MySQL 中,十进制数据类型的精度高达 65,但在 Flink 中,十进制数据类型的精度仅限于 38。所以,如果定义精度大于 38 的十进制列,则应将其映射到字符串以避免精度损失。在 MySQL 中,十进制数据类型的精度高达65,但在Flink中,十进制数据类型的精度仅限于38。所以,如果定义精度大于 38 的十进制列,则应将其映射到字符串以避免精度损失。</td>
+ <td>在 MySQL 中,十进制数据类型的精度高达 65,但在 Flink 中,十进制数据类型的精度仅限于 38。所以,如果定义精度大于 38 的十进制列,则应将其映射到字符串以避免精度损失。</td>
</tr>
<tr>
<td>
@@ -1060,7 +1102,7 @@ $ ./bin/flink run \
<td>
BIT(n)
</td>
- <td>BINARY(⌈n/8⌉)</td>
+ <td>BINARY(⌈(n + 7) / 8⌉)</td>
<td></td>
</tr>
<tr>
@@ -1157,7 +1199,7 @@ MySQL中除`GEOMETRYCOLLECTION`之外的空间数据类型都会转换为 Json
{"srid": 0 , "type": "xxx", "coordinates": [0, 0]}
```
字段`srid`标识定义几何体的 SRS,如果未指定 SRID,则 SRID 0 是新几何体值的默认值。
-由于 MySQL 8+ 在定义空间数据类型时只支持特定的 SRID,因此在版本较低的MySQL中,字段`srid`将始终为 0。
+由于只有 MySQL 8+ 在定义空间数据类型时支持指定 SRID,因此在版本较低的MySQL中,字段`srid`将始终为 0。
字段`type`标识空间数据类型,例如`POINT`/`LINESTRING`/`POLYGON`。
@@ -1168,15 +1210,15 @@ MySQL中除`GEOMETRYCOLLECTION`之外的空间数据类型都会转换为 Json
{"srid": 0 , "type": "GeometryCollection", "geometries": [{"type":"Point","coordinates":[10,10]}]}
```
-`Geometrics`字段是一个包含所有空间数据的数组。
+`geometries`字段是一个包含所有空间数据的数组。
不同空间数据类型映射的示例如下:
<div class="wy-table-responsive">
<table class="colwidths-auto docutils">
<thead>
<tr>
- <th class="text-left">Spatial data in MySQL</th>
- <th class="text-left">Json String converted in Flink</th>
+ <th class="text-left">MySQL 中的空间数据</th>
+ <th class="text-left">在 Flink 中转换的 Json 字符串</th>
</tr>
</thead>
<tbody>
diff --git a/docs/content.zh/docs/connectors/flink-sources/oceanbase-cdc.md b/docs/content.zh/docs/connectors/flink-sources/oceanbase-cdc.md
index 6e94046d3..155cbf185 100644
--- a/docs/content.zh/docs/connectors/flink-sources/oceanbase-cdc.md
+++ b/docs/content.zh/docs/connectors/flink-sources/oceanbase-cdc.md
@@ -92,7 +92,7 @@ OceanBase CDC 源端读取方案:
**注意事项**: oceanbase-cdc 连接器 从 3.5 版本开始进行了以下大的改动:
- 先前基于 OceanBase Log Proxy 服务实现的连接器已被正式移除,当前将仅支持连接到 OceanBase Binlog 服务。
-- 当前版本 oceanbase-cdc 将基于 mysql-cdc 连接器实现,主要改进了对 OceanBase Binlog 服务的兼容性,包含一些 Bug 修复,推荐使用。
+- 当前版本 oceanbase-cdc 连接器基于 mysql-cdc 连接器重建,改进了对 OceanBase Binlog 服务的兼容性,包含关键的 Bug 修复,强烈建议升级到该版本。
- 由于 OceanBase Binlog 服务兼容 MySQL 复制协议,仍然支持使用 [MySQL CDC](mysql-cdc.md) 连接器连接到 OceanBase Binlog 服务。
- 暂不支持 OceanBase Oracle 兼容模式下的增量订阅服务,请联系企业技术支持。
@@ -100,7 +100,7 @@ OceanBase CDC 源端读取方案:
依赖
------------
-为了使用 OceanBase CDC 连接器,您必须提供相关的依赖信息。以下依赖信息适用于使用自动构建工具(如 Maven 或 SBT)构建的项目和带有 SQL JAR 包的 SQL 客户端。
+为了设置 OceanBase CDC 连接器,下表提供了使用构建自动化工具(如 Maven 或 SBT )和带有 SQL JAR 包的 SQL 客户端的两个项目的依赖关系信息。
### Maven dependency
@@ -112,7 +112,7 @@ OceanBase CDC 源端读取方案:
**注意:** 参考 [flink-sql-connector-oceanbase-cdc](https://mvnrepository.com/artifact/org.apache.flink/flink-sql-connector-oceanbase-cdc) 当前已发布的所有版本都可以在 Maven 中央仓库获取。
-由于 MySQL Driver 使用的开源协议与 Flink CDC 项目不兼容,我们无法在 jar 包中提供驱动。 您可能需要手动配置以下依赖:
+由于 MySQL Driver 和 OceanBase Driver 使用的开源协议都与 Flink CDC 项目不兼容,我们无法在 jar 包中提供驱动。 您可能需要手动配置以下依赖:
<div class="wy-table-responsive">
<table class="colwidths-auto docutils">
@@ -141,12 +141,13 @@ OceanBase CDC 源端读取方案:
使用文档
----------------
-**注意事项**:
-- 当前版本 oceanbase-cdc 连接器基于 mysql-cdc 连接器实现,只修改了部分内部实现。外部接口、使用参数等 和 mysql-cdc 基本保持一致,使用文档也可参考[MySQL CDC 使用文档](mysql-cdc.md)。
+**注意**:
+- 当前版本的 **oceanbase-cdc 连接器**基于 **mysql-cdc 连接器**实现,**仅修改了部分内部实现**。
+ - **外部接口**和**配置参数**与 mysql-cdc 连接器**完全一致**。
+ - 详细的使用说明,请参考 [**MySQL CDC 使用文档**](mysql-cdc.md)。
-### 创建 OceanBase CDC 表
-
-OceanBase CDC 表可以定义如下:
+创建 OceanBase CDC 表
+----------------
```sql
-- 每 3 秒做一次 checkpoint,用于测试,生产配置建议5到10分钟
@@ -244,7 +245,7 @@ Flink SQL> SELECT * FROM orders;
<td style="word-wrap: break-word;">(none)</td>
<td>String</td>
<td>读取数据使用的 server id,server id 可以是个整数或者一个整数范围,比如 '5400' 或 '5400-5408',
- 建议在 'scan.incremental.snapshot.enabled' 参数为启用时,配置成整数范围。 默认情况下,连接器会在 5400 和 6400 之间生成一个随机数,但是我们建议用户明确指定 Server id。
+ 建议在 'scan.incremental.snapshot.enabled' 参数为启用时,配置成整数范围。每个 id 在 OceanBase 集群中当前运行的所有数据库进程之间必须是唯一的。该连接器以另一个 server 的身份(具有此唯一 id)加入 OceanBase 集群,从而可以读取 binlog。 默认情况下,连接器会在 5400 和 6400 之间生成一个随机数,但是我们建议用户明确指定 Server id。
</td>
</tr>
<tr>
@@ -267,7 +268,7 @@ Flink SQL> SELECT * FROM orders;
<td>optional</td>
<td style="word-wrap: break-word;">8096</td>
<td>Integer</td>
- <td>表快照的块大小(行数),读取表的快照时,捕获的表被拆分为多个块。</td>
+ <td>表快照的分片大小(行数),读取表的快照时,捕获的表被拆分为多个分片。</td>
</tr>
<tr>
<td>scan.snapshot.fetch.size</td>
@@ -284,7 +285,7 @@ Flink SQL> SELECT * FROM orders;
<td>表快照的分片键,在读取表的快照时,被捕获的表会按分片键拆分为多个分片。
默认情况下,分片键是主键的第一列。可以使用非主键列作为分片键,但这可能会导致查询性能下降。
<br>
- <b>警告:</b> 使用非主键列作为分片键可能会导致数据不一致。请参阅 <a href="./mysql-cdc.md#警告">增量快照读取</a> 章节了解详细信息。
+ <b>警告:</b> 使用非主键列作为分片键可能会导致数据不一致。请参阅 <a href="./mysql-cdc.md#警告">警告</a> 章节了解详细信息。
</td>
</tr>
<tr>
@@ -350,8 +351,7 @@ Flink SQL> SELECT * FROM orders;
</td>
</tr>
<tr>
- <td>debezium.min.row.
- count.to.stream.result</td>
+ <td>debezium.min.row.count.to.stream.result</td>
<td>optional</td>
<td style="word-wrap: break-word;">1000</td>
<td>Integer</td>
@@ -391,7 +391,7 @@ Flink SQL> SELECT * FROM orders;
<td>optional</td>
<td style="word-wrap: break-word;">30s</td>
<td>Duration</td>
- <td>用于跟踪最新可用 binlog 偏移的发送心跳事件的间隔。</td>
+ <td>用于跟踪最新可用 binlog 位点的发送心跳事件的间隔。</td>
</tr>
<tr>
<td>debezium.*</td>
@@ -399,7 +399,7 @@ Flink SQL> SELECT * FROM orders;
<td style="word-wrap: break-word;">(none)</td>
<td>String</td>
<td>将 Debezium 的属性传递给 Debezium 嵌入式引擎,该引擎用于从 OceanBase 服务器捕获数据更改。
- For example: <code>'debezium.snapshot.mode' = 'never'</code>.
+ 例如:<code>'debezium.snapshot.mode' = 'never'</code>.
查看更多关于 <a href="https://debezium.io/documentation/reference/1.9/connectors/mysql.html#mysql-connector-properties"> Debezium 的 MySQL 连接器属性</a></td>
</tr>
<tr>
@@ -407,7 +407,22 @@ Flink SQL> SELECT * FROM orders;
<td>optional</td>
<td style="word-wrap: break-word;">false</td>
<td>Boolean</td>
- <td>是否在快照结束后关闭空闲的 Reader。 此特性需要 flink 版本大于等于 1.14 并且 'execution.checkpointing.checkpoints-after-tasks-finish.enabled' 需要设置为 true。</td>
+ <td>是否在快照阶段结束后关闭空闲的 Reader。 <br>
+ 当 'execution.checkpointing.checkpoints-after-tasks-finish.enabled' 设置为 true 时,要求 flink 版本大于等于 1.14。<br>
+ 如果 flink 版本大于等于 1.15,'execution.checkpointing.checkpoints-after-tasks-finish.enabled' 的默认值已变更为 true,
+ 因此不需要显式配置 'execution.checkpointing.checkpoints-after-tasks-finish.enabled' = 'true'
+ </td>
+ </tr>
+ <tr>
+ <td>debezium.binary.handling.mode</td>
+ <td>optional</td>
+ <td style="word-wrap: break-word;">(none)</td>
+ <td>String</td>
+ <td>debezium.binary.handling.mode 可以设置为以下值之一:
+ none:不做任何处理,binary 数据类型以字节数组(byte array)的形式传输。
+ base64:将 binary 数据类型转换为 Base64 编码的字符串进行传输。
+ hex:将 binary 数据类型转换为十六进制字符串进行传输。
+ 默认值为 none。可以根据需求和数据类型选择合适的处理模式。如果数据库中包含大量 binary 数据类型,建议使用 base64 或 hex 模式,以便在传输过程中更易于处理。</td>
</tr>
<tr>
<td>scan.parse.online.schema.changes.enabled</td>
@@ -418,7 +433,19 @@ Flink SQL> SELECT * FROM orders;
是否尝试解析由 <a href="https://github.com/github/gh-ost">gh-ost</a> 或 <a href="https://docs.percona.com/percona-toolkit/pt-online-schema-change.html">pt-osc</a> 工具生成的表结构变更事件。
这些工具会在变更表结构时,将变更语句应用到“影子表”之上,并稍后将其与主表进行交换,以达到表结构变更的目的。
<br>
- 这是一项实验性功能。
+ 这是一项实验性功能,未来可能会发生变化。
+ </td>
+ </tr>
+ <tr>
+ <td>use.legacy.json.format</td>
+ <td>optional</td>
+ <td style="word-wrap: break-word;">true</td>
+ <td>Boolean</td>
+ <td>是否使用 legacy JSON 格式来转换 Binlog 中的 JSON 类型的数据。 <br>
+ 这代表着是否使用 legacy JSON 格式来转换 Binlog 中的 JSON 类型的数据。
+ 如果用户配置 'use.legacy.json.format' = 'true',则从 Binlog 中转换 JSON 类型的数据时,会移除值之前的空格和逗号之后的空格。例如,
+ Binlog 中 JSON 类型的数据 {"key1": "value1", "key2": "value2"} 会被转换为 {"key1":"value1","key2":"value2"}。
+ 如果设置 'use.legacy.json.format' = 'false', 这条数据会被转换为 {"key1": "value1", "key2": "value2"}, 也就是 key 和 value 前的空格都会被保留。
</td>
</tr>
<tr>
@@ -428,8 +455,8 @@ Flink SQL> SELECT * FROM orders;
<td>Boolean</td>
<td>
快照读取阶段是否先分配 UnboundedChunk。<br>
- 这有助于降低 TaskManager 在快照阶段同步最后一个chunk时遇到内存溢出 (OOM) 的风险。<br>
- 这是一项实验特性,默认为 false。
+ 这可能有助于降低 TaskManager 在对最大的 UnboundedChunk 执行快照时出现内存溢出 (OOM) 错误的风险。<br>
+ 实验性配置项,默认为 false。
</td>
</tr>
<tr>
@@ -455,17 +482,6 @@ Flink SQL> SELECT * FROM orders;
如果跳过 backfill ,快照阶段捕获表的更改将在稍后的 binlog 读取阶段被回放,而不是合并到快照中。<br>
警告:跳过 backfill 可能会导致数据不一致,因为快照阶段发生的某些 binlog 事件可能会被重放(仅保证 at-least-once )。
例如,更新快照阶段已更新的值,或删除快照阶段已删除的数据。这些重放的 binlog 事件应进行特殊处理。
- </tr>
- <tr>
- <td>use.legacy.json.format</td>
- <td>optional</td>
- <td style="word-wrap: break-word;">true</td>
- <td>Boolean</td>
- <td>是否使用 legacy JSON 格式来转换 Binlog 中的 JSON 类型的数据。 <br>
- 这代表着是否使用 legacy JSON 格式来转换 Binlog 中的 JSON 类型的数据。
- 如果用户配置 'use.legacy.json.format' = 'true',则从 Binlog 中转换 JSON 类型的数据时,会移除值之前的空格和逗号之后的空格。例如,
- Binlog 中 JSON 类型的数据 {"key1": "value1", "key2": "value2"} 会被转换为 {"key1":"value1","key2":"value2"}。
- 如果设置 'use.legacy.json.format' = 'false', 这条数据会被转换为 {"key1": "value1", "key2": "value2"}, 也就是 key 和 value 前的空格都会被保留。
</td>
</tr>
</tbody>
@@ -505,60 +521,64 @@ Flink SQL> SELECT * FROM orders;
<td>row_kind</td>
<td>STRING NOT NULL</td>
<td>当前记录的变更类型。<br>
- 注意:如果 Source 算子选择为每条记录输出 row_kind 列,则下游 SQL 操作符在处理回撤时可能会由于此新添加的列而无法比较,导致出现非确定性更新问题。建议仅在简单的同步作业中使用此元数据列。<br>
+ 注意:如果 Source 算子选择为每条记录输出 row_kind 列,则下游 SQL 操作符在处理回撤时可能会由于此新添加的列而无法比较。建议仅在简单的同步作业中使用此元数据列。<br>
'+I' 表示 INSERT 消息,'-D' 表示 DELETE 消息,'-U' 表示 UPDATE_BEFORE 消息,'+U' 表示 UPDATE_AFTER 消息。</td>
</tr>
</tbody>
</table>
下述创建表示例展示元数据列的用法:
+
```sql
-CREATE TABLE products (
- db_name STRING METADATA FROM 'database_name' VIRTUAL,
- table_name STRING METADATA FROM 'table_name' VIRTUAL,
- operation_ts TIMESTAMP_LTZ(3) METADATA FROM 'op_ts' VIRTUAL,
- operation STRING METADATA FROM 'row_kind' VIRTUAL,
- order_id INT,
- order_date TIMESTAMP(0),
+CREATE TABLE products
+(
+ db_name STRING METADATA FROM 'database_name' VIRTUAL,
+ table_name STRING METADATA FROM 'table_name' VIRTUAL,
+ operation_ts TIMESTAMP_LTZ(3) METADATA FROM 'op_ts' VIRTUAL,
+ operation STRING METADATA FROM 'row_kind' VIRTUAL,
+ order_id INT,
+ order_date TIMESTAMP(0),
customer_name STRING,
- price DECIMAL(10, 5),
- product_id INT,
- order_status BOOLEAN,
- PRIMARY KEY(order_id) NOT ENFORCED
+ price DECIMAL(10, 5),
+ product_id INT,
+ order_status BOOLEAN,
+ PRIMARY KEY (order_id) NOT ENFORCED
) WITH (
- 'connector' = 'oceanbase-cdc',
- 'hostname' = 'localhost',
- 'port' = '2881',
- 'username' = 'root',
- 'password' = '123456',
- 'database-name' = 'mydb',
- 'table-name' = 'orders'
-);
+ 'connector' = 'oceanbase-cdc',
+ 'hostname' = 'localhost',
+ 'port' = '2881',
+ 'username' = 'root',
+ 'password' = '123456',
+ 'database-name' = 'mydb',
+ 'table-name' = 'orders'
+ );
```
下述创建表示例展示使用正则表达式匹配多张库表的用法:
+
```sql
-CREATE TABLE products (
- db_name STRING METADATA FROM 'database_name' VIRTUAL,
- table_name STRING METADATA FROM 'table_name' VIRTUAL,
- operation_ts TIMESTAMP_LTZ(3) METADATA FROM 'op_ts' VIRTUAL,
- operation STRING METADATA FROM 'row_kind' VIRTUAL,
- order_id INT,
- order_date TIMESTAMP(0),
+CREATE TABLE products
+(
+ db_name STRING METADATA FROM 'database_name' VIRTUAL,
+ table_name STRING METADATA FROM 'table_name' VIRTUAL,
+ operation_ts TIMESTAMP_LTZ(3) METADATA FROM 'op_ts' VIRTUAL,
+ operation STRING METADATA FROM 'row_kind' VIRTUAL,
+ order_id INT,
+ order_date TIMESTAMP(0),
customer_name STRING,
- price DECIMAL(10, 5),
- product_id INT,
- order_status BOOLEAN,
- PRIMARY KEY(order_id) NOT ENFORCED
+ price DECIMAL(10, 5),
+ product_id INT,
+ order_status BOOLEAN,
+ PRIMARY KEY (order_id) NOT ENFORCED
) WITH (
- 'connector' = 'oceanbase-cdc',
- 'hostname' = 'localhost',
- 'port' = '2881',
- 'username' = 'root',
- 'password' = '123456',
- 'database-name' = '(^(test).*|^(tpc).*|txc|.*[p$]|t{2})',
- 'table-name' = '(t[5-8]|tt)'
-);
+ 'connector' = 'oceanbase-cdc',
+ 'hostname' = 'localhost',
+ 'port' = '2881',
+ 'username' = 'root',
+ 'password' = '123456',
+ 'database-name' = '(^(test).*|^(tpc).*|txc|.*[p$]|t{2})',
+ 'table-name' = '(t[5-8]|tt)'
+ );
```
<table class="colwidths-auto docutils">
<thead>
@@ -582,7 +602,7 @@ CREATE TABLE products (
<tr>
<td>特定匹配</td>
<td>txc</td>
- <td>匹配具体的数据库名或表名。</td>
+ <td>匹配具体的数据库名或表名,例如 txc。</td>
</tr>
</tbody>
</table>
@@ -748,7 +768,7 @@ CREATE TABLE products (
<td>
BIT(n)
</td>
- <td>BINARY(⌈n/8⌉)</td>
+ <td>BINARY(⌈(n + 7) / 8⌉)</td>
<td></td>
</tr>
<tr>
@@ -855,15 +875,15 @@ CREATE TABLE products (
{"srid": 0 , "type": "GeometryCollection", "geometries": [{"type":"Point","coordinates":[10,10]}]}
```
-`Geometrics`字段是一个包含所有空间数据的数组。
+`geometries`字段是一个包含所有空间数据的数组。
不同空间数据类型映射的示例如下:
<div class="wy-table-responsive">
<table class="colwidths-auto docutils">
<thead>
<tr>
- <th class="text-left">Spatial data</th>
- <th class="text-left">Json String converted in Flink</th>
+ <th class="text-left">空间数据</th>
+ <th class="text-left">在 Flink 中转换的 Json 字符串</th>
</tr>
</thead>
<tbody>
diff --git a/docs/content.zh/docs/connectors/flink-sources/oracle-cdc.md b/docs/content.zh/docs/connectors/flink-sources/oracle-cdc.md
index 5bbcf56de..50f3deb86 100644
--- a/docs/content.zh/docs/connectors/flink-sources/oracle-cdc.md
+++ b/docs/content.zh/docs/connectors/flink-sources/oracle-cdc.md
@@ -24,14 +24,14 @@ specific language governing permissions and limitations
under the License.
-->
-# Oracle CDC Connector
+# Oracle CDC 连接器
-The Oracle CDC connector allows for reading snapshot data and incremental data from Oracle database. This document describes how to setup the Oracle CDC connector to run SQL queries against Oracle databases.
+Oracle CDC 连接器允许从 Oracle 数据库读取快照数据和增量数据。本文描述了如何设置 Oracle CDC 连接器来对 Oracle 数据库运行 SQL 查询。
-Dependencies
+依赖
------------
-In order to setup the Oracle CDC connector, the following table provides dependency information for both projects using a build automation tool (such as Maven or SBT) and SQL Client with SQL JAR bundles.
+为了设置 Oracle CDC 连接器,下表提供了使用构建自动化工具(如 Maven 或 SBT )和带有 SQL JAR 包的 SQL 客户端的两个项目的依赖关系信息。
### Maven dependency
@@ -39,11 +39,12 @@ In order to setup the Oracle CDC connector, the following table provides depende
### SQL Client JAR
-**Download link is available only for stable releases.**
+**下载链接仅适用于稳定版本。**
-Download [flink-sql-connector-oracle-cdc](https://mvnrepository.com/artifact/org.apache.flink/flink-sql-connector-oracle-cdc) and put it under `<FLINK_HOME>/lib/`.
+下载 [flink-sql-connector-oracle-cdc](https://mvnrepository.com/artifact/org.apache.flink/flink-sql-connector-oracle-cdc) 到 `<FLINK_HOME>/lib/` 目录下。
+
+**注意:** 参考 [flink-sql-connector-oracle-cdc](https://mvnrepository.com/artifact/org.apache.flink/flink-sql-connector-oracle-cdc) 当前已发布的所有版本都可以在 Maven 中央仓库获取。
-**Note:** Refer to [flink-sql-connector-oracle-cdc](https://mvnrepository.com/artifact/org.apache.flink/flink-sql-connector-oracle-cdc), more released versions will be available in the Maven central warehouse.
由于 Oracle Connector 采用的 FUTC 协议与 Flink CDC 项目不兼容,我们无法在 jar 包中提供 Oracle 连接器。
您可能需要手动配置以下依赖:
@@ -71,15 +72,15 @@ Download [flink-sql-connector-oracle-cdc](https://mvnrepository.com/artifact/org
</table>
</div>
-Setup Oracle
+设置 Oracle
----------------
-You have to enable log archiving for Oracle database and define an Oracle user with appropriate permissions on all databases that the Debezium Oracle connector monitors.
+你必须为 Oracle 数据库启用日志归档,并定义一个 Oracle 用户,该用户对 Debezium Oracle 连接器监视的所有数据库都应该具有相应的权限。
-### For Non-CDB database
+### 非 CDB 数据库
-1. Enable log archiving
+1. 启用日志归档
- (1.1). Connect to the database as DBA
+ (1.1). 以 DBA 身份连接到数据库
```sql
ORACLE_SID=SID
export ORACLE_SID
@@ -87,7 +88,7 @@ You have to enable log archiving for Oracle database and define an Oracle user w
CONNECT sys/password AS SYSDBA
```
- (1.2). Enable log archiving
+ (1.2). 启用日志归档
```sql
alter system set db_recovery_file_dest_size = 10G;
alter system set db_recovery_file_dest = '/opt/oracle/oradata/recovery_area' scope=spfile;
@@ -119,16 +120,16 @@ You have to enable log archiving for Oracle database and define an Oracle user w
ALTER DATABASE ADD SUPPLEMENTAL LOG DATA;
```
-2. Create an Oracle user with permissions
+2. 创建具有权限的 Oracle 用户
- (2.1). Create Tablespace
+ (2.1). 创建表空间
```sql
sqlplus sys/password@host:port/SID AS SYSDBA;
CREATE TABLESPACE logminer_tbs DATAFILE '/opt/oracle/oradata/SID/logminer_tbs.dbf' SIZE 25M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED;
exit;
```
- (2.2). Create a user and grant permissions
+ (2.2). 创建用户并授予权限
```sql
sqlplus sys/password@host:port/SID AS SYSDBA;
CREATE USER flinkuser IDENTIFIED BY flinkpw DEFAULT TABLESPACE LOGMINER_TBS QUOTA UNLIMITED ON LOGMINER_TBS;
@@ -163,10 +164,10 @@ You have to enable log archiving for Oracle database and define an Oracle user w
exit;
```
-### For CDB database
+### CDB 数据库
-Overall, the steps for configuring CDB database is quite similar to non-CDB database, but the commands may be different.
-1. Enable log archiving
+总体而言,配置 CDB 数据库的步骤与非 CDB 数据库非常相似,但命令可能有所不同。
+1. 启用日志归档
```sql
ORACLE_SID=ORCLCDB
export ORACLE_SID
@@ -183,8 +184,8 @@ Overall, the steps for configuring CDB database is quite similar to non-CDB data
archive log list
exit;
```
- **Note:**
- You can also use the following commands to enable supplemental logging:
+ **注意:**
+ 你也可以使用以下命令来启用补充日志:
```sql
-- Enable supplemental logging for a specific table:
ALTER TABLE inventory.customers ADD SUPPLEMENTAL LOG DATA (ALL) COLUMNS;
@@ -192,7 +193,7 @@ Overall, the steps for configuring CDB database is quite similar to non-CDB data
ALTER DATABASE ADD SUPPLEMENTAL LOG DATA;
```
-2. Create an Oracle user with permissions
+2. 创建具有权限的 Oracle 用户
```sql
sqlplus sys/password@//localhost:1521/ORCLCDB as sysdba
CREATE TABLESPACE logminer_tbs DATAFILE '/opt/oracle/oradata/ORCLCDB/logminer_tbs.dbf' SIZE 25M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED;
@@ -234,12 +235,12 @@ Overall, the steps for configuring CDB database is quite similar to non-CDB data
exit
```
-See more about the [Setting up Oracle](https://debezium.io/documentation/reference/1.9/connectors/oracle.html#setting-up-oracle)
+查看更多关于 [Setting up Oracle](https://debezium.io/documentation/reference/1.9/connectors/oracle.html#setting-up-oracle) 的信息
-How to create an Oracle CDC table
+如何创建 Oracle CDC 表
----------------
-The Oracle CDC table can be defined as following:
+Oracle CDC 表可以定义如下:
```sql
-- register an Oracle table 'products' in Flink SQL
@@ -262,13 +263,13 @@ Flink SQL> CREATE TABLE products (
-- read snapshot and redo logs from products table
Flink SQL> SELECT * FROM products;
```
-**Note:**
-When working with the CDB + PDB model, you are expected to add an extra option `'debezium.database.pdb.name' = 'xxx'` in Flink DDL to specific the name of the PDB to connect to.
+**注意:**
+在使用 CDB + PDB 模型时,需要在 Flink DDL 中添加一个额外的选项 `'debezium.database.pdb.name' = 'xxx'` 来指定要连接的 PDB 的名称。
-**Note:**
-While the connector might work with a variety of Oracle versions and editions, only Oracle 9i, 10g, 11g and 12c have been tested.
+**注意:**
+虽然该连接器可能适用于多种 Oracle 版本和发行版,但仅对 Oracle 9i、10g、11g 和 12c 进行了测试。
-Connector Options
+连接器配置项
----------------
<div class="highlight">
<table class="colwidths-auto docutils">
@@ -287,90 +288,90 @@ Connector Options
<td>required</td>
<td style="word-wrap: break-word;">(none)</td>
<td>String</td>
- <td>Specify what connector to use, here should be <code>'oracle-cdc'</code>.</td>
+ <td>指定要使用的连接器, 这里应该是 <code>'oracle-cdc'</code>.</td>
</tr>
<tr>
<td>hostname</td>
<td>optional</td>
<td style="word-wrap: break-word;">(none)</td>
<td>String</td>
- <td>IP address or hostname of the Oracle database server. If the url is not empty, hostname may not be configured, otherwise hostname can not be empty</td>
+ <td> Oracle 数据库服务器的 IP 地址或主机名。如果 url 不为空,则可以不配置 hostname,否则 hostname 不能为空</td>
</tr>
<tr>
<td>username</td>
<td>required</td>
<td style="word-wrap: break-word;">(none)</td>
<td>String</td>
- <td>Name of the Oracle database to use when connecting to the Oracle database server.</td>
+ <td>连接到 Oracle 数据库服务器时要使用的 Oracle 用户的名称。</td>
</tr>
<tr>
<td>password</td>
<td>required</td>
<td style="word-wrap: break-word;">(none)</td>
<td>String</td>
- <td>Password to use when connecting to the Oracle database server.</td>
+ <td>连接 Oracle 数据库服务器时使用的密码。</td>
</tr>
<tr>
<td>database-name</td>
<td>required</td>
<td style="word-wrap: break-word;">(none)</td>
<td>String</td>
- <td>Database name of the Oracle server to monitor.</td>
+ <td>要监视的 Oracle 服务器的数据库名称。</td>
</tr>
<tr>
<td>schema-name</td>
<td>required</td>
<td style="word-wrap: break-word;">(none)</td>
<td>String</td>
- <td>Schema name of the Oracle database to monitor.</td>
+ <td>要监视的 Oracle 数据库的 schema 名称。</td>
</tr>
<tr>
<td>table-name</td>
<td>required</td>
<td style="word-wrap: break-word;">(none)</td>
<td>String</td>
- <td>Table name of the Oracle database to monitor.</td>
+ <td>要监视的 Oracle 数据库的表名。</td>
</tr>
<tr>
<td>port</td>
<td>optional</td>
<td style="word-wrap: break-word;">1521</td>
<td>Integer</td>
- <td>Integer port number of the Oracle database server.</td>
+ <td> Oracle 数据库服务器的整数端口号。</td>
</tr>
<tr>
<td>url</td>
<td>optional</td>
<td style="word-wrap: break-word;">jdbc:oracle:thin:@{hostname}:{port}:{database-name}</td>
<td>String</td>
- <td>JdbcUrl of the oracle database server . If the hostname and port parameter is configured, the URL is concatenated by hostname port database-name in SID format by default. Otherwise, you need to configure the URL parameter</td>
+ <td>Oracle 数据库服务器的 JdbcUrl。如果配置了 hostname 和 port 参数,默认情况下,URL 会按 SID 格式由 hostname、port、database-name 拼接而成。否则,你需要配置 URL 参数</td>
</tr>
<tr>
<td>scan.startup.mode</td>
<td>optional</td>
<td style="word-wrap: break-word;">initial</td>
<td>String</td>
- <td>Optional startup mode for Oracle CDC consumer, valid enumerations are "initial"
- , "latest-offset" , specific-offset.
- Please see <a href="#startup-reading-position">Startup Reading Position</a> section for more detailed information.</td>
+ <td>Oracle CDC 消费者可选的启动模式,
+ 合法的模式为 "initial","latest-offset","specific-offset"。
+ 请查阅 <a href="#启动模式">启动模式</a> 章节了解更多详细信息。</td>
</tr>
<tr>
<td>scan.startup.specific-offset.scn</td>
<td>optional</td>
<td style="word-wrap: break-word;">(none)</td>
<td>Long</td>
- <td>Optional SCN used in case of "specific-offset" startup mode</td>
+ <td>在 "specific-offset" 启动模式下使用的可选 SCN</td>
</tr>
<tr>
<td>scan.incremental.snapshot.enabled</td>
<td>optional</td>
<td style="word-wrap: break-word;">true</td>
<td>Boolean</td>
- <td>Incremental snapshot is a new mechanism to read snapshot of a table. Compared to the old snapshot mechanism,
- the incremental snapshot has many advantages, including:
- (1) source can be parallel during snapshot reading,
- (2) source can perform checkpoints in the chunk granularity during snapshot reading,
- (3) source doesn't need to acquire ROW SHARE MODE lock before snapshot reading.
+ <td>增量快照是一种读取表快照的新机制,与旧的快照机制相比,
+ 增量快照有许多优点,包括:
+ (1)在快照读取期间,Source 支持并发读取,
+ (2)在快照读取期间,Source 支持进行 chunk 粒度的 checkpoint,
+ (3)在快照读取之前,Source 不需要获取 ROW SHARE MODE 锁。
</td>
</tr>
<tr>
@@ -378,47 +379,47 @@ Connector Options
<td>optional</td>
<td style="word-wrap: break-word;">8096</td>
<td>Integer</td>
- <td>The chunk size (number of rows) of table snapshot, captured tables are split into multiple chunks when read the snapshot of table.</td>
+ <td>表快照的分片大小(行数),读取表的快照时,捕获的表被拆分为多个分片。</td>
</tr>
<tr>
<td>scan.snapshot.fetch.size</td>
<td>optional</td>
<td style="word-wrap: break-word;">1024</td>
<td>Integer</td>
- <td>The maximum fetch size for per poll when read table snapshot.</td>
+ <td>读取表快照时每次读取数据的最大条数。</td>
</tr>
<tr>
<td>connect.max-retries</td>
<td>optional</td>
<td style="word-wrap: break-word;">3</td>
<td>Integer</td>
- <td>The max retry times that the connector should retry to build Oracle database server connection.</td>
+ <td>连接器应重试以建立 Oracle 数据库服务器连接的最大重试次数。</td>
</tr>
<tr>
<td>connection.pool.size</td>
<td>optional</td>
<td style="word-wrap: break-word;">20</td>
<td>Integer</td>
- <td>The connection pool size.</td>
+ <td>连接池大小。</td>
</tr>
<tr>
<td>debezium.*</td>
<td>optional</td>
<td style="word-wrap: break-word;">(none)</td>
<td>String</td>
- <td>Pass-through Debezium's properties to Debezium Embedded Engine which is used to capture data changes from Oracle server.
- For example: <code>'debezium.snapshot.mode' = 'never'</code>.
- See more about the <a href="https://debezium.io/documentation/reference/1.9/connectors/oracle.html#oracle-connector-properties">Debezium's Oracle Connector properties</a></td>
+ <td>将 Debezium 的属性传递给 Debezium 嵌入式引擎,该引擎用于从 Oracle 服务器捕获数据更改。
+ 例如:<code>'debezium.snapshot.mode' = 'never'</code>.
+ 查看更多关于 <a href="https://debezium.io/documentation/reference/1.9/connectors/oracle.html#oracle-connector-properties"> Debezium 的 Oracle 连接器属性</a></td>
</tr>
<tr>
<td>scan.incremental.close-idle-reader.enabled</td>
<td>optional</td>
<td style="word-wrap: break-word;">false</td>
<td>Boolean</td>
- <td>Whether to close idle readers at the end of the snapshot phase. <br>
- 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.<br>
- 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'
+ <td>是否在快照阶段结束后关闭空闲的 Reader。 <br>
+ 当 'execution.checkpointing.checkpoints-after-tasks-finish.enabled' 设置为 true 时,要求 flink 版本大于等于 1.14。<br>
+ 如果 flink 版本大于等于 1.15,'execution.checkpointing.checkpoints-after-tasks-finish.enabled' 的默认值已变更为 true,
+ 因此不需要显式配置 'execution.checkpointing.checkpoints-after-tasks-finish.enabled' = 'true'
</td>
</tr>
<tr>
@@ -433,10 +434,10 @@ Connector Options
<td>optional</td>
<td style="word-wrap: break-word;">(none)</td>
<td>String</td>
- <td>The chunk key of table snapshot, captured tables are split into multiple chunks by a chunk key when read the snapshot of table.
- By default, the chunk key is 'ROWID'. A column that is not part of the primary key can be used as a chunk key, but this may lead to slower query performance.
+ <td>表快照的分片键,在读取表的快照时,被捕获的表会按分片键拆分为多个分片。
+ 默认情况下,分片键是 'ROWID'。可以使用非主键列作为分片键,但这可能会导致查询性能下降。
<br>
- <b>Warning:</b> Using a non-primary key column as a chunk key may lead to data inconsistencies. Please see <a href="#warning">Warning</a> for details.
+ <b>警告:</b> 使用非主键列作为分片键可能会导致数据不一致。请参阅 <a href="#警告">警告</a> 了解详细信息。
</td>
</tr>
<tr>
@@ -445,8 +446,8 @@ Connector Options
<td style="word-wrap: break-word;">true</td>
<td>Boolean</td>
<td>
- Whether to assign the unbounded chunks first during snapshot reading phase.<br>
- This might help reduce the risk of the TaskManager experiencing an out-of-memory (OOM) error when taking a snapshot of the largest unbounded chunk.<br>
+ 快照读取阶段是否先分配 UnboundedChunk。<br>
+ 这可能有助于降低 TaskManager 在对最大的 UnboundedChunk 执行快照时出现内存溢出 (OOM) 错误的风险。<br>
</td>
</tr>
<tr>
@@ -455,21 +456,21 @@ Connector Options
<td style="word-wrap: break-word;">false</td>
<td>Boolean</td>
<td>
- Whether to skip backfill in snapshot reading phase.<br>
- If backfill is skipped, changes on captured tables during snapshot phase will be consumed later in change log reading phase instead of being merged into the snapshot.<br>
- WARNING: Skipping backfill might lead to data inconsistency because some change log events happened within the snapshot phase might be replayed (only at-least-once semantic is promised).
- For example updating an already updated value in snapshot, or deleting an already deleted entry in snapshot. These replayed change log events should be handled specially.
+ 是否在快照读取阶段跳过 backfill 。<br>
+ 如果跳过 backfill ,快照阶段捕获表的更改将在稍后的 change log 读取阶段被回放,而不是合并到快照中。<br>
+ 警告:跳过 backfill 可能会导致数据不一致,因为快照阶段发生的某些 change log 事件可能会被重放(仅保证 at-least-once )。
+ 例如,更新快照阶段已更新的值,或删除快照阶段已删除的数据。这些重放的 change log 事件应进行特殊处理。
</td>
</tr>
</tbody>
</table>
</div>
-Limitation
+限制
--------
-### Can't perform checkpoint during scanning snapshot of tables
-During scanning snapshot of database tables, since there is no recoverable position, we can't perform checkpoints. In order to not perform checkpoints, Oracle CDC source will keep the checkpoint waiting to timeout. The timeout checkpoint will be recognized as failed checkpoint, by default, this will trigger a failover for the Flink job. So if the database table is large, it is recommended to add following Flink configurations to avoid failover because of the timeout checkpoints:
+### 扫描表快照期间无法执行 checkpoint
+在扫描数据库表快照期间,由于没有可恢复的位点,我们无法执行 checkpoint。为了不执行 checkpoint,Oracle CDC source 会让 checkpoint 一直等待直至超时。超时的 checkpoint 会被视为失败的 checkpoint,默认情况下,这将触发 Flink 作业的故障转移。因此,如果数据库表很大,建议添加以下 Flink 配置,以避免因 checkpoint 超时而触发故障转移:
```
execution.checkpointing.interval: 10min
@@ -478,10 +479,10 @@ restart-strategy: fixed-delay
restart-strategy.fixed-delay.attempts: 2147483647
```
-Available Metadata
+可用的元数据
----------------
-The following format metadata can be exposed as read-only (VIRTUAL) columns in a table definition.
+下表中的元数据可以在 DDL 中作为只读(虚拟)meta 列声明。
<table class="colwidths-auto docutils">
<thead>
@@ -495,27 +496,27 @@ The following format metadata can be exposed as read-only (VIRTUAL) columns in a
<tr>
<td>table_name</td>
<td>STRING NOT NULL</td>
- <td>Name of the table that contain the row.</td>
+ <td>当前记录所属的表名称。</td>
</tr>
<tr>
<td>schema_name</td>
<td>STRING NOT NULL</td>
- <td>Name of the schema that contain the row.</td>
+ <td>当前记录所属的 schema 名称。</td>
</tr>
<tr>
<td>database_name</td>
<td>STRING NOT NULL</td>
- <td>Name of the database that contain the row.</td>
+ <td>当前记录所属的库名称。</td>
</tr>
<tr>
<td>op_ts</td>
<td>TIMESTAMP_LTZ(3) NOT NULL</td>
- <td>It indicates the time that the change was made in the database. <br>If the record is read from snapshot of the table instead of the change stream, the value is always 0.</td>
+ <td>当前记录表在数据库中更新的时间。 <br>如果从表的快照而不是更改流读取记录,该值将始终为0。</td>
</tr>
</tbody>
</table>
-The extended CREATE TABLE example demonstrates the syntax for exposing these metadata fields:
+下述创建表示例展示元数据列的用法:
```sql
CREATE TABLE products (
db_name STRING METADATA FROM 'database_name' VIRTUAL,
@@ -541,29 +542,29 @@ CREATE TABLE products (
);
```
-**Note** : The Oracle dialect is case-sensitive, it converts field name to uppercase if the field name is not quoted, Flink SQL doesn't convert the field name. Thus for physical columns from oracle database, we should use its converted field name in Oracle when define an `oracle-cdc` table in Flink SQL.
+**注意** : Oracle 方言是大小写敏感的,如果字段名没有加引号,它会将字段名转换为大写,而 Flink SQL 不会转换字段名。因此,对于来自 Oracle 数据库的物理列,在 Flink SQL 中定义 `oracle-cdc` 表时,应该使用其在 Oracle 中转换后的字段名。
-Features
+特性
--------
-### Exactly-Once Processing
+### Exactly-Once 处理
-The Oracle CDC connector is a Flink Source connector which will read database snapshot first and then continues to read change events with **exactly-once processing** even failures happen. Please read [How the connector works](https://debezium.io/documentation/reference/1.9/connectors/oracle.html#how-the-oracle-connector-works).
+Oracle CDC 连接器是一个 Flink Source 连接器,它将首先读取数据库快照,然后继续读取变更事件,即使在处理时出现故障,也能**准确读取数据**。请参阅 [How the connector works](https://debezium.io/documentation/reference/1.9/connectors/oracle.html#how-the-oracle-connector-works)。
-### Startup Reading Position
+### 启动模式
-The config option `scan.startup.mode` specifies the startup mode for Oracle CDC consumer. The valid enumerations are:
+配置选项`scan.startup.mode`指定 Oracle CDC 使用者的启动模式。有效枚举包括:
-- `initial` (default): Performs an initial snapshot on the monitored database tables upon first startup, and continue to read the latest redo log.
-- `latest-offset`: Never to perform a snapshot on the monitored database tables upon first startup, just read from
- the change since the connector was started.
-- `specific-offset`: Skip snapshot phase and start reading redo log from a specific offset with scn.
+- `initial` (默认):在第一次启动时对受监视的数据库表执行初始快照,并继续读取最新的 redo log。
+- `latest-offset`:首次启动时,从不对受监视的数据库表执行快照,仅读取
+ 连接器启动之后的数据更改。
+- `specific-offset`:跳过快照阶段,使用 scn 从特定位点开始读取 redo log。
-_Note: the mechanism of `scan.startup.mode` option relying on Debezium's `snapshot.mode` configuration. So please do not use them together. If you specific both `scan.startup.mode` and `debezium.snapshot.mode` options in the table DDL, it may make `scan.startup.mode` doesn't work._
+_注意:`scan.startup.mode` 选项的机制依赖于 Debezium 的 `snapshot.mode` 配置,因此请不要同时使用它们。如果在表 DDL 中同时指定 `scan.startup.mode` 和 `debezium.snapshot.mode` 选项,可能会导致 `scan.startup.mode` 失效。_
-### Single Thread Reading
+### 单线程读取
-The Oracle CDC source can't work in parallel reading, because there is only one task can receive change events.
+Oracle CDC source 无法以并行读取的方式工作,因为只有一个任务可以接收变更事件。
### 动态加表
@@ -628,12 +629,12 @@ $ ./bin/flink run \
### DataStream Source
-The Oracle CDC connector can also be a DataStream source. There are two modes for the DataStream source:
+Oracle CDC 连接器也可以是一个数据流源。DataStream 源有两种模式:
-- incremental snapshot based, which allows parallel reading
-- SourceFunction based, which only supports single thread reading
+- 基于增量快照,允许并行读取
+- 基于 SourceFunction,仅支持单线程读取
-#### Incremental Snapshot based DataStream (Experimental)
+#### 基于增量快照的 DataStream(实验性)
```java
import org.apache.flink.cdc.connectors.base.options.StartupOptions;
@@ -683,7 +684,7 @@ public class OracleParallelSourceExample {
}
```
-#### SourceFunction-based DataStream
+#### 基于 SourceFunction 的 DataStream
```java
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
@@ -735,43 +736,42 @@ public class OracleSourceExample {
1. Group 名称是 `namespace.schema.table`,这里的 `namespace` 是实际的数据库名称, `schema` 是实际的 schema 名称, `table` 是实际的表名称。
2. 对于 Oracle,Group 的名称会类似于 `test_database.test_schema.test_table`。
-### Tables Without primary keys
-
-Starting from version 3.4.0, Oracle CDC support tables that do not have a primary key. To use a table without primary keys, you must configure the `scan.incremental.snapshot.chunk.key-column` option and specify one non-null field.
+### 关于无主键表
-There are two places that need to be taken care of.
+从3.4.0 版本开始支持无主键表,使用无主键表必须设置 `scan.incremental.snapshot.chunk.key-column`,且只能选择非空类型的一个字段。
-1. If there is an index in the table, try to use a column which is contained in the index in `scan.incremental.snapshot.chunk.key-column`. This will increase the speed of select statement.
-2. The processing semantics of an Oracle CDC table without primary keys is determined based on the behavior of the column that are specified by the `scan.incremental.snapshot.chunk.key-column`.
-* If no update operation is performed on the specified column, the exactly-once semantics is ensured.
-* If the update operation is performed on the specified column, only the at-least-once semantics is ensured. However, you can specify primary keys at downstream and perform the idempotence operation to ensure data correctness.
+在使用无主键表时,需要注意以下两种情况。
-#### Warning
+1. 配置 `scan.incremental.snapshot.chunk.key-column` 时,如果表中存在索引,请尽量使用索引中的列来加快 select 速度。
+2. 无主键表的处理语义由 `scan.incremental.snapshot.chunk.key-column` 指定的列的行为决定:
+* 如果指定的列不存在更新操作,此时可以保证 Exactly once 语义。
+* 如果指定的列存在更新操作,此时只能保证 At least once 语义。但可以结合下游,通过指定下游主键,结合幂等性操作来保证数据的正确性。
-Using a **non-primary key column** as the `scan.incremental.snapshot.chunk.key-column` for an oracle table with primary keys may lead to data inconsistencies. Below is a scenario illustrating this issue and recommendations to mitigate potential problems.
+#### 警告
-#### Problem Scenario
+在 Oracle 表中,若使用 **非主键列** 作为有主键表的 `scan.incremental.snapshot.chunk.key-column`,可能导致**数据不一致**。以下为可能出现的问题及其缓解方案。
-- **Table Structure:**
- - **Primary Key:** `id`
- - **Chunk Key Column:** `pid` (Not a primary key)
+#### 问题场景
-- **Snapshot Splits:**
- - **Split 0:** `1 < pid <= 3`
- - **Split 1:** `3 < pid <= 5`
+- **表结构:**
+ - **主键:** `id`
+ - **分片键列 :** `pid`(非主键)
-- **Operation:**
- - Two different subtasks are reading Split 0 and Split 1 concurrently.
- - An update operation changes `pid` from `2` to `4` for `id=0` while both splits are being read. This update occurs between the low and high watermark of both splits.
+- **快照分片 :**
+ - **分片 0:** `1 < pid <= 3`
+ - **分片 1:** `3 < pid <= 5`
-- **Result:**
- - **Split 0:** Contains the record `[id=0, pid=2]`
- - **Split 1:** Contains the record `[id=0, pid=4]`
+- **操作 :**
+ - 两个子任务并行读取 **分片 0** 和 **分片 1**。
+ - 在读取过程中,发生了一次 **更新** 操作,使 `id=0` 的 `pid` 从 `2` 变为 `4`,在两个分片的**高低水位**间都包含此次变更,导致该更新操作在增量阶段不会被处理。
-Since the order of processing these records cannot be guaranteed, the final value of `pid` for `id=0` may end up being either `2` or `4`, leading to potential data inconsistencies.
+- **结果 :**
+ - **分片 0:** 记录 `[id=0, pid=2]`
+ - **分片 1:** 记录 `[id=0, pid=4]`
+由于**处理顺序**无法保证,最终 `id=0` 的 `pid` 可能为 `2` 或 `4`,从而导致数据不一致。
-Data Type Mapping
+数据类型映射
----------------
<div class="wy-table-responsive">
<table class="colwidths-auto docutils">
diff --git a/docs/content.zh/docs/connectors/flink-sources/overview.md b/docs/content.zh/docs/connectors/flink-sources/overview.md
index 97abe6af1..62ee40d1b 100644
--- a/docs/content.zh/docs/connectors/flink-sources/overview.md
+++ b/docs/content.zh/docs/connectors/flink-sources/overview.md
@@ -26,28 +26,28 @@ under the License.
# Flink Sources 连接器
-Flink CDC sources is a set of source connectors for <a href="https://flink.apache.org/">Apache Flink<sup>®</sup></a>, ingesting changes from different databases using change data capture (CDC).
-Some CDC sources integrate Debezium as the engine to capture data changes. So it can fully leverage the ability of Debezium. See more about what is [Debezium](https://github.com/debezium/debezium).
+Flink CDC sources 是一组用于 <a href="https://flink.apache.org/">Apache Flink<sup>®</sup></a> 的 source 连接器,使用变更数据捕获(change data capture,CDC)从不同的数据库摄取变更。
+一些 CDC source 集成 Debezium 作为捕获数据变更的引擎,因此可以充分利用 Debezium 的能力。进一步了解什么是 [Debezium](https://github.com/debezium/debezium)。
-You can also read [tutorials]({{< ref "docs/connectors/flink-sources/tutorials/build-streaming-etl-tutorial" >}}) about how to use these sources.
+你也可以阅读[教程]({{< ref "docs/connectors/flink-sources/tutorials/build-streaming-etl-tutorial" >}}),了解如何使用这些 source。
{{< img src="/fig/cdc-flow.png" width="600px" alt="Flink CDC" >}}
-## Supported Connectors
+## 支持的连接器
-| Connector | Database | Driver [...]
+| 连接器 | 数据库 | 驱动 | 下载页面 [...]
|----------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------- [...]
-| [mongodb-cdc]({{< ref "docs/connectors/flink-sources/mongodb-cdc" >}}) | <li> [MongoDB](https://www.mongodb.com): 3.6, 4.x, 5.0, 6.0, 6.1, 7.0 | MongoDB Driver: 4.1 [...]
-| [mysql-cdc]({{< ref "docs/connectors/flink-sources/mysql-cdc" >}}) | <li> [MySQL](https://dev.mysql.com/doc): 5.7, 8.0.x, 8.4+ <li> [RDS MySQL](https://www.aliyun.com/product/rds/mysql): 5.6, 5.7, 8.0.x <li> [PolarDB MySQL](https://www.aliyun.com/product/polardb): 5.6, 5.7, 8.0.x <li> [Aurora MySQL](https://aws.amazon.com/cn/rds/aurora): 5.6, 5.7, 8.0.x <li> [MariaDB](https://mariadb.org): 10.x <li> [PolarDB X](https://github.com/ApsaraDB/galaxysql): 2.0.1 | JDBC Driver: 8.0.28 [...]
-| [oceanbase-cdc]({{< ref "docs/connectors/flink-sources/oceanbase-cdc" >}}) | <li> [OceanBase CE](https://open.oceanbase.com): 3.1.x, 4.x <li> [OceanBase EE](https://www.oceanbase.com/product/oceanbase): 2.x, 3.x, 4.x | OceanBase Driver: 2 [...]
-| [oracle-cdc]({{< ref "docs/connectors/flink-sources/oracle-cdc" >}}) | <li> [Oracle](https://www.oracle.com/index.html): 11, 12, 19, 21 | Oracle Driver: 19.3 [...]
-| [postgres-cdc]({{< ref "docs/connectors/flink-sources/postgres-cdc" >}}) | <li> [PostgreSQL](https://www.postgresql.org): 9.6, 10, 11, 12, 13, 14 | JDBC Driver: 42.5.1 [...]
-| [sqlserver-cdc]({{< ref "docs/connectors/flink-sources/sqlserver-cdc" >}}) | <li> [Sqlserver](https://www.microsoft.com/sql-server): 2012, 2014, 2016, 2017, 2019 | JDBC Driver: 9.4.1. [...]
-| [tidb-cdc]({{< ref "docs/connectors/flink-sources/tidb-cdc" >}}) | <li> [TiDB](https://www.pingcap.com/): 5.1.x, 5.2.x, 5.3.x, 5.4.x, 6.0.0 | JDBC Driver: 8.0.27 [...]
-| [db2-cdc]({{< ref "docs/connectors/flink-sources/db2-cdc" >}}) | <li> [Db2](https://www.ibm.com/products/db2): 11.5 | Db2 Driver: 11.5.0. [...]
-| [vitess-cdc]({{< ref "docs/connectors/flink-sources/vitess-cdc" >}}) | <li> [Vitess](https://vitess.io/): 8.0.x, 9.0.x | MySQL JDBC Driver: [...]
-
-## Supported Flink Versions
+| [mongodb-cdc]({{< ref "docs/connectors/flink-sources/mongodb-cdc" >}}) | <li> [MongoDB](https://www.mongodb.com): 3.6, 4.x, 5.0, 6.0, 6.1, 7.0 | MongoDB 驱动: 4.11.2 [...]
+| [mysql-cdc]({{< ref "docs/connectors/flink-sources/mysql-cdc" >}}) | <li> [MySQL](https://dev.mysql.com/doc): 5.7, 8.0.x, 8.4+ <li> [RDS MySQL](https://www.aliyun.com/product/rds/mysql): 5.6, 5.7, 8.0.x <li> [PolarDB MySQL](https://www.aliyun.com/product/polardb): 5.6, 5.7, 8.0.x <li> [Aurora MySQL](https://aws.amazon.com/cn/rds/aurora): 5.6, 5.7, 8.0.x <li> [MariaDB](https://mariadb.org): 10.x <li> [PolarDB X](https://github.com/ApsaraDB/galaxysql): 2.0.1 | JDBC 驱动: 8.0.28 [...]
+| [oceanbase-cdc]({{< ref "docs/connectors/flink-sources/oceanbase-cdc" >}}) | <li> [OceanBase CE](https://open.oceanbase.com): 3.1.x, 4.x <li> [OceanBase EE](https://www.oceanbase.com/product/oceanbase): 2.x, 3.x, 4.x | OceanBase 驱动: 2.4.x [...]
+| [oracle-cdc]({{< ref "docs/connectors/flink-sources/oracle-cdc" >}}) | <li> [Oracle](https://www.oracle.com/index.html): 11, 12, 19, 21 | Oracle 驱动: 19.3.0.0 [...]
+| [postgres-cdc]({{< ref "docs/connectors/flink-sources/postgres-cdc" >}}) | <li> [PostgreSQL](https://www.postgresql.org): 9.6, 10, 11, 12, 13, 14 | JDBC 驱动: 42.5.1 [...]
+| [sqlserver-cdc]({{< ref "docs/connectors/flink-sources/sqlserver-cdc" >}}) | <li> [Sqlserver](https://www.microsoft.com/sql-server): 2012, 2014, 2016, 2017, 2019 | JDBC 驱动: 9.4.1.jre8 [...]
+| [tidb-cdc]({{< ref "docs/connectors/flink-sources/tidb-cdc" >}}) | <li> [TiDB](https://www.pingcap.com/): 5.1.x, 5.2.x, 5.3.x, 5.4.x, 6.0.0 | JDBC 驱动: 8.0.27 [...]
+| [db2-cdc]({{< ref "docs/connectors/flink-sources/db2-cdc" >}}) | <li> [Db2](https://www.ibm.com/products/db2): 11.5 | Db2 驱动: 11.5.0.0 [...]
+| [vitess-cdc]({{< ref "docs/connectors/flink-sources/vitess-cdc" >}}) | <li> [Vitess](https://vitess.io/): 8.0.x, 9.0.x | MySQL JDBC 驱动: 8.0. [...]
+
+## 支持的 Flink 版本
下表展示了 Flink CDC 连接器和 Flink 之间的版本映射:
@@ -56,7 +56,7 @@ You can also read [tutorials]({{< ref "docs/connectors/flink-sources/tutorials/b
| 3.6.\* | 1.20.\*, 2.2.\* |
| 3.5.\* | 1.19.\*, 1.20.\* |
| 3.4.\* | 1.19.\*, 1.20.\* |
-| 3.3.\* | 1.18.\*, 1.19.\*, 1.20.\*, 2.1.\* |
+| 3.3.\* | 1.19.\*, 1.20.\* |
| 3.2.\* | 1.17.\*, 1.18.\*, 1.19.\*, 1.20.\* |
| 3.1.\* | 1.16.\*, 1.17.\*, 1.18.\*, 1.19.\* |
| 3.0.\* | 1.14.\*, 1.15.\*, 1.16.\*, 1.17.\*, 1.18.\* |
@@ -71,16 +71,16 @@ You can also read [tutorials]({{< ref "docs/connectors/flink-sources/tutorials/b
| 1.1.0* | 1.11.\* |
| 1.0.0* | 1.11.\* |
-## Features
+## 特性
-1. Supports reading database snapshot and continues to read binlogs with **exactly-once processing** even failures happen.
-2. CDC connectors for DataStream API, users can consume changes on multiple databases and tables in a single job without Debezium and Kafka deployed.
-3. CDC connectors for Table/SQL API, users can use SQL DDL to create a CDC source to monitor changes on a single table.
+1. 支持读取数据库快照,并继续读取 binlog,即使发生故障也能保证 **Exactly-Once 处理**。
+2. 面向 DataStream API 的 CDC 连接器,用户可以在单个作业中消费多个数据库和多张表的变更,而无需部署 Debezium 和 Kafka。
+3. 面向 Table/SQL API 的 CDC 连接器,用户可以使用 SQL DDL 创建 CDC source 来监控单张表的变更。
-The following table shows the current features of the connector:
+下表展示了当前各个连接器的特性:
-| Connector | No-lock Read | Parallel Read | Exactly-once Read | Incremental Snapshot Read |
-|----------------------------------------------------------------------------|--------------|---------------|-------------------|---------------------------|
+| 连接器 | 无锁读取 | 并行读取 | Exactly-Once 读取 | 增量快照读取 |
+|---------------------------------------------------------------------------------------|--------------|---------------|-------------------|---------------------------|
| [mongodb-cdc]({{< ref "docs/connectors/flink-sources/mongodb-cdc" >}}) | ✅ | ✅ | ✅ | ✅ |
| [mysql-cdc]({{< ref "docs/connectors/flink-sources/mysql-cdc" >}}) | ✅ | ✅ | ✅ | ✅ |
| [oracle-cdc]({{< ref "docs/connectors/flink-sources/oracle-cdc" >}}) | ✅ | ✅ | ✅ | ✅ |
@@ -91,16 +91,16 @@ The following table shows the current features of the connector:
| [db2-cdc]({{< ref "docs/connectors/flink-sources/db2-cdc" >}}) | ✅ | ✅ | ✅ | ✅ |
| [vitess-cdc]({{< ref "docs/connectors/flink-sources/vitess-cdc" >}}) | ✅ | ❌ | ❌ | ❌ |
-## Usage for Table/SQL API
+## Table/SQL API 的使用方式
-We need several steps to setup a Flink cluster with the provided connector.
+使用所提供的连接器搭建 Flink 集群需要以下几个步骤。
-1. Setup a Flink cluster with version 1.12+ and Java 8+ installed.
-2. Download the connector SQL jars from the [Downloads](https://github.com/apache/flink-cdc/releases) page (or [build yourself](#building-from-source)).
-3. Put the downloaded jars under `FLINK_HOME/lib/`.
-4. Restart the Flink cluster.
+1. 搭建一个安装了 1.12+ 版本 Flink 和 Java 8+ 的 Flink 集群。
+2. 从[下载](https://github.com/apache/flink-cdc/releases)页面下载连接器 SQL jar 包(或者[自行构建](#从源码构建))。
+3. 将下载的 jar 包放到 `FLINK_HOME/lib/` 目录下。
+4. 重启 Flink 集群。
-The example shows how to create a MySQL CDC source in [Flink SQL Client](https://nightlies.apache.org/flink/flink-docs-stable/docs/dev/table/sqlclient/) and execute queries on it.
+下面的示例展示了如何在 [Flink SQL Client](https://nightlies.apache.org/flink/flink-docs-stable/docs/dev/table/sqlclient/) 中创建一个 MySQL CDC source 并执行查询。
```sql
-- creates a mysql cdc table source
@@ -124,9 +124,9 @@ CREATE TABLE mysql_binlog (
SELECT id, UPPER(name), description, weight FROM mysql_binlog;
```
-## Usage for DataStream API
+## DataStream API 的使用方式
-Include following Maven dependency (available through Maven Central):
+引入以下 Maven 依赖(可通过 Maven Central 获取):
```
<dependency>
@@ -170,8 +170,8 @@ public class MySqlBinlogSourceExample {
}
}
```
-### Deserialization
-The following JSON data show the change event in JSON format.
+### 反序列化
+下面的 JSON 数据展示了 JSON 格式的变更事件。
```json
{
@@ -193,10 +193,10 @@ The following JSON data show the change event in JSON format.
"transaction": null
}
```
-**Note:** Please refer [Debezium documentation](https://debezium.io/documentation/reference/1.9/connectors/mysql.html#mysql-events
-) to know the meaning of each field.
+**注意:** 请参阅 [Debezium 文档](https://debezium.io/documentation/reference/1.9/connectors/mysql.html#mysql-events
+) 了解每个字段的含义。
-In some cases, users can use the `JsonDebeziumDeserializationSchema(true)` Constructor to enabled include schema in the message. Then the Debezium JSON message may look like this:
+在某些情况下,用户可以使用 `JsonDebeziumDeserializationSchema(true)` 构造函数在消息中包含 schema。此时 Debezium JSON 消息可能如下所示:
```json
{
"schema": {
@@ -301,10 +301,10 @@ In some cases, users can use the `JsonDebeziumDeserializationSchema(true)` Const
}
}
```
-Usually, it is recommended to exclude schema because schema fields makes the messages very verbose which reduces parsing performance.
+通常,建议排除 schema,因为 schema 字段会使消息非常冗长,从而降低解析性能。
-The `JsonDebeziumDeserializationSchema` can also accept custom configuration of `JsonConverter`, for example if you want to obtain numeric output for decimal data,
-you can construct `JsonDebeziumDeserializationSchema` as following:
+`JsonDebeziumDeserializationSchema` 还可以接受 `JsonConverter` 的自定义配置,例如,如果你想为 decimal 数据获得数值形式的输出,
+可以按照如下方式构造 `JsonDebeziumDeserializationSchema`:
```java
Map<String, Object> customConverterConfigs = new HashMap<>();
@@ -313,12 +313,12 @@ you can construct `JsonDebeziumDeserializationSchema` as following:
new JsonDebeziumDeserializationSchema(true, customConverterConfigs);
```
-## Building from source
+## 从源码构建
-Prerequisites:
+前置条件:
- git
- Maven
-- At least Java 8
+- 至少 Java 8
```
git clone https://github.com/apache/flink-cdc.git
@@ -326,6 +326,6 @@ cd flink-cdc
mvn clean install -DskipTests
```
-The dependencies are now available in your local `.m2` repository.
+现在,这些依赖可以在你本地的 `.m2` 仓库中使用了。
{{< top >}}
diff --git a/docs/content.zh/docs/connectors/flink-sources/postgres-cdc.md b/docs/content.zh/docs/connectors/flink-sources/postgres-cdc.md
index 01baf131a..6e8c3be1f 100644
--- a/docs/content.zh/docs/connectors/flink-sources/postgres-cdc.md
+++ b/docs/content.zh/docs/connectors/flink-sources/postgres-cdc.md
@@ -24,14 +24,13 @@ specific language governing permissions and limitations
under the License.
-->
-# Postgres CDC Connector
+# Postgres CDC 连接器
-The Postgres CDC connector allows for reading snapshot data and incremental data from PostgreSQL database. This document describes how to setup the Postgres CDC connector to run SQL queries against PostgreSQL databases.
+Postgres CDC 连接器允许从 PostgreSQL 数据库读取快照数据和增量数据。本文描述了如何设置 Postgres CDC 连接器来对 PostgreSQL 数据库运行 SQL 查询。
-Dependencies
-------------
+## 依赖
-In order to setup the Postgres CDC connector, the following table provides dependency information for both projects using a build automation tool (such as Maven or SBT) and SQL Client with SQL JAR bundles.
+为了设置 Postgres CDC 连接器,下表提供了使用构建自动化工具(如 Maven 或 SBT )和带有 SQL JAR 包的 SQL 客户端的两个项目的依赖关系信息。
### Maven dependency
@@ -39,16 +38,15 @@ In order to setup the Postgres CDC connector, the following table provides depen
### SQL Client JAR
-```Download link is available only for stable releases.```
+```下载链接仅适用于稳定版本。```
-Download [flink-sql-connector-postgres-cdc](https://mvnrepository.com/artifact/org.apache.flink/flink-sql-connector-postgres-cdc) and put it under `<FLINK_HOME>/lib/`.
+下载 [flink-sql-connector-postgres-cdc](https://mvnrepository.com/artifact/org.apache.flink/flink-sql-connector-postgres-cdc) 到 `<FLINK_HOME>/lib/` 目录下。
-**Note:** Refer to [flink-sql-connector-postgres-cdc](https://mvnrepository.com/artifact/org.apache.flink/flink-sql-connector-postgres-cdc), more released versions will be available in the Maven central warehouse.
+**注意:** 参考 [flink-sql-connector-postgres-cdc](https://mvnrepository.com/artifact/org.apache.flink/flink-sql-connector-postgres-cdc) 当前已发布的所有版本都可以在 Maven 中央仓库获取。
-How to create a Postgres CDC table
-----------------
+## 如何创建 Postgres CDC 表
-The Postgres CDC table can be defined as following:
+Postgres CDC 表可以定义如下:
```sql
-- register a PostgreSQL table 'shipments' in Flink SQL
@@ -76,8 +74,7 @@ CREATE TABLE shipments (
SELECT * FROM shipments;
```
-Connector Options
-----------------
+## 连接器配置项
<div class="highlight">
<table class="colwidths-auto docutils">
@@ -96,107 +93,106 @@ Connector Options
<td>required</td>
<td style="word-wrap: break-word;">(none)</td>
<td>String</td>
- <td>Specify what connector to use, here should be <code>'postgres-cdc'</code>.</td>
+ <td>指定要使用的连接器, 这里应该是 <code>'postgres-cdc'</code>.</td>
</tr>
<tr>
<td>hostname</td>
<td>required</td>
<td style="word-wrap: break-word;">(none)</td>
<td>String</td>
- <td>IP address or hostname of the PostgreSQL database server.</td>
+ <td>PostgreSQL 数据库服务器的 IP 地址或主机名。</td>
</tr>
<tr>
<td>username</td>
<td>required</td>
<td style="word-wrap: break-word;">(none)</td>
<td>String</td>
- <td>Name of the PostgreSQL database to use when connecting to the PostgreSQL database server.</td>
+ <td>连接到 PostgreSQL 数据库服务器时要使用的 PostgreSQL 用户的名称。</td>
</tr>
<tr>
<td>password</td>
<td>required</td>
<td style="word-wrap: break-word;">(none)</td>
<td>String</td>
- <td>Password to use when connecting to the PostgreSQL database server.</td>
+ <td>连接 PostgreSQL 数据库服务器时使用的密码。</td>
</tr>
<tr>
<td>database-name</td>
<td>required</td>
<td style="word-wrap: break-word;">(none)</td>
<td>String</td>
- <td>Database name of the PostgreSQL server to monitor.</td>
+ <td>要监视的 PostgreSQL 服务器的数据库名称。</td>
</tr>
<tr>
<td>schema-name</td>
<td>required</td>
<td style="word-wrap: break-word;">(none)</td>
<td>String</td>
- <td>Schema name of the PostgreSQL database to monitor.</td>
+ <td>要监视的 PostgreSQL 数据库的 Schema 名称。Schema 名称还支持正则表达式,以监视满足正则表达式的多个 schema。</td>
</tr>
<tr>
<td>table-name</td>
<td>required</td>
<td style="word-wrap: break-word;">(none)</td>
<td>String</td>
- <td>Table name of the PostgreSQL database to monitor.</td>
+ <td>需要监视的 PostgreSQL 数据库的表名。表名还支持正则表达式,以监视满足正则表达式的多个表。</td>
</tr>
<tr>
<td>port</td>
<td>optional</td>
<td style="word-wrap: break-word;">5432</td>
<td>Integer</td>
- <td>Integer port number of the PostgreSQL database server.</td>
+ <td>PostgreSQL 数据库服务器的整数端口号。</td>
</tr>
<tr>
<td>slot.name</td>
<td>required</td>
<td style="word-wrap: break-word;">(none)</td>
<td>String</td>
- <td>The name of the PostgreSQL logical decoding slot that was created for streaming changes from a particular plug-in
- for a particular database/schema. The server uses this slot to stream events to the connector that you are configuring.
- <br/>Slot names must conform to <a href="https://www.postgresql.org/docs/current/static/warm-standby.html#STREAMING-REPLICATION-SLOTS-MANIPULATION">PostgreSQL replication slot naming rules</a>, which state: "Each replication slot has a name, which can contain lower-case letters, numbers, and the underscore character."</td>
+ <td>为从特定插件以流式传输方式获取某个数据库/模式的变更数据,所创建的 Postgres 逻辑解码槽(logical decoding slot)的名称。服务器使用这个槽(slot)将事件流式传输给你要配置的连接器(connector)。
+ <br/>复制槽名称必须符合 <a href="https://www.postgresql.org/docs/current/static/warm-standby.html#STREAMING-REPLICATION-SLOTS-MANIPULATION">PostgreSQL 复制槽的命名规则</a>, 其规则如下: "Each replication slot has a name, which can contain lower-case letters, numbers, and the underscore character."</td>
</tr>
<tr>
<td>decoding.plugin.name</td>
<td>optional</td>
<td style="word-wrap: break-word;">decoderbufs</td>
<td>String</td>
- <td>The name of the Postgres logical decoding plug-in installed on the server.
- Supported values are decoderbufs, wal2json, wal2json_rds, wal2json_streaming, wal2json_rds_streaming and pgoutput.</td>
+ <td>安装在服务器上的 Postgres 逻辑解码插件的名称。
+ 支持的值为 decoderbufs、wal2json、wal2json_rds、wal2json_streaming、wal2json_rds_streaming 和 pgoutput。</td>
</tr>
<tr>
<td>changelog-mode</td>
<td>optional</td>
<td style="word-wrap: break-word;">all</td>
<td>String</td>
- <td>The changelog mode used for encoding streaming changes. Supported values are <code>all</code> (which encodes changes as retract stream using all RowKinds) and <code>upsert</code> (which encodes changes as upsert stream that describes idempotent updates on a key).
- <br/> <code>upsert</code> mode can be used for tables with primary keys when replica identity <code>FULL</code> is not an option. Primary keys must be set to use <code>upsert</code> mode.</td>
+ <td>用于编码流式变更的 changelog 模式。支持的值为 <code>all</code>(使用所有 RowKind 将变更编码为回撤流)和 <code>upsert</code>(将变更编码为描述针对某个键的幂等更新的 upsert 流)。
+ <br/> 当副本标识(replica identity)无法设置为 <code>FULL</code> 时,<code>upsert</code> 模式可用于有主键的表。使用 <code>upsert</code> 模式必须设置主键。</td>
</tr>
<tr>
<td>heartbeat.interval.ms</td>
<td>optional</td>
<td style="word-wrap: break-word;">30s</td>
<td>Duration</td>
- <td>The interval of sending heartbeat event for tracing the latest available replication slot offsets</td>
+ <td>用于跟踪最新可用复制槽位点的发送心跳事件的间隔。</td>
</tr>
<tr>
<td>debezium.*</td>
<td>optional</td>
<td style="word-wrap: break-word;">(none)</td>
<td>String</td>
- <td>Pass-through Debezium's properties to Debezium Embedded Engine which is used to capture data changes from Postgres server.
- For example: <code>'debezium.snapshot.mode' = 'never'</code>.
- See more about the <a href="https://debezium.io/documentation/reference/1.9/connectors/postgresql.html#postgresql-connector-properties">Debezium's Postgres Connector properties</a></td>
+ <td>将 Debezium 的属性传递给 Debezium 嵌入式引擎,该引擎用于从 Postgres 服务器捕获数据更改。
+ 例如: <code>'debezium.snapshot.mode' = 'never'</code>.
+ 查看更多关于 <a href="https://debezium.io/documentation/reference/1.9/connectors/postgresql.html#postgresql-connector-properties"> Debezium 的 Postgres 连接器属性</a></td>
</tr>
<tr>
<td>debezium.snapshot.select.statement.overrides</td>
<td>optional</td>
<td style="word-wrap: break-word;">(none)</td>
<td>String</td>
- <td>If you encounter a situation where there is a large amount of data in the table and you don't need all the historical data. You can try to specify the underlying configuration in debezium to select the data range you want to snapshot. This parameter only affects snapshots and does not affect subsequent data reading consumption.
- <br/> Note: PostgreSQL must use schema name and table name.
- <br/> For example: <code>'debezium.snapshot.select.statement.overrides' = 'schema.table'</code>.
- <br/> After specifying the above attributes, you must also add the following attributes:
+ <td>如果你遇到表中数据量很大,而你不需要所有历史数据的情况,可以尝试在 debezium 中指定底层配置来选择你想要快照的数据范围。该参数只影响快照,不影响后续的数据读取消费。
+ <br/> 注意: PostgreSQL 必须使用 schema 名称和表名。
+ <br/> 例如: <code>'debezium.snapshot.select.statement.overrides' = 'schema.table'</code>.
+ <br/> 指定上述属性后,你还必须添加以下属性:
<code> debezium.snapshot.select.statement.overrides.[schema].[table] </code>
</td>
</tr>
@@ -205,11 +201,11 @@ Connector Options
<td>optional</td>
<td style="word-wrap: break-word;">(none)</td>
<td>String</td>
- <td>You can specify SQL statements to limit the data range of snapshot.
- <br/> Note1: Schema and table need to be specified in the SQL statement, and the SQL should conform to the syntax of the data source.Currently.
- <br/> For example: <code>'debezium.snapshot.select.statement.overrides.schema.table' = 'select * from schema.table where 1 != 1'</code>.
- <br/> Note2: The Flink SQL client submission task does not support functions with single quotation marks in the content.
- <br/> For example: <code>'debezium.snapshot.select.statement.overrides.schema.table' = 'select * from schema.table where to_char(rq, 'yyyy-MM-dd')'</code>.
+ <td>你可以指定 SQL 语句来限制快照的数据范围。
+ <br/> 注意1: SQL 语句中需要指定 schema 和表,且 SQL 应符合数据源的语法。
+ <br/> 例如: <code>'debezium.snapshot.select.statement.overrides.schema.table' = 'select * from schema.table where 1 != 1'</code>.
+ <br/> 注意2: Flink SQL 客户端提交的任务不支持内容中带单引号的函数。
+ <br/> 例如: <code>'debezium.snapshot.select.statement.overrides.schema.table' = 'select * from schema.table where to_char(rq, 'yyyy-MM-dd')'</code>.
</td>
</tr>
<tr>
@@ -217,12 +213,12 @@ Connector Options
<td>optional</td>
<td style="word-wrap: break-word;">false</td>
<td>Boolean</td>
- <td>Incremental snapshot is a new mechanism to read snapshot of a table. Compared to the old snapshot mechanism,
- the incremental snapshot has many advantages, including:
- <br/>(1) source can be parallel during snapshot reading,
- <br/>(2) source can perform checkpoints in the chunk granularity during snapshot reading,
- <br/>(3) source doesn't need to acquire global read lock (FLUSH TABLES WITH READ LOCK) before snapshot reading.
- <br/>Please see <a href="#incremental-snapshot-reading-experimental">Incremental Snapshot Reading</a> section for more detailed information.
+ <td>增量快照是一种读取表快照的新机制,与旧的快照机制相比,
+ 增量快照有许多优点,包括:
+ <br/>(1)在快照读取期间,Source 支持并发读取,
+ <br/>(2)在快照读取期间,Source 支持进行 chunk 粒度的 checkpoint,
+ <br/>(3)在快照读取之前,Source 不需要获取全局读锁(FLUSH TABLES WITH READ LOCK)。
+ <br/>请查阅 <a href="#增量快照读取实验性">增量快照读取</a> 章节了解更多详细信息。
</td>
</tr>
<tr>
@@ -230,10 +226,10 @@ Connector Options
<td>optional</td>
<td style="word-wrap: break-word;">false</td>
<td>Boolean</td>
- <td>Whether to close idle readers at the end of the snapshot phase. <br>
- 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.<br>
- 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'
+ <td>是否在快照阶段结束后关闭空闲的 Reader。 <br>
+ 当 'execution.checkpointing.checkpoints-after-tasks-finish.enabled' 设置为 true 时,要求 flink 版本大于等于 1.14。<br>
+ 如果 flink 版本大于等于 1.15,'execution.checkpointing.checkpoints-after-tasks-finish.enabled' 的默认值已变更为 true,
+ 因此不需要显式配置 'execution.checkpointing.checkpoints-after-tasks-finish.enabled' = 'true'
</td>
</tr>
<tr>
@@ -248,8 +244,8 @@ Connector Options
<td>optional</td>
<td style="word-wrap: break-word;">3</td>
<td>Integer</td>
- <td>The number of checkpoint delays before starting to commit the LSN offsets. <br>
- The checkpoint LSN offsets will be committed in rolling fashion, the earliest checkpoint identifier will be committed first from the delayed checkpoints.
+ <td>在开始提交 LSN 位点之前,允许延迟的 checkpoint 次数。 <br>
+ checkpoint 的 LSN 位点将以滚动方式提交,最早的那个 checkpoint 标识符将首先从延迟的 checkpoint 中被提交。
</td>
</tr>
<tr>
@@ -258,8 +254,8 @@ Connector Options
<td style="word-wrap: break-word;">true</td>
<td>Boolean</td>
<td>
- Whether to assign the unbounded chunks first during snapshot reading phase.<br>
- This might help reduce the risk of the TaskManager experiencing an out-of-memory (OOM) error when taking a snapshot of the largest unbounded chunk.<br>
+ 快照读取阶段是否先分配 UnboundedChunk。<br>
+ 这可能有助于降低 TaskManager 在对最大的 UnboundedChunk 执行快照时出现内存溢出 (OOM) 错误的风险。<br>
</td>
</tr>
<tr>
@@ -268,10 +264,10 @@ Connector Options
<td style="word-wrap: break-word;">false</td>
<td>Boolean</td>
<td>
- Whether to skip backfill in snapshot reading phase.<br>
- If backfill is skipped, changes on captured tables during snapshot phase will be consumed later in change log reading phase instead of being merged into the snapshot.<br>
- WARNING: Skipping backfill might lead to data inconsistency because some change log events happened within the snapshot phase might be replayed (only at-least-once semantic is promised).
- For example updating an already updated value in snapshot, or deleting an already deleted entry in snapshot. These replayed change log events should be handled specially.
+ 是否在快照读取阶段跳过 backfill 。<br>
+ 如果跳过 backfill ,快照阶段捕获表的更改将在稍后的 changelog 读取阶段被回放,而不是合并到快照中。<br>
+ 警告:跳过 backfill 可能会导致数据不一致,因为快照阶段发生的某些 changelog 事件可能会被重放(仅保证 at-least-once )。
+ 例如,更新快照阶段已更新的值,或删除快照阶段已删除的数据。这些重放的 changelog 事件应进行特殊处理。
</td>
</tr>
<tr>
@@ -293,10 +289,10 @@ Connector Options
<td style="word-wrap: break-word;">false</td>
<td>Boolean</td>
<td>
- Whether to enable reading partitioned tables via partition root.<br>
- If enabled:
- (1) PUBLICATION must be created beforehand with parameter publish_via_partition_root=true
- (2) Table list (regex or predefined list) should only match the parent table name, if table list matches both parent and child tables, snapshot data will be read twice.
+ 是否启用通过分区根读取分区表。<br>
+ 如果启用:
+ (1)必须事先创建 PUBLICATION,并带有参数 publish_via_partition_root=true
+ (2)表列表(正则表达式或预定义列表)应当只匹配父表名,如果表列表同时匹配父表和子表,快照数据将被读取两次。
</td>
</tr>
<tr>
@@ -319,19 +315,19 @@ Connector Options
</div>
<div>
-### Notes
+### 注意事项
-#### `slot.name` option
+#### `slot.name` 选项
-The `slot.name` is recommended to set for different tables to avoid the potential `PSQLException: ERROR: replication slot "flink" is active for PID 974` error. See more [here](https://debezium.io/documentation/reference/1.9/connectors/postgresql.html#postgresql-property-slot-name).
+建议为不同的表设置不同的 `slot.name`,以避免潜在的 `PSQLException: ERROR: replication slot "flink" is active for PID 974` 错误。更多信息请参阅 [这里](https://debezium.io/documentation/reference/1.9/connectors/postgresql.html#postgresql-property-slot-name)。
-#### `scan.lsn-commit.checkpoints-num-delay` option
+#### `scan.lsn-commit.checkpoints-num-delay` 选项
-When consuming PostgreSQL logs, the LSN offset must be committed to trigger the log data cleanup for the corresponding slot. However, once the LSN offset is committed, earlier offsets become invalid. To ensure access to earlier LSN offsets for job recovery, we delay the LSN commit by `scan.lsn-commit.checkpoints-num-delay` (default value is `3`) checkpoints. This feature is available when config option `scan.incremental.snapshot.enabled` is set to true.
+在消费 PostgreSQL 日志时,必须提交 LSN 位点以触发对应复制槽的日志数据清理。然而,一旦 LSN 位点被提交,更早的位点就会失效。为了确保作业恢复时能够访问更早的 LSN 位点,我们将 LSN 的提交延迟 `scan.lsn-commit.checkpoints-num-delay`(默认值为 `3`)个 checkpoint。该特性在配置选项 `scan.incremental.snapshot.enabled` 设置为 true 时可用。
-### Incremental Snapshot Options
+### 增量快照选项
-The following options is available only when `scan.incremental.snapshot.enabled=true`:
+以下选项仅在 `scan.incremental.snapshot.enabled=true` 时可用:
<div class="highlight">
<table class="colwidths-auto docutils">
@@ -350,60 +346,60 @@ The following options is available only when `scan.incremental.snapshot.enabled=
<td>optional</td>
<td style="word-wrap: break-word;">8096</td>
<td>Integer</td>
- <td>The chunk size (number of rows) of table snapshot, captured tables are split into multiple chunks when read the snapshot of table.</td>
+ <td>表快照的分片大小(行数),读取表的快照时,捕获的表被拆分为多个分片。</td>
</tr>
<tr>
<td>scan.startup.mode</td>
<td>optional</td>
<td style="word-wrap: break-word;">initial</td>
<td>String</td>
- <td>Optional startup mode for Postgres CDC consumer, valid enumerations are "initial", "latest-offset", "committed-offset" and "snapshot".
- Please see <a href="#startup-reading-position">Startup Reading Position</a> section for more detailed information.</td>
+ <td>Postgres CDC 消费者可选的启动模式,合法的模式为 "initial","latest-offset","committed-offset" 和 "snapshot"。
+ 请查阅 <a href="#启动模式">启动模式</a> 章节了解更多详细信息。</td>
</tr>
<tr>
<td>chunk-meta.group.size</td>
<td>optional</td>
<td style="word-wrap: break-word;">1000</td>
<td>Integer</td>
- <td>The group size of chunk meta, if the meta size exceeds the group size, the meta will be divided into multiple groups.</td>
+ <td>分片元数据的分组大小,如果元数据大小超过分组大小,则元数据将被划分为多个分组。</td>
</tr>
<tr>
<td>connect.timeout</td>
<td>optional</td>
<td style="word-wrap: break-word;">30s</td>
<td>Duration</td>
- <td>The maximum time that the connector should wait after trying to connect to the PostgreSQL database server before timing out.</td>
+ <td>连接器在尝试连接到 PostgreSQL 数据库服务器后超时前应等待的最长时间。</td>
</tr>
<tr>
<td>connect.pool.size</td>
<td>optional</td>
<td style="word-wrap: break-word;">30</td>
<td>Integer</td>
- <td>The connection pool size.</td>
+ <td>连接池大小。</td>
</tr>
<tr>
<td>connect.max-retries</td>
<td>optional</td>
<td style="word-wrap: break-word;">3</td>
<td>Integer</td>
- <td>The max retry times that the connector should retry to build database server connection.</td>
+ <td>连接器应重试以建立 PostgreSQL 数据库服务器连接的最大重试次数。</td>
</tr>
<tr>
<td>scan.snapshot.fetch.size</td>
<td>optional</td>
<td style="word-wrap: break-word;">1024</td>
<td>Integer</td>
- <td>The maximum fetch size for per poll when read table snapshot.</td>
+ <td>读取表快照时每次读取数据的最大条数。</td>
</tr>
<tr>
<td>scan.incremental.snapshot.chunk.key-column</td>
<td>optional</td>
<td style="word-wrap: break-word;">(none)</td>
<td>String</td>
- <td>The chunk key of table snapshot, captured tables are split into multiple chunks by a chunk key when read the snapshot of table.
- By default, the chunk key is the first column of the primary key. A column that is not part of the primary key can be used as a chunk key, but this may lead to slower query performance.
- <br>
- <b>Warning:</b> Using a non-primary key column as a chunk key may lead to data inconsistencies. Please see <a href="#warning">Warning</a> for details.
+ <td>表快照的分片键,在读取表的快照时,被捕获的表会按分片键拆分为多个分片。
+ 默认情况下,分片键是主键的第一列。可以使用非主键列作为分片键,但这可能会导致查询性能下降。
+ <br>
+ <b>警告:</b> 使用非主键列作为分片键可能会导致数据不一致。请参阅 <a href="#警告">警告</a> 了解详细信息。
</td>
</tr>
<tr>
@@ -411,27 +407,26 @@ The following options is available only when `scan.incremental.snapshot.enabled=
<td>optional</td>
<td style="word-wrap: break-word;">0.05d</td>
<td>Double</td>
- <td>The lower bound of chunk key distribution factor. The distribution factor is used to determine whether the table is evenly distribution or not.
- The table chunks would use evenly calculation optimization when the data distribution is even, and the query for splitting would happen when it is uneven.
- The distribution factor could be calculated by (MAX(id) - MIN(id) + 1) / rowCount.</td>
+ <td>分片键分布因子的下界。分布因子用于判断表的数据分布是否均匀。
+ 当数据分布均匀时,表分片将使用均匀计算优化,当数据分布不均匀时,将通过查询进行拆分。
+ 分布因子可以通过 (MAX(id) - MIN(id) + 1) / rowCount 计算得出。</td>
</tr>
<tr>
<td>chunk-key.even-distribution.factor.upper-bound</td>
<td>optional</td>
<td style="word-wrap: break-word;">1000.0d</td>
<td>Double</td>
- <td>The upper bound of chunk key distribution factor. The distribution factor is used to determine whether the table is evenly distribution or not.
- The table chunks would use evenly calculation optimization when the data distribution is even, and the query for splitting would happen when it is uneven.
- The distribution factor could be calculated by (MAX(id) - MIN(id) + 1) / rowCount.</td>
+ <td>分片键分布因子的上界。分布因子用于判断表的数据分布是否均匀。
+ 当数据分布均匀时,表分片将使用均匀计算优化,当数据分布不均匀时,将通过查询进行拆分。
+ 分布因子可以通过 (MAX(id) - MIN(id) + 1) / rowCount 计算得出。</td>
</tr>
</tbody>
</table>
</div>
-Available Metadata
-----------------
+## 可用的元数据
-The following format metadata can be exposed as read-only (VIRTUAL) columns in a table definition.
+下表中的元数据可以在 DDL 中作为只读(虚拟)meta 列声明。
<table class="colwidths-auto docutils">
<thead>
@@ -445,34 +440,40 @@ The following format metadata can be exposed as read-only (VIRTUAL) columns in a
<tr>
<td>table_name</td>
<td>STRING NOT NULL</td>
- <td>Name of the table that contain the row.</td>
+ <td>当前记录所属的表名称。</td>
</tr>
<tr>
<td>schema_name</td>
<td>STRING NOT NULL</td>
- <td>Name of the schema that contain the row.</td>
+ <td>当前记录所属的 schema 名称。</td>
</tr>
<tr>
<td>database_name</td>
<td>STRING NOT NULL</td>
- <td>Name of the database that contain the row.</td>
+ <td>当前记录所属的库名称。</td>
</tr>
<tr>
<td>op_ts</td>
<td>TIMESTAMP_LTZ(3) NOT NULL</td>
- <td>It indicates the time that the change was made in the database. <br>If the record is read from snapshot of the table instead of the change stream, the value is always 0.</td>
+ <td>当前记录表在数据库中更新的时间。 <br>如果从表的快照而不是更改流读取记录,该值将始终为0。</td>
+ </tr>
+ <tr>
+ <td>row_kind</td>
+ <td>STRING NOT NULL</td>
+ <td>当前记录的变更类型。<br>
+ 注意:如果 Source 算子选择为每条记录输出 row_kind 列,则下游 SQL 操作符在处理回撤时可能会由于此新添加的列而无法比较。建议仅在简单的同步作业中使用此元数据列。<br>
+ '+I' 表示 INSERT 消息,'-D' 表示 DELETE 消息,'-U' 表示 UPDATE_BEFORE 消息,'+U' 表示 UPDATE_AFTER 消息。</td>
</tr>
</tbody>
</table>
-Limitation
---------
+## 限制
-### Can't perform checkpoint during scanning snapshot of tables when incremental snapshot is disabled
+### 增量快照关闭时,无法在扫描表快照期间执行 checkpoint
-When `scan.incremental.snapshot.enabled=false`, we have the following limitation.
+当 `scan.incremental.snapshot.enabled=false` 时,存在以下限制。
-During scanning snapshot of database tables, since there is no recoverable position, we can't perform checkpoints. In order to not perform checkpoints, Postgres CDC source will keep the checkpoint waiting to timeout. The timeout checkpoint will be recognized as failed checkpoint, by default, this will trigger a failover for the Flink job. So if the database table is large, it is recommended to add following Flink configurations to avoid failover because of the timeout checkpoints:
+在扫描数据库表的快照期间,由于没有可恢复的位点,我们无法执行 checkpoint。为了不执行 checkpoint,Postgres CDC source 会让 checkpoint 一直等待直至超时。超时的 checkpoint 将被认定为失败的 checkpoint,默认情况下,这会触发 Flink 作业的故障转移。因此,如果数据库表很大,建议添加以下 Flink 配置,以避免因 checkpoint 超时而触发故障转移:
```
execution.checkpointing.interval: 10min
@@ -481,7 +482,7 @@ restart-strategy: fixed-delay
restart-strategy.fixed-delay.attempts: 2147483647
```
-The extended CREATE TABLE example demonstrates the syntax for exposing these metadata fields:
+下述创建表示例展示元数据列的用法:
```sql
CREATE TABLE products (
db_name STRING METADATA FROM 'database_name' VIRTUAL,
@@ -505,32 +506,30 @@ CREATE TABLE products (
);
```
-Features
---------
+## 特性
-### Incremental Snapshot Reading (Experimental)
+### 增量快照读取(实验性)
-Incremental snapshot reading is a new mechanism to read snapshot of a table. Compared to the old snapshot mechanism, the incremental snapshot has many advantages, including:
-* (1) PostgreSQL CDC Source can be parallel during snapshot reading
-* (2) PostgreSQL CDC Source can perform checkpoints in the chunk granularity during snapshot reading
-* (3) PostgreSQL CDC Source doesn't need to acquire global read lock before snapshot reading
+增量快照读取是一种读取表快照的新机制。与旧的快照机制相比,增量快照具有许多优点,包括:
+* (1)在快照读取期间,PostgreSQL CDC Source 支持并发读取
+* (2)在快照读取期间,PostgreSQL CDC Source 支持进行 chunk 粒度的 checkpoint
+* (3)在快照读取之前,PostgreSQL CDC Source 不需要获取全局读锁
-During the incremental snapshot reading, the PostgreSQL CDC Source firstly splits snapshot chunks (splits) by user specified chunk key of table,
-and then PostgreSQL CDC Source assigns the chunks to multiple readers to read the data of snapshot chunk.
+在增量快照读取过程中,PostgreSQL CDC Source 首先会根据用户指定的表分片键将快照切分为多个分片(splits),
+然后 PostgreSQL CDC Source 将这些分片分配给多个 reader,以读取快照分片的数据。
-### Exactly-Once Processing
+### Exactly-Once 处理
-The Postgres CDC connector is a Flink Source connector which will read database snapshot first and then continues to read binlogs with **exactly-once processing** even failures happen. Please read [How the connector works](https://debezium.io/documentation/reference/1.9/connectors/postgresql.html#how-the-postgresql-connector-works).
+Postgres CDC 连接器是一个 Flink Source 连接器,它将首先读取数据库快照,然后继续读取 binlog,即使在处理时出现故障,也能**准确读取数据**。请参阅 [How the connector works](https://debezium.io/documentation/reference/1.9/connectors/postgresql.html#how-the-postgresql-connector-works)。
-### Startup Reading Position
+### 启动模式
-The config option `scan.startup.mode` specifies the startup mode for PostgreSQL CDC consumer. The valid enumerations are:
+配置选项`scan.startup.mode`指定 PostgreSQL CDC 使用者的启动模式。有效枚举包括:
-- `initial` (default): Performs an initial snapshot on the monitored database tables upon first startup, and continue to read the replication slot.
-- `latest-offset`: Never to perform snapshot on the monitored database tables upon first startup, just read from
- the end of the replication which means only have the changes since the connector was started.
-- `committed-offset`: Skip snapshot phase and start reading events from a `confirmed_flush_lsn` offset of replication slot.
-- `snapshot`: Only the snapshot phase is performed and exits after the snapshot phase reading is completed.
+- `initial` (默认):在第一次启动时对受监视的数据库表执行初始快照,并继续读取复制槽。
+- `latest-offset`:首次启动时,从不对受监视的数据库表执行快照, 连接器仅从复制槽的结尾处开始读取,这意味着连接器只能读取在连接器启动之后的数据更改。
+- `committed-offset`:跳过快照阶段,从复制槽的 `confirmed_flush_lsn` 位点开始读取事件。
+- `snapshot`:仅执行快照阶段,并在快照阶段读取完成后退出。
### 动态加表
@@ -599,12 +598,12 @@ $ ./bin/flink run \
### DataStream Source
-The Postgres CDC connector can also be a DataStream source. There are two modes for the DataStream source:
+Postgres CDC 连接器也可以是一个数据流源。DataStream 源有两种模式:
-- incremental snapshot based, which allows parallel reading
-- SourceFunction based, which only supports single thread reading
+- 基于增量快照,允许并行读取
+- 基于 SourceFunction,仅支持单线程读取
-#### Incremental Snapshot based DataStream (Experimental)
+#### 基于增量快照的 DataStream(实验性)
```java
import org.apache.flink.cdc.connectors.base.source.jdbc.JdbcIncrementalSource;
@@ -652,7 +651,7 @@ public class PostgresParallelSourceExample {
}
```
-#### SourceFunction-based DataStream
+#### 基于 SourceFunction 的 DataStream
```java
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
@@ -704,43 +703,42 @@ public class PostgreSQLSourceExample {
1. Group 名称是 `namespace.schema.table`,这里的 `namespace` 是实际的数据库名称, `schema` 是实际的 schema 名称, `table` 是实际的表名称。
2. 对于 PostgreSQL,Group 的名称会类似于 `test_database.test_schema.test_table`。
-### Tables Without primary keys
+### 关于无主键表
-Starting from version 3.4.0, Postgres CDC support tables that do not have a primary key. To use a table without primary keys, you must configure the `scan.incremental.snapshot.chunk.key-column` option and specify one non-null field.
+从3.4.0 版本开始支持无主键表,使用无主键表必须设置 `scan.incremental.snapshot.chunk.key-column`,且只能选择非空类型的一个字段。
-There are two places that need to be taken care of.
+在使用无主键表时,需要注意以下两种情况。
-1. If there is an index in the table, try to use a column which is contained in the index in `scan.incremental.snapshot.chunk.key-column`. This will increase the speed of select statement.
-2. The processing semantics of a Postgres CDC table without primary keys is determined based on the behavior of the column that are specified by the `scan.incremental.snapshot.chunk.key-column`.
-* If no update operation is performed on the specified column, the exactly-once semantics is ensured.
-* If the update operation is performed on the specified column, only the at-least-once semantics is ensured. However, you can specify primary keys at downstream and perform the idempotence operation to ensure data correctness.
+1. 配置 `scan.incremental.snapshot.chunk.key-column` 时,如果表中存在索引,请尽量使用索引中的列来加快 select 速度。
+2. 无主键表的处理语义由 `scan.incremental.snapshot.chunk.key-column` 指定的列的行为决定:
+* 如果指定的列不存在更新操作,此时可以保证 Exactly once 语义。
+* 如果指定的列存在更新操作,此时只能保证 At least once 语义。但可以结合下游,通过指定下游主键,结合幂等性操作来保证数据的正确性。
-#### Warning
+#### 警告
-Using a **non-primary key column** as the `scan.incremental.snapshot.chunk.key-column` for a Postgres table with primary keys may lead to data inconsistencies. Below is a scenario illustrating this issue and recommendations to mitigate potential problems.
+在 Postgres 表中,若使用 **非主键列** 作为有主键表的 `scan.incremental.snapshot.chunk.key-column`,可能导致**数据不一致**。以下为可能出现的问题及其缓解方案。
-#### Problem Scenario
+#### 问题场景
-- **Table Structure:**
- - **Primary Key:** `id`
- - **Chunk Key Column:** `pid` (Not a primary key)
+- **表结构:**
+ - **主键:** `id`
+ - **分片键列 :** `pid`(非主键)
-- **Snapshot Splits:**
- - **Split 0:** `1 < pid <= 3`
- - **Split 1:** `3 < pid <= 5`
+- **快照分片 :**
+ - **分片 0:** `1 < pid <= 3`
+ - **分片 1:** `3 < pid <= 5`
-- **Operation:**
- - Two different subtasks are reading Split 0 and Split 1 concurrently.
- - An update operation changes `pid` from `2` to `4` for `id=0` while both splits are being read. This update occurs between the low and high watermark of both splits.
+- **操作 :**
+ - 两个子任务并行读取 **分片 0** 和 **分片 1**。
+ - 在读取过程中,发生了一次 **更新** 操作,使 `id=0` 的 `pid` 从 `2` 变为 `4`,在两个分片的**高低水位**间都包含此次变更,导致该更新操作在增量阶段不会被处理。
-- **Result:**
- - **Split 0:** Contains the record `[id=0, pid=2]`
- - **Split 1:** Contains the record `[id=0, pid=4]`
+- **结果 :**
+ - **分片 0:** 记录 `[id=0, pid=2]`
+ - **分片 1:** 记录 `[id=0, pid=4]`
-Since the order of processing these records cannot be guaranteed, the final value of `pid` for `id=0` may end up being either `2` or `4`, leading to potential data inconsistencies.
+由于**处理顺序**无法保证,最终 `id=0` 的 `pid` 可能为 `2` 或 `4`,从而导致数据不一致。
-Data Type Mapping
-----------------
+## 数据类型映射
<div class="wy-table-responsive">
<table class="colwidths-auto docutils">
@@ -817,6 +815,10 @@ Data Type Mapping
<td>TIMESTAMP [(p)] [WITHOUT TIMEZONE]</td>
<td>TIMESTAMP [(p)] [WITHOUT TIMEZONE]</td>
</tr>
+ <tr>
+ <td>TIMESTAMP [ (p) ] WITH TIME ZONE</td>
+ <td>TIMESTAMP_LTZ(p)</td>
+ </tr>
<tr>
<td>
CHAR(n)<br>
diff --git a/docs/content.zh/docs/connectors/flink-sources/sqlserver-cdc.md b/docs/content.zh/docs/connectors/flink-sources/sqlserver-cdc.md
index 1e0c9d9b1..398d87b74 100644
--- a/docs/content.zh/docs/connectors/flink-sources/sqlserver-cdc.md
+++ b/docs/content.zh/docs/connectors/flink-sources/sqlserver-cdc.md
@@ -24,14 +24,14 @@ specific language governing permissions and limitations
under the License.
-->
-# SQLServer CDC Connector
+# SQLServer CDC 连接器
-The SQLServer CDC connector allows for reading snapshot data and incremental data from SQLServer database. This document describes how to setup the SQLServer CDC connector to run SQL queries against SQLServer databases.
+SQLServer CDC 连接器允许从 SQLServer 数据库读取快照数据和增量数据。本文描述了如何设置 SQLServer CDC 连接器来对 SQLServer 数据库运行 SQL 查询。
-Dependencies
+依赖
------------
-In order to setup the SQLServer CDC connector, the following table provides dependency information for both projects using a build automation tool (such as Maven or SBT) and SQL Client with SQL JAR bundles.
+为了设置 SQLServer CDC 连接器,下表提供了使用构建自动化工具(如 Maven 或 SBT )和带有 SQL JAR 包的 SQL 客户端的两个项目的依赖关系信息。
### Maven dependency
@@ -39,24 +39,24 @@ In order to setup the SQLServer CDC connector, the following table provides depe
### SQL Client JAR
-```Download link is available only for stable releases.```
+```下载链接仅适用于稳定版本。```
-Download [flink-sql-connector-sqlserver-cdc](https://mvnrepository.com/artifact/org.apache.flink/flink-sql-connector-sqlserver-cdc) and put it under `<FLINK_HOME>/lib/`.
+下载 [flink-sql-connector-sqlserver-cdc](https://mvnrepository.com/artifact/org.apache.flink/flink-sql-connector-sqlserver-cdc) 到 `<FLINK_HOME>/lib/` 目录下。
-**Note:** Refer to [flink-sql-connector-sqlserver-cdc](https://mvnrepository.com/artifact/org.apache.flink/flink-sql-connector-sqlserver-cdc), more released versions will be available in the Maven central warehouse.
+**注意:** 参考 [flink-sql-connector-sqlserver-cdc](https://mvnrepository.com/artifact/org.apache.flink/flink-sql-connector-sqlserver-cdc) 当前已发布的所有版本都可以在 Maven 中央仓库获取。
-Setup SQLServer Database
+设置 SQLServer 数据库
----------------
-A SQL Server administrator must enable change data capture on the source tables that you want to capture. The database must already be enabled for CDC. To enable CDC on a table, a SQL Server administrator runs the stored procedure ```sys.sp_cdc_enable_table``` for the table.
+SQL Server 管理员必须在你想要捕获的源表上启用变更数据捕获(CDC)。数据库必须已经启用了 CDC。要在表上启用 CDC,SQL Server 管理员需要为该表运行存储过程 ```sys.sp_cdc_enable_table```。
-**Prerequisites:**
-* CDC is enabled on the SQL Server database.
-* The SQL Server Agent is running.
-* You are a member of the db_owner fixed database role for the database.
+**前置条件:**
+* SQL Server 数据库已启用 CDC。
+* SQL Server Agent 正在运行。
+* 你是该数据库 db_owner 固定数据库角色的成员。
-**Procedure:**
-* Connect to the SQL Server database by database management studio.
-* Run the following SQL statement to enable CDC on the table.
+**步骤:**
+* 通过数据库管理工具(database management studio)连接到 SQL Server 数据库。
+* 运行以下 SQL 语句,在表上启用 CDC。
```sql
USE MyDB
GO
@@ -69,7 +69,7 @@ EXEC sys.sp_cdc_enable_table
@supports_net_changes = 0
GO
```
-* Verifying that the user has access to the CDC table
+* 验证用户是否有权访问 CDC 表
```sql
--The following example runs the stored procedure sys.sp_cdc_help_change_data_capture on the database MyDB:
USE MyDB;
@@ -77,12 +77,12 @@ GO
EXEC sys.sp_cdc_help_change_data_capture
GO
```
-The query returns configuration information for each table in the database that is enabled for CDC and that contains change data that the caller is authorized to access. If the result is empty, verify that the user has privileges to access both the capture instance and the CDC tables.
+该查询会针对数据库中已启用 CDC 且包含调用者有权访问的变更数据的每个表返回配置信息。如果结果为空,请验证用户是否有权访问捕获实例和 CDC 表。
-How to create a SQLServer CDC table
+如何创建 SQLServer CDC 表
----------------
-The SqlServer CDC table can be defined as following:
+SqlServer CDC 表可以定义如下:
```sql
-- register a SqlServer table 'orders' in Flink SQL
@@ -107,7 +107,7 @@ CREATE TABLE orders (
SELECT * FROM orders;
```
-Connector Options
+连接器配置项
----------------
<div class="highlight">
@@ -127,107 +127,107 @@ Connector Options
<td>required</td>
<td style="word-wrap: break-word;">(none)</td>
<td>String</td>
- <td>Specify what connector to use, here should be <code>'sqlserver-cdc'</code>.</td>
+ <td>指定要使用的连接器, 这里应该是 <code>'sqlserver-cdc'</code>.</td>
</tr>
<tr>
<td>hostname</td>
<td>required</td>
<td style="word-wrap: break-word;">(none)</td>
<td>String</td>
- <td>IP address or hostname of the SQLServer database.</td>
+ <td>SQLServer 数据库的 IP 地址或主机名。</td>
</tr>
<tr>
<td>username</td>
<td>required</td>
<td style="word-wrap: break-word;">(none)</td>
<td>String</td>
- <td>Username to use when connecting to the SQLServer database.</td>
+ <td>连接到 SQLServer 数据库时要使用的用户名。</td>
</tr>
<tr>
<td>password</td>
<td>required</td>
<td style="word-wrap: break-word;">(none)</td>
<td>String</td>
- <td>Password to use when connecting to the SQLServer database.</td>
+ <td>连接 SQLServer 数据库时使用的密码。</td>
</tr>
<tr>
<td>database-name</td>
<td>required</td>
<td style="word-wrap: break-word;">(none)</td>
<td>String</td>
- <td>Database name of the SQLServer database to monitor.</td>
+ <td>要监视的 SQLServer 数据库名称。</td>
</tr>
<tr>
<td>table-name</td>
<td>required</td>
<td style="word-wrap: break-word;">(none)</td>
<td>String</td>
- <td>Table name of the SQLServer database to monitor, e.g.: "db1.table1"</td>
+ <td>需要监视的 SQLServer 数据库的表名,例如: "db1.table1"</td>
</tr>
<tr>
<td>port</td>
<td>optional</td>
<td style="word-wrap: break-word;">1433</td>
<td>Integer</td>
- <td>Integer port number of the SQLServer database.</td>
+ <td>SQLServer 数据库的整数端口号。</td>
</tr>
<tr>
<td>server-time-zone</td>
<td>optional</td>
<td style="word-wrap: break-word;">UTC</td>
<td>String</td>
- <td>The session time zone in database server, e.g. "Asia/Shanghai".</td>
+ <td>数据库服务器中的会话时区, 例如: "Asia/Shanghai"。</td>
</tr>
<tr>
<td>scan.incremental.snapshot.enabled</td>
<td>optional</td>
<td style="word-wrap: break-word;">true</td>
<td>Boolean</td>
- <td>Whether enable parallelism snapshot.</td>
+ <td>是否启用并行快照。</td>
</tr>
<tr>
<td>chunk-meta.group.size</td>
<td>optional</td>
<td style="word-wrap: break-word;">1000</td>
<td>Integer</td>
- <td>The group size of chunk meta, if the meta size exceeds the group size, the meta will be divided into multiple groups.</td>
+ <td>分片元数据的分组大小,如果元数据大小超过分组大小,则元数据将被划分为多个分组。</td>
</tr>
<tr>
<td>chunk-key.even-distribution.factor.lower-bound</td>
<td>optional</td>
<td style="word-wrap: break-word;">0.05d</td>
<td>Double</td>
- <td>The lower bound of chunk key distribution factor. The distribution factor is used to determine whether the table is evenly distribution or not.
- The table chunks would use evenly calculation optimization when the data distribution is even, and the query for splitting would happen when it is uneven.
- The distribution factor could be calculated by (MAX(id) - MIN(id) + 1) / rowCount.</td>
+ <td>分片键分布因子的下界。分布因子用于判断表的数据分布是否均匀。
+ 当数据分布均匀时,表分片将使用均匀计算优化,当数据分布不均匀时,将通过查询进行拆分。
+ 分布因子可以通过 (MAX(id) - MIN(id) + 1) / rowCount 计算得出。</td>
</tr>
<tr>
<td>chunk-key.even-distribution.factor.upper-bound</td>
<td>optional</td>
<td style="word-wrap: break-word;">1000.0d</td>
<td>Double</td>
- <td>The upper bound of chunk key distribution factor. The distribution factor is used to determine whether the table is evenly distribution or not.
- The table chunks would use evenly calculation optimization when the data distribution is even, and the query for splitting would happen when it is uneven.
- The distribution factor could be calculated by (MAX(id) - MIN(id) + 1) / rowCount.</td>
+ <td>分片键分布因子的上界。分布因子用于判断表的数据分布是否均匀。
+ 当数据分布均匀时,表分片将使用均匀计算优化,当数据分布不均匀时,将通过查询进行拆分。
+ 分布因子可以通过 (MAX(id) - MIN(id) + 1) / rowCount 计算得出。</td>
</tr>
<tr>
<td>debezium.*</td>
<td>optional</td>
<td style="word-wrap: break-word;">(none)</td>
<td>String</td>
- <td>Pass-through Debezium's properties to Debezium Embedded Engine which is used to capture data changes from SQLServer.
- For example: <code>'debezium.snapshot.mode' = 'initial_only'</code>.
- See more about the <a href="https://debezium.io/documentation/reference/1.9/connectors/sqlserver.html#sqlserver-required-connector-configuration-properties">Debezium's SQLServer Connector properties</a></td>
+ <td>将 Debezium 的属性传递给 Debezium 嵌入式引擎,该引擎用于从 SQLServer 捕获数据更改。
+ 例如: <code>'debezium.snapshot.mode' = 'initial_only'</code>.
+ 查看更多关于 <a href="https://debezium.io/documentation/reference/1.9/connectors/sqlserver.html#sqlserver-required-connector-configuration-properties">Debezium 的 SQLServer 连接器属性</a></td>
</tr>
<tr>
<td>scan.incremental.close-idle-reader.enabled</td>
<td>optional</td>
<td style="word-wrap: break-word;">false</td>
<td>Boolean</td>
- <td>Whether to close idle readers at the end of the snapshot phase. <br>
- 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.<br>
- 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'
+ <td>是否在快照阶段结束后关闭空闲的 Reader。 <br>
+ 当 'execution.checkpointing.checkpoints-after-tasks-finish.enabled' 设置为 true 时,要求 flink 版本大于等于 1.14。<br>
+ 如果 flink 版本大于等于 1.15,'execution.checkpointing.checkpoints-after-tasks-finish.enabled' 的默认值已变更为 true,
+ 因此不需要显式配置 'execution.checkpointing.checkpoints-after-tasks-finish.enabled' = 'true'
</td>
</tr>
<tr>
@@ -242,10 +242,10 @@ Connector Options
<td>optional</td>
<td style="word-wrap: break-word;">(none)</td>
<td>String</td>
- <td>The chunk key of table snapshot, captured tables are split into multiple chunks by a chunk key when read the snapshot of table.
- By default, the chunk key is the first column of the primary key. A column that is not part of the primary key can be used as a chunk key, but this may lead to slower query performance.
+ <td>表快照的分片键,在读取表的快照时,被捕获的表会按分片键拆分为多个分片。
+ 默认情况下,分片键是主键的第一列。可以使用非主键列作为分片键,但这可能会导致查询性能下降。
<br>
- <b>Warning:</b> Using a non-primary key column as a chunk key may lead to data inconsistencies. Please see <a href="#warning">Warning</a> for details.
+ <b>警告:</b> 使用非主键列作为分片键可能会导致数据不一致。请参阅 <a href="#警告">警告</a> 了解详细信息。
</td>
</tr>
<tr>
@@ -254,8 +254,8 @@ Connector Options
<td style="word-wrap: break-word;">true</td>
<td>Boolean</td>
<td>
- Whether to assign the unbounded chunks first during snapshot reading phase.<br>
- This might help reduce the risk of the TaskManager experiencing an out-of-memory (OOM) error when taking a snapshot of the largest unbounded chunk.<br>
+ 快照读取阶段是否先分配 UnboundedChunk。<br>
+ 这可能有助于降低 TaskManager 在对最大的 UnboundedChunk 执行快照时出现内存溢出 (OOM) 错误的风险。<br>
</td>
</tr>
<tr>
@@ -264,20 +264,20 @@ Connector Options
<td style="word-wrap: break-word;">false</td>
<td>Boolean</td>
<td>
- Whether to skip backfill in snapshot reading phase.<br>
- If backfill is skipped, changes on captured tables during snapshot phase will be consumed later in change log reading phase instead of being merged into the snapshot.<br>
- WARNING: Skipping backfill might lead to data inconsistency because some change log events happened within the snapshot phase might be replayed (only at-least-once semantic is promised).
- For example updating an already updated value in snapshot, or deleting an already deleted entry in snapshot. These replayed change log events should be handled specially.
+ 是否在快照读取阶段跳过 backfill 。<br>
+ 如果跳过 backfill ,快照阶段捕获表的更改将在稍后的 change log 读取阶段被回放,而不是合并到快照中。<br>
+ 警告:跳过 backfill 可能会导致数据不一致,因为快照阶段发生的某些 change log 事件可能会被重放(仅保证 at-least-once )。
+ 例如,更新快照阶段已更新的值,或删除快照阶段已删除的数据。这些重放的 change log 事件应进行特殊处理。
</td>
</tr>
</tbody>
</table>
</div>
-Available Metadata
+可用的元数据
----------------
-The following format metadata can be exposed as read-only (VIRTUAL) columns in a table definition.
+下表中的元数据可以在 DDL 中作为只读(虚拟)meta 列声明。
<table class="colwidths-auto docutils">
<thead>
@@ -291,34 +291,34 @@ The following format metadata can be exposed as read-only (VIRTUAL) columns in a
<tr>
<td>table_name</td>
<td>STRING NOT NULL</td>
- <td>Name of the table that contain the row.</td>
+ <td>当前记录所属的表名称。</td>
</tr>
<tr>
<td>schema_name</td>
<td>STRING NOT NULL</td>
- <td>Name of the schema that contain the row.</td>
+ <td>当前记录所属的 schema 名称。</td>
</tr>
<tr>
<td>database_name</td>
<td>STRING NOT NULL</td>
- <td>Name of the database that contain the row.</td>
+ <td>当前记录所属的库名称。</td>
</tr>
<tr>
<td>op_ts</td>
<td>TIMESTAMP_LTZ(3) NOT NULL</td>
- <td>It indicates the time that the change was made in the database. <br>If the record is read from snapshot of the table instead of the change stream, the value is always 0.</td>
+ <td>当前记录表在数据库中更新的时间。 <br>如果从表的快照而不是更改流读取记录,该值将始终为0。</td>
</tr>
</tbody>
</table>
-Limitation
+限制
--------
-### Can't perform checkpoint during scanning snapshot of tables
+### 扫描表快照期间无法执行 checkpoint
*注意:此限制仅在未启用增量快照框架(即 `scan.incremental.snapshot.enabled` 设置为 `false`)时适用。*
-During scanning snapshot of database tables, since there is no recoverable position, we can't perform checkpoints. In order to not perform checkpoints, SqlServer CDC source will keep the checkpoint waiting to timeout. The timeout checkpoint will be recognized as failed checkpoint, by default, this will trigger a failover for the Flink job. So if the database table is large, it is recommended to add following Flink configurations to avoid failover because of the timeout checkpoints:
+在扫描数据库表快照期间,由于没有可恢复的位点,我们无法执行 checkpoint。为了不执行 checkpoint,SqlServer CDC source 会让 checkpoint 一直等待直至超时。超时的 checkpoint 会被视为失败的 checkpoint,默认情况下,这将触发 Flink 作业的故障转移。因此,如果数据库表很大,建议添加以下 Flink 配置,以避免因 checkpoint 超时而触发故障转移:
```
execution.checkpointing.interval: 10min
@@ -327,7 +327,7 @@ restart-strategy: fixed-delay
restart-strategy.fixed-delay.attempts: 2147483647
```
-The extended CREATE TABLE example demonstrates the syntax for exposing these metadata fields:
+下述创建表示例展示元数据列的用法:
```sql
CREATE TABLE products (
table_name STRING METADATA FROM 'table_name' VIRTUAL,
@@ -349,29 +349,29 @@ CREATE TABLE products (
);
```
-Features
+特性
--------
-### Exactly-Once Processing
+### Exactly-Once 处理
-The SQLServer CDC connector is a Flink Source connector which will read database snapshot first and then continues to read change events with **exactly-once processing** even failures happen. Please read [How the connector works](https://debezium.io/documentation/reference/1.9/connectors/sqlserver.html#how-the-sqlserver-connector-works).
+SQLServer CDC 连接器是一个 Flink Source 连接器,它将首先读取数据库快照,然后继续读取变更事件,即使在处理时出现故障,也能**准确读取数据**。请参阅 [How the connector works](https://debezium.io/documentation/reference/1.9/connectors/sqlserver.html#how-the-sqlserver-connector-works)。
-### Startup Reading Position
+### 启动模式
-The config option `scan.startup.mode` specifies the startup mode for SQLServer CDC consumer. The valid enumerations are:
+配置选项`scan.startup.mode`指定 SQLServer CDC 使用者的启动模式。有效枚举包括:
-- `initial` (default): Takes a snapshot of structure and data of captured tables; useful if topics should be populated with a complete representation of the data from the captured tables.
-- `latest-offset`: Takes a snapshot of the structure of captured tables only; useful if only changes happening from now onwards should be propagated to topics.
+- `initial` (默认):对捕获表的结构和数据执行快照;适用于需要使用捕获表数据的完整表示来填充主题的场景。
+- `latest-offset`:仅对捕获表的结构执行快照;适用于只需要将从现在开始发生的变更传播到主题的场景。
-_Note: the mechanism of `scan.startup.mode` option relying on Debezium's `snapshot.mode` configuration. So please do not use them together. If you specific both `scan.startup.mode` and `debezium.snapshot.mode` options in the table DDL, it may make `scan.startup.mode` doesn't work._
+_注意:`scan.startup.mode` 选项的机制依赖于 Debezium 的 `snapshot.mode` 配置,因此请不要同时使用它们。如果在表 DDL 中同时指定 `scan.startup.mode` 和 `debezium.snapshot.mode` 选项,可能会导致 `scan.startup.mode` 失效。_
-### Single Thread Reading
+### 单线程读取
-The SQLServer CDC source can't work in parallel reading, because there is only one task can receive change events.
+SQLServer CDC source 无法进行并行读取,因为只有一个任务可以接收变更事件。
### DataStream Source
-The SQLServer CDC connector can also be a DataStream source. You can create a SourceFunction as the following shows:
+SQLServer CDC 连接器也可以是一个数据流源。 你可以创建 SourceFunction,如下所示:
```java
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
@@ -402,7 +402,7 @@ public class SqlServerSourceExample {
}
```
-The SQLServer CDC incremental connector (after 2.4.0) can be used as the following shows:
+SQLServer CDC 增量连接器(2.4.0 之后)可以使用,如下所示:
```java
import org.apache.flink.api.common.eventtime.WatermarkStrategy;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
@@ -443,6 +443,41 @@ public class SqlServerIncrementalSourceExample {
}
```
+### 关于无主键表
+
+从3.4.0 版本开始支持无主键表,使用无主键表必须设置 `scan.incremental.snapshot.chunk.key-column`,且只能选择非空类型的一个字段。
+
+在使用无主键表时,需要注意以下两种情况。
+
+1. 配置 `scan.incremental.snapshot.chunk.key-column` 时,如果表中存在索引,请尽量使用索引中的列来加快 select 速度。
+2. 无主键表的处理语义由 `scan.incremental.snapshot.chunk.key-column` 指定的列的行为决定:
+* 如果指定的列不存在更新操作,此时可以保证 Exactly once 语义。
+* 如果指定的列存在更新操作,此时只能保证 At least once 语义。但可以结合下游,通过指定下游主键,结合幂等性操作来保证数据的正确性。
+
+#### 警告
+
+在 SQLServer 表中,若使用 **非主键列** 作为有主键表的 `scan.incremental.snapshot.chunk.key-column`,可能导致**数据不一致**。以下为可能出现的问题及其缓解方案。
+
+#### 问题场景
+
+- **表结构:**
+ - **主键:** `id`
+ - **分片键列 :** `pid`(非主键)
+
+- **快照分片 :**
+ - **分片 0:** `1 < pid <= 3`
+ - **分片 1:** `3 < pid <= 5`
+
+- **操作 :**
+ - 两个子任务并行读取 **分片 0** 和 **分片 1**。
+ - 在读取过程中,发生了一次 **更新** 操作,使 `id=0` 的 `pid` 从 `2` 变为 `4`,在两个分片的**高低水位**间都包含此次变更,导致该更新操作在增量阶段不会被处理。
+
+- **结果 :**
+ - **分片 0:** 记录 `[id=0, pid=2]`
+ - **分片 1:** 记录 `[id=0, pid=4]`
+
+由于**处理顺序**无法保证,最终 `id=0` 的 `pid` 可能为 `2` 或 `4`,从而导致数据不一致。
+
### 可用的指标
指标系统能够帮助了解分片分发的进展, 下面列举出了支持的 Flink 指标 [Flink metrics](https://nightlies.apache.org/flink/flink-docs-master/docs/ops/metrics/):
@@ -463,43 +498,7 @@ public class SqlServerIncrementalSourceExample {
1. Group 名称是 `namespace.schema.table`,这里的 `namespace` 是实际的数据库名称, `schema` 是实际的 schema 名称, `table` 是实际的表名称。
2. 对于 SQLServer,Group 的名称会类似于 `test_database.test_schema.test_table`。
-### Tables Without primary keys
-
-Starting from version 3.4.0, SQLServer CDC support tables that do not have a primary key. To use a table without primary keys, you must configure the `scan.incremental.snapshot.chunk.key-column` option and specify one non-null field.
-
-There are two places that need to be taken care of.
-
-1. If there is an index in the table, try to use a column which is contained in the index in `scan.incremental.snapshot.chunk.key-column`. This will increase the speed of select statement.
-2. The processing semantics of a SQLServer CDC table without primary keys is determined based on the behavior of the column that are specified by the `scan.incremental.snapshot.chunk.key-column`.
-* If no update operation is performed on the specified column, the exactly-once semantics is ensured.
-* If the update operation is performed on the specified column, only the at-least-once semantics is ensured. However, you can specify primary keys at downstream and perform the idempotence operation to ensure data correctness.
-
-#### Warning
-
-Using a **non-primary key column** as the `scan.incremental.snapshot.chunk.key-column` for a SQLServer table with primary keys may lead to data inconsistencies. Below is a scenario illustrating this issue and recommendations to mitigate potential problems.
-
-#### Problem Scenario
-
-- **Table Structure:**
- - **Primary Key:** `id`
- - **Chunk Key Column:** `pid` (Not a primary key)
-
-- **Snapshot Splits:**
- - **Split 0:** `1 < pid <= 3`
- - **Split 1:** `3 < pid <= 5`
-
-- **Operation:**
- - Two different subtasks are reading Split 0 and Split 1 concurrently.
- - An update operation changes `pid` from `2` to `4` for `id=0` while both splits are being read. This update occurs between the low and high watermark of both splits.
-
-- **Result:**
- - **Split 0:** Contains the record `[id=0, pid=2]`
- - **Split 1:** Contains the record `[id=0, pid=4]`
-
-Since the order of processing these records cannot be guaranteed, the final value of `pid` for `id=0` may end up being either `2` or `4`, leading to potential data inconsistencies.
-
-
-Data Type Mapping
+数据类型映射
----------------
<div class="wy-table-responsive">
diff --git a/docs/content.zh/docs/connectors/flink-sources/tidb-cdc.md b/docs/content.zh/docs/connectors/flink-sources/tidb-cdc.md
index 458a5d4cf..5bb4f4cd0 100644
--- a/docs/content.zh/docs/connectors/flink-sources/tidb-cdc.md
+++ b/docs/content.zh/docs/connectors/flink-sources/tidb-cdc.md
@@ -24,14 +24,14 @@ specific language governing permissions and limitations
under the License.
-->
-# TiDB CDC Connector
+# TiDB CDC 连接器
-The TiDB CDC connector allows for reading snapshot data and incremental data from TiDB database. This document describes how to setup the TiDB CDC connector to run SQL queries against TiDB databases.
+TiDB CDC 连接器允许从 TiDB 数据库读取快照数据和增量数据。本文描述了如何设置 TiDB CDC 连接器来对 TiDB 数据库运行 SQL 查询。
-Dependencies
+依赖
------------
-In order to setup the TiDB CDC connector, the following table provides dependency information for both projects using a build automation tool (such as Maven or SBT) and SQL Client with SQL JAR bundles.
+为了设置 TiDB CDC 连接器,下表提供了使用构建自动化工具(如 Maven 或 SBT )和带有 SQL JAR 包的 SQL 客户端的两个项目的依赖关系信息。
### Maven dependency
@@ -39,16 +39,16 @@ In order to setup the TiDB CDC connector, the following table provides dependenc
### SQL Client JAR
-```Download link is available only for stable releases.```
+```下载链接仅适用于稳定版本。```
-Download [flink-sql-connector-tidb-cdc](https://mvnrepository.com/artifact/org.apache.flink/flink-sql-connector-tidb-cdc) and put it under `<FLINK_HOME>/lib/`.
+下载 [flink-sql-connector-tidb-cdc](https://mvnrepository.com/artifact/org.apache.flink/flink-sql-connector-tidb-cdc) 到 `<FLINK_HOME>/lib/` 目录下。
-**Note:** Refer to [flink-sql-connector-tidb-cdc](https://mvnrepository.com/artifact/org.apache.flink/flink-sql-connector-tidb-cdc), more released versions will be available in the Maven central warehouse.
+**注意:** 参考 [flink-sql-connector-tidb-cdc](https://mvnrepository.com/artifact/org.apache.flink/flink-sql-connector-tidb-cdc) 当前已发布的所有版本都可以在 Maven 中央仓库获取。
-How to create a TiDB CDC table
+如何创建 TiDB CDC 表
----------------
-The TiDB CDC table can be defined as following:
+TiDB CDC 表可以定义如下:
```sql
-- checkpoint every 3000 milliseconds
@@ -75,7 +75,7 @@ Flink SQL> CREATE TABLE orders (
Flink SQL> SELECT * FROM orders;
```
-Connector Options
+连接器配置项
----------------
<div class="highlight">
@@ -95,79 +95,79 @@ Connector Options
<td>required</td>
<td style="word-wrap: break-word;">(none)</td>
<td>String</td>
- <td>Specify what connector to use, here should be <code>'tidb-cdc'</code>.</td>
+ <td>指定要使用的连接器, 这里应该是 <code>'tidb-cdc'</code>.</td>
</tr>
<tr>
<td>database-name</td>
<td>required</td>
<td style="word-wrap: break-word;">(none)</td>
<td>String</td>
- <td>Database name of the TiDB server to monitor.</td>
- </tr>
+ <td>要监视的 TiDB 服务器的数据库名称。</td>
+ </tr>
<tr>
<td>table-name</td>
<td>required</td>
<td style="word-wrap: break-word;">(none)</td>
<td>String</td>
- <td>Table name of the TiDB database to monitor.</td>
+ <td>需要监视的 TiDB 数据库的表名。</td>
</tr>
<tr>
<td>scan.startup.mode</td>
<td>optional</td>
<td style="word-wrap: break-word;">initial</td>
<td>String</td>
- <td>Optional startup mode for TiDB CDC consumer, valid enumerations are "initial" and "latest-offset".</td>
+ <td>TiDB CDC 消费者可选的启动模式,合法的模式为 "initial" 和 "latest-offset"。</td>
</tr>
<tr>
<td>pd-addresses</td>
<td>required</td>
<td style="word-wrap: break-word;">(none)</td>
<td>String</td>
- <td>TiKV cluster's PD address.</td>
+ <td>TiKV 集群的 PD 地址。</td>
</tr>
- <tr>
+ <tr>
<td>host-mapping</td>
<td>optional</td>
<td style="word-wrap: break-word;">(none)</td>
<td>String</td>
- <td>TiKV cluster's host-mapping used to configure public IP and intranet IP mapping. When the TiKV cluster is running on the intranet, you can map a set of intranet IPs to public IPs for an outside Flink cluster to access. The format is {Intranet IP1}:{Public IP1};{Intranet IP2}:{Public IP2}, e.g. 192.168.0.2:8.8.8.8;192.168.0.3:9.9.9.9.</td>
+ <td>TiKV 集群的 host-mapping,用于配置公网 IP 和内网 IP 的映射。当 TiKV 集群运行在内网时,你可以将一组内网 IP 映射到公网 IP,以供外部的 Flink 集群访问。格式为 {Intranet IP1}:{Public IP1};{Intranet IP2}:{Public IP2},例如 192.168.0.2:8.8.8.8;192.168.0.3:9.9.9.9。</td>
</tr>
<tr>
<td>tikv.grpc.timeout_in_ms</td>
<td>optional</td>
<td style="word-wrap: break-word;">(none)</td>
<td>Long</td>
- <td>TiKV GRPC timeout in ms.</td>
+ <td>TiKV GRPC 超时时间,单位为毫秒。</td>
</tr>
<tr>
<td>tikv.grpc.scan_timeout_in_ms</td>
<td>optional</td>
<td style="word-wrap: break-word;">(none)</td>
<td>Long</td>
- <td>TiKV GRPC scan timeout in ms.</td>
+ <td>TiKV GRPC 扫描超时时间,单位为毫秒。</td>
</tr>
<tr>
<td>tikv.batch_get_concurrency</td>
<td>optional</td>
<td style="word-wrap: break-word;">20</td>
<td>Integer</td>
- <td>TiKV GRPC batch get concurrency.</td>
+ <td>TiKV GRPC batch get 的并发度。</td>
</tr>
<tr>
<td>tikv.*</td>
<td>optional</td>
<td style="word-wrap: break-word;">(none)</td>
<td>String</td>
- <td>Pass-through TiDB client's properties.</td>
+ <td>透传 TiDB 客户端的属性。</td>
</tr>
</tbody>
</table>
</div>
-Available Metadata
+可用的元数据
----------------
-The following format metadata can be exposed as read-only (VIRTUAL) columns in a table definition.
+下表中的元数据可以在 DDL 中作为只读(虚拟)meta 列声明。
<table class="colwidths-auto docutils">
<thead>
@@ -181,22 +181,22 @@ The following format metadata can be exposed as read-only (VIRTUAL) columns in a
<tr>
<td>table_name</td>
<td>STRING NOT NULL</td>
- <td>Name of the table that contain the row.</td>
+ <td>当前记录所属的表名称。</td>
</tr>
<tr>
<td>database_name</td>
<td>STRING NOT NULL</td>
- <td>Name of the database that contain the row.</td>
+ <td>当前记录所属的库名称。</td>
</tr>
<tr>
<td>op_ts</td>
<td>TIMESTAMP_LTZ(3) NOT NULL</td>
- <td>It indicates the time that the change was made in the database. <br>If the record is read from snapshot of the table instead of the binlog, the value is always 0.</td>
+ <td>当前记录表在数据库中更新的时间。 <br>如果从表的快照而不是 binlog 读取记录,该值将始终为0。</td>
</tr>
</tbody>
</table>
-The extended CREATE TABLE example demonstrates the syntax for exposing these metadata fields:
+下述创建表示例展示元数据列的用法:
```sql
CREATE TABLE products (
db_name STRING METADATA FROM 'database_name' VIRTUAL,
@@ -218,26 +218,26 @@ CREATE TABLE products (
);
```
-Features
+特性
--------
-### Exactly-Once Processing
+### Exactly-Once 处理
-The TiDB CDC connector is a Flink Source connector which will read database snapshot first and then continues to read change events with **exactly-once processing** even failures happen.
+TiDB CDC 连接器是一个 Flink Source 连接器,它将首先读取数据库快照,然后继续读取变更事件,即使在处理时出现故障,也能**准确读取数据**。
-### Startup Reading Position
+### 启动模式
-The config option `scan.startup.mode` specifies the startup mode for TiDB CDC consumer. The valid enumerations are:
+配置选项`scan.startup.mode`指定 TiDB CDC 使用者的启动模式。有效枚举包括:
-- `initial` (default): Takes a snapshot of structure and data of captured tables; useful if you want fetch a complete representation of the data from the captured tables.
-- `latest-offset`: Takes a snapshot of the structure of captured tables only; useful if only changes happening from now onwards should be fetched.
+- `initial` (默认):对捕获表的结构和数据执行快照;适用于需要获取捕获表数据完整表示的场景。
+- `latest-offset`:仅对捕获表的结构执行快照;适用于只需要获取从现在开始发生的变更的场景。
-### Multi Thread Reading
+### 多线程读取
-The TiDB CDC source can work in parallel reading, because there is multiple tasks can receive change events.
+TiDB CDC source 可通过并行读取方式工作,因为有多个任务可以接收变更事件。
### DataStream Source
-The TiDB CDC connector can also be a DataStream source. You can create a SourceFunction as the following shows:
+TiDB CDC 连接器也可以是一个数据流源。 你可以创建 SourceFunction,如下所示:
### DataStream Source
@@ -309,7 +309,7 @@ public class TiDBSourceExample {
}
```
-Data Type Mapping
+数据类型映射
----------------
<div class="wy-table-responsive">
@@ -385,8 +385,8 @@ Data Type Mapping
where 38 < p <= 65<br>
</td>
<td>STRING</td>
- <td>The precision for DECIMAL data type is up to 65 in TiDB, 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.</td>
+ <td>在 TiDB 中,十进制数据类型的精度高达 65,但在 Flink 中,十进制数据类型的精度仅限于 38。
+ 所以,如果定义精度大于 38 的十进制列,则应将其映射到字符串以避免精度损失。</td>
</tr>
<tr>
<td>
@@ -464,7 +464,7 @@ Data Type Mapping
LONGBLOB<br>
</td>
<td>BYTES</td>
- <td>Currently, for BLOB data type in TiDB, only the blob whose length isn't greater than 2,147,483,647(2 ** 31 - 1) is supported. </td>
+ <td>目前,对于 TiDB 中的 BLOB 数据类型,仅支持长度不大于 2,147,483,647(2 ** 31 - 1) 的 blob。</td>
</tr>
<tr>
<td>
@@ -485,15 +485,15 @@ Data Type Mapping
JSON
</td>
<td>STRING</td>
- <td>The JSON data type will be converted into STRING with JSON format in Flink.</td>
+ <td>JSON 数据类型将在 Flink 中转换为 JSON 格式的字符串。</td>
</tr>
<tr>
<td>
SET
</td>
<td>ARRAY<STRING></td>
- <td>As the SET data type in TiDB is a string object that can have zero or more values,
- it should always be mapped to an array of string
+ <td>因为 TiDB 中的 SET 数据类型是一个字符串对象,可以有零个或多个值,
+ 它应该始终映射到字符串数组。
</td>
</tr>
</tbody>
diff --git a/docs/content.zh/docs/connectors/flink-sources/vitess-cdc.md b/docs/content.zh/docs/connectors/flink-sources/vitess-cdc.md
index e3eee7e40..7eb9ca25b 100644
--- a/docs/content.zh/docs/connectors/flink-sources/vitess-cdc.md
+++ b/docs/content.zh/docs/connectors/flink-sources/vitess-cdc.md
@@ -24,15 +24,15 @@ specific language governing permissions and limitations
under the License.
-->
-# Vitess CDC Connector
+# Vitess CDC 连接器
-The Vitess CDC connector allows for reading of incremental data from Vitess cluster. The connector does not support snapshot feature at the moment. This document describes how to setup the Vitess CDC connector to run SQL queries against Vitess databases.
-[Vitess debezium documentation](https://debezium.io/documentation/reference/connectors/vitess.html)
+Vitess CDC 连接器允许从 Vitess 集群读取增量数据。该连接器目前不支持快照功能。本文描述了如何设置 Vitess CDC 连接器来对 Vitess 数据库运行 SQL 查询。
+[Vitess debezium 文档](https://debezium.io/documentation/reference/connectors/vitess.html)
-Dependencies
+依赖
------------
-In order to setup the Vitess CDC connector, the following table provides dependency information for both projects using a build automation tool (such as Maven or SBT) and SQL Client with SQL JAR bundles.
+为了设置 Vitess CDC 连接器,下表提供了使用构建自动化工具(如 Maven 或 SBT )和带有 SQL JAR 包的 SQL 客户端的两个项目的依赖关系信息。
### Maven dependency
@@ -40,28 +40,26 @@ In order to setup the Vitess CDC connector, the following table provides depende
### SQL Client JAR
-Download [flink-sql-connector-vitess-cdc](https://mvnrepository.com/artifact/org.apache.flink/flink-sql-connector-vitess-cdc) and put it under `<FLINK_HOME>/lib/`.
+下载 [flink-sql-connector-vitess-cdc](https://mvnrepository.com/artifact/org.apache.flink/flink-sql-connector-vitess-cdc) 到 `<FLINK_HOME>/lib/` 目录下。
-**Note:** Refer to
-[flink-sql-connector-vitess-cdc](https://mvnrepository.com/artifact/org.apache.flink/flink-sql-connector-vitess-cdc),
-more released versions will be available in the Maven central warehouse.
+**注意:** 参考 [flink-sql-connector-vitess-cdc](https://mvnrepository.com/artifact/org.apache.flink/flink-sql-connector-vitess-cdc) 当前已发布的所有版本都可以在 Maven 中央仓库获取。
-Setup Vitess server
+设置 Vitess 服务器
----------------
-You can follow the Local Install via [Docker guide](https://vitess.io/docs/get-started/vttestserver-docker-image/), or the Vitess Operator for [Kubernetes guide](https://vitess.io/docs/get-started/operator/) to install Vitess. No special setup is needed to support Vitess connector.
+你可以按照 [Docker 指南](https://vitess.io/docs/get-started/vttestserver-docker-image/) 中的本地安装方式,或者按照 [Kubernetes 指南](https://vitess.io/docs/get-started/operator/) 使用 Vitess Operator 来安装 Vitess。支持 Vitess 连接器不需要任何特殊的设置。
-### Checklist
-* Make sure that the VTGate host and its gRPC port (default is 15991) is accessible from the machine where the Vitess connector is installed
+### 检查清单
+* 确保在安装 Vitess 连接器的机器上可以访问 VTGate 主机及其 gRPC 端口(默认为 15991)
-### gRPC authentication
-Because Vitess connector reads change events from the VTGate VStream gRPC server, it does not need to connect directly to MySQL instances.
-Therefore, no special database user and permissions are needed. At the moment, Vitess connector only supports unauthenticated access to the VTGate gRPC server.
+### gRPC 认证
+由于 Vitess 连接器从 VTGate VStream gRPC 服务器读取变更事件,因此它不需要直接连接到 MySQL 实例。
+所以,不需要特殊的数据库用户和权限。目前,Vitess 连接器仅支持以未经认证的方式访问 VTGate gRPC 服务器。
-How to create a Vitess CDC table
+如何创建 Vitess CDC 表
----------------
-The Vitess CDC table can be defined as following:
+Vitess CDC 表可以定义如下:
```sql
-- checkpoint every 3000 milliseconds
@@ -87,7 +85,7 @@ Flink SQL> CREATE TABLE orders (
Flink SQL> SELECT * FROM orders;
```
-Connector Options
+连接器配置项
----------------
@@ -108,123 +106,123 @@ Connector Options
<td>required</td>
<td>(none)</td>
<td>String</td>
- <td>Specify what connector to use, here should be <code>‘vitess-cdc’</code>.</td>
+ <td>指定要使用的连接器,这里应该是 <code>‘vitess-cdc’</code>。</td>
</tr>
<tr>
<td>hostname</td>
<td>required</td>
<td>(none)</td>
<td>String</td>
- <td>IP address or hostname of the Vitess database server (VTGate).</td>
+ <td>Vitess 数据库服务器(VTGate)的 IP 地址或主机名。</td>
</tr>
<tr>
<td>keyspace</td>
<td>required</td>
<td>(none)</td>
<td>String</td>
- <td>The name of the keyspace from which to stream the changes.</td>
+ <td>要从中流式读取变更的 keyspace 的名称。</td>
</tr>
<tr>
<td>username</td>
<td>optional</td>
<td>(none)</td>
<td>String</td>
- <td>An optional username of the Vitess database server (VTGate). If not configured, unauthenticated VTGate gRPC is used.</td>
+ <td>Vitess 数据库服务器(VTGate)的可选用户名。如果未配置,则使用未经认证的 VTGate gRPC。</td>
</tr>
<tr>
<td>password</td>
<td>optional</td>
<td>(none)</td>
<td>String</td>
- <td>An optional password of the Vitess database server (VTGate). If not configured, unauthenticated VTGate gRPC is used.</td>
+ <td>Vitess 数据库服务器(VTGate)的可选密码。如果未配置,则使用未经认证的 VTGate gRPC。</td>
</tr>
<tr>
<td>shard</td>
<td>optional</td>
<td>(none)</td>
<td>String</td>
- <td>An optional name of the shard from which to stream the changes. If not configured, in case of unsharded keyspace, the connector streams changes from the only shard, in case of sharded keyspace, the connector streams changes from all shards in the keyspace.</td>
+ <td>要从中流式读取变更的 shard 的可选名称。如果未配置,对于未分片的 keyspace,连接器会从唯一的 shard 流式读取变更;对于已分片的 keyspace,连接器会从该 keyspace 中的所有 shard 流式读取变更。</td>
</tr>
<tr>
<td>gtid</td>
<td>optional</td>
<td>current</td>
<td>String</td>
- <td>An optional GTID position for a shard to stream from.</td>
+ <td>可选的 GTID 位点,shard 将从该位点开始流式读取。</td>
</tr>
<tr>
<td>stopOnReshard</td>
<td>optional</td>
<td>false</td>
<td>Boolean</td>
- <td>Controls Vitess flag stop_on_reshard.</td>
+ <td>控制 Vitess 标志 stop_on_reshard。</td>
</tr>
<tr>
<td>tombstonesOnDelete</td>
<td>optional</td>
<td>true</td>
<td>Boolean</td>
- <td>Controls whether a delete event is followed by a tombstone event.</td>
+ <td>控制删除事件之后是否跟随 tombstone 事件。</td>
</tr>
<tr>
<td>tombstonesOnDelete</td>
<td>optional</td>
<td>true</td>
<td>Boolean</td>
- <td>Controls whether a delete event is followed by a tombstone event.</td>
+ <td>控制删除事件之后是否跟随 tombstone 事件。</td>
</tr>
<tr>
<td>schemaNameAdjustmentMode</td>
<td>optional</td>
<td>avro</td>
<td>String</td>
- <td>Specifies how schema names should be adjusted for compatibility with the message converter used by the connector.</td>
+ <td>指定应如何调整 schema 名称,以便与连接器所使用的消息转换器兼容。</td>
</tr>
<tr>
<td>table-name</td>
<td>required</td>
<td>(none)</td>
<td>String</td>
- <td>Table name of the MySQL database to monitor.</td>
+ <td>需要监视的 MySQL 数据库的表名。</td>
</tr>
<tr>
<td>tablet.type</td>
<td>optional</td>
<td>RDONLY</td>
<td>String</td>
- <td>The type of Tablet (hence MySQL) from which to stream the changes: MASTER represents streaming from the master MySQL instance REPLICA represents streaming from the replica slave MySQL instance RDONLY represents streaming from the read-only slave MySQL instance.</td>
+ <td>要从中流式读取变更的 Tablet(即 MySQL)的类型:MASTER 表示从主 MySQL 实例流式读取,REPLICA 表示从 replica 从属 MySQL 实例流式读取,RDONLY 表示从只读从属 MySQL 实例流式读取。</td>
</tr>
</tbody>
</table>
</div>
-Features
+特性
--------
-### Incremental Reading
+### 增量读取
-The Vitess connector spends all its time streaming changes from the VTGate’s VStream gRPC service to which it is subscribed. The client receives changes from VStream as they are committed in the underlying MySQL server’s binlog at certain positions, which are referred to as VGTID.
+Vitess 连接器将其全部时间用于从其订阅的 VTGate 的 VStream gRPC 服务中流式读取变更。客户端从 VStream 接收变更,这些变更是在底层 MySQL 服务器的 binlog 中的特定位置提交的,这些位置被称为 VGTID。
-The VGTID in Vitess is the equivalent of GTID in MySQL, it describes the position in the VStream in which a change event happens. Typically, A VGTID has multiple shard GTIDs, each shard GTID is a tuple of (Keyspace, Shard, GTID), which describes the GTID position of a given shard.
+Vitess 中的 VGTID 等价于 MySQL 中的 GTID,它描述了变更事件在 VStream 中发生的位置。通常,一个 VGTID 包含多个 shard GTID,每个 shard GTID 是一个 (Keyspace, Shard, GTID) 三元组,用于描述给定 shard 的 GTID 位点。
-When subscribing to a VStream service, the connector needs to provide a VGTID and a Tablet Type (e.g. MASTER, REPLICA). The VGTID describes the position from which VStream should starts sending change events; the Tablet type describes which underlying MySQL instance (master or replica) in each shard do we read change events from.
+订阅 VStream 服务时,连接器需要提供一个 VGTID 和一个 Tablet 类型(例如 MASTER、REPLICA)。VGTID 描述了 VStream 应从哪个位置开始发送变更事件;Tablet 类型描述了从每个 shard 中的哪个底层 MySQL 实例(master 或 replica)读取变更事件。
-The first time the connector connects to a Vitess cluster, it gets and provides the current VGTID to VStream.
+连接器第一次连接到 Vitess 集群时,会获取当前的 VGTID 并将其提供给 VStream。
-The Debezium Vitess connector acts as a gRPC client of VStream. When the connector receives changes it transforms the events into Debezium create, update, or delete events that include the VGTID of the event. The Vitess connector forwards these change events in records to the Kafka Connect framework, which is running in the same process. The Kafka Connect process asynchronously writes the change event records in the same order in which they were generated to the appropriate Kafka topic.
+Debezium Vitess 连接器充当 VStream 的 gRPC 客户端。当连接器接收到变更时,会将这些事件转换为 Debezium 的 create、update 或 delete 事件,其中包含该事件的 VGTID。Vitess 连接器以记录的形式将这些变更事件转发到运行在同一进程中的 Kafka Connect 框架。Kafka Connect 进程会按照变更事件记录生成时的相同顺序,异步地将它们写入相应的 Kafka topic。
-#### Checkpoint
+#### 全量阶段支持 checkpoint
-Incremental snapshot reading provides the ability to perform checkpoint in chunk level. It resolves the checkpoint timeout problem in previous version with old snapshot reading mechanism.
+增量快照读取提供了在 chunk 级别执行 checkpoint 的能力。它解决了以前版本中使用旧快照读取机制时的 checkpoint 超时问题。
-### Exactly-Once Processing
+### Exactly-Once 处理
-The Vitess CDC connector is a Flink Source connector which will read table snapshot chunks first and then continues to read binlog,
-both snapshot phase and binlog phase, Vitess CDC connector read with **exactly-once processing** even failures happen.
+Vitess CDC 连接器是一个 Flink Source 连接器,它将首先读取表快照分片,然后继续读取 binlog,
+无论是在快照阶段还是读取 binlog 阶段,Vitess CDC 连接器都会在处理时**准确读取数据**,即使任务出现了故障。
### DataStream Source
-The Incremental Reading feature of Vitess CDC Source only exposes in SQL currently, if you're using DataStream, please use Vitess Source:
+Vitess CDC Source 的增量读取特性目前仅在 SQL 中提供,如果你使用的是 DataStream,请使用 Vitess Source:
```java
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
@@ -254,7 +252,7 @@ public class VitessSourceExample {
}
```
-Data Type Mapping
+数据类型映射
----------------
<div class="wy-table-responsive">