Informix 连接器
Debezium 的 Informix 连接器可以捕获 Informix 数据库表中行级别的更改。有关此连接器兼容的 Informix 数据库版本的信息,请参阅 Debezium 版本概述。
此连接器在很大程度上受到了 Debezium IBM Db2 实现的启发,但它使用 Informix Change Streams API for Java 来捕获事务性数据。Change Data Capture API 从已启用完全行日志记录的数据库捕获数据,并从当前的逻辑日志捕获事务。该 API 按顺序处理所有事务。
Debezium Informix 连接器首次连接到 Informix 数据库时,它会读取已配置为捕获更改的表的一致快照。默认情况下,连接器捕获所有非系统表的更改。要自定义快照行为,您可以设置配置属性来指定要包含或排除在快照中的表。
快照完成后,连接器将开始为已设置为捕获模式的表所提交的更新发出更改事件。默认情况下,特定表的更改事件会发送到与表同名的 Kafka 主题。应用程序和服务随后可以从这些主题中消费更改事件记录。
|
该连接器需要使用 Informix Change Streams API for Java,该 API 作为 Informix JDBC 安装的一部分打包,并且与最新的 JDBC 驱动程序一起在 Maven Central 上提供。 |
Informix 连接器已在 Linux 上的 Informix 中进行了测试。预计该连接器在 Windows 等其他平台上也能正常工作,如果您能确认这一点,我们将非常乐意收到您的反馈。
概述
Debezium Informix 连接器基于 Informix Change Data Capture API,该 API 启用了 Informix 中的变更数据捕获。
数据库管理员必须准备数据库和数据库服务器以使用 Change Data Capture API。请参阅 准备使用 Change Data Capture API。
在将表设置为捕获模式后,连接器可以读取每个表更新的变更流记录并从中生成更改事件。连接器为每个行级别的插入、更新和删除操作发出一个更改事件记录。默认情况下,更改事件记录会发送到与源表同名的 Kafka 主题。可选地,您可以自定义目标主题的名称。客户端应用程序读取与感兴趣的数据库表对应的 Kafka 主题,并可以对每个行级别的更改事件做出响应。
通常,数据库管理员会在表的生命周期中途将表设置为捕获模式。这意味着连接器没有表中所有更改的完整历史记录。因此,当 Informix 连接器首次连接到某个 Informix 数据库时,它将从对处于捕获模式的每个表执行一致性快照开始。在连接器完成快照后,它将从快照创建的时间点开始流式传输更改事件。这样,连接器就可以从捕获模式的表中获得一致的视图,并且不会丢失在执行快照期间所做的任何更改。
Debezium 连接器具有容错能力。当连接器读取和生成更改事件时,它会记录变更流记录的日志序列号 (LSN)。LSN 是数据库日志中更改事件的位置。如果连接器因任何原因停止,包括通信故障、网络问题或崩溃,在重新启动时,它将从上次中断的地方继续读取变更流。此行为也适用于快照。也就是说,如果快照在连接器停止时未完成,则在重新启动后,连接器将开始新的快照。
连接器的工作原理
为了最佳地配置和运行 Debezium Informix 连接器,了解连接器如何执行快照、流式传输更改事件、确定 Kafka 主题名称以及处理模式更改会很有帮助。
快照
Informix 复制功能并非旨在存储数据库更改的完整历史记录。因此,Debezium Informix 连接器无法从日志中检索数据库的完整历史记录。为了让连接器建立数据库当前状态的基线,第一次启动连接器时,它会执行对处于捕获模式的表的初始一致性快照。对于快照捕获的每个更改,连接器会将一个 read 事件发送到捕获表的 Kafka 主题。
以下工作流程列出了 Debezium 创建快照的步骤。这些步骤描述了当 snapshot.mode 配置属性设置为其默认值 initial 时的快照过程。您可以通过更改 snapshot.mode 属性的值来自定义连接器创建快照的方式。如果您配置了不同的快照模式,连接器将使用修改后的工作流程来完成快照。
-
Establish a connection to the database. (建立数据库连接。)
-
确定哪些表处于捕获模式并应包含在快照中。默认情况下,连接器捕获所有非系统表的数据。快照完成后,连接器将继续流式传输指定表的 数据。如果您希望连接器仅从特定表捕获数据,您可以配置连接器通过设置
table.include.list或table.exclude.list等属性来捕获表或表元素的子集的数据。 -
获取处于捕获模式的所有表的锁。此锁可确保在快照完成之前,这些表中不会发生任何模式更改。锁的级别由
snapshot.isolation.mode连接器配置属性的值决定。 -
读取服务器事务日志中的最高 (最近) LSN 位置。
-
捕获所有表或所有标记为捕获的表的模式。连接器将模式信息持久化到其内部数据库模式历史主题。模式历史记录提供了有关在发生更改事件时生效的结构的有关信息。
默认情况下,连接器捕获数据库中处于捕获模式的每个表的模式,包括未配置为捕获的表。如果表未配置为捕获,初始 snapshot 只捕获它们的结构;它不捕获任何表数据。
For more information about why snapshots persist schema information for tables that you did not include in the initial snapshot, see Understanding why initial snapshots capture the schema for all tables. (有关为什么快照会为未包含在初始快照中的表保留模式信息的信息,请参阅了解为什么初始快照会捕获所有表的模式历史记录。)
-
释放步骤 3 中获得的任何锁。其他数据库客户端现在可以写入任何先前锁定的表。
-
在步骤 4 读取的 LSN 位置,连接器会扫描指定的表。在扫描过程中,连接器将执行以下任务:
-
Confirms that the table was created before the snapshot began. If the table was created after the snapshot began, the connector skips the table. After the snapshot is complete, and the connector transitions to streaming, it emits change events for any tables that were created after the snapshot began. (确认表在快照开始之前已创建。如果表在快照开始之后创建,连接器将跳过该表。快照完成后,连接器过渡到流式传输,它会为快照开始后创建的任何表发出变更事件。)
-
为从表中捕获的每一行生成一个
read事件。所有read事件都具有相同的 LSN 位置,该位置是步骤 4 中获取的 LSN 位置。 -
Emits each
readevent to the Kafka topic for the source table. (将每个read事件发送到源表的 Kafka 主题。) -
Releases data table locks, if applicable. (释放数据表锁(如果适用)。)
-
-
Record the successful completion of the snapshot in the connector offsets. (在连接器偏移量中记录快照的成功完成。)
The resulting initial snapshot captures the current state of each row in the captured tables. From this baseline state, the connector captures subsequent changes as they occur. (生成的初始快照捕获了捕获表中每一行的当前状态。从这个基线状态开始,连接器会捕获后续发生的更改。)
After the snapshot process begins, if the process is interrupted due to connector failure, rebalancing, or other reasons, the process restarts after the connector restarts. (在快照过程开始后,如果由于连接器故障、重新平衡或其他原因导致过程中断,该过程将在连接器重新启动后重新启动。)
连接器完成后期 snapshot,它将从步骤 4 中读取的位置继续流式传输,以确保不遗漏任何更新。
If the connector stops again for any reason, after it restarts, it resumes streaming changes from where it previously left off. (如果连接器因任何原因再次停止,则在重新启动后,它将从之前停止的地方继续流式传输更改。)
| Setting (设置) | 描述 |
|---|---|
|
连接器在每次启动时执行 snapshot。snapshot 完成后,连接器开始流式传输后续数据库更改的事件记录。 |
|
连接器执行数据库快照,如 执行初始快照的默认工作流 中所述。快照完成后,连接器将开始流式传输后续数据库更改的事件记录。 |
|
The connector performs a database snapshot. After the snapshot completes, the connector stops, and does not stream event records for subsequent database changes. (连接器执行数据库快照。快照完成后,连接器停止,并且不为后续数据库更改流式传输事件记录。) |
|
Deprecated, see |
|
连接器捕获所有相关表的结构,并执行 默认快照工作流程 中描述的所有步骤,但它不创建 |
|
Set this option to restore a database schema history topic that is lost or corrupted. After a restart, the connector runs a snapshot that rebuilds the topic from the source tables. You can also set the property to periodically prune a database schema history topic that experiences unexpected growth. (将此选项设置为恢复已丢失或损坏的数据库模式历史主题。重新启动后,连接器将运行一个快照,从源表重建该主题。您还可以将此属性设置为定期修剪经历意外增长的数据库模式历史主题。) + 警告:如果模式更改在上次连接器关闭后已提交到数据库,请勿使用此模式执行快照。 |
|
在连接器启动后,仅当它检测到以下任一情况时,它才会执行快照:* 它无法检测到任何主题偏移量。* 先前记录的偏移量指定了一个服务器上不存在的日志位置。 |
|
Set the snapshot mode to |
|
|
了解为什么初始快照会捕获所有表的模式历史记录
The initial snapshot that a connector runs captures two types of information (连接器运行的初始快照捕获两种类型的信息:)
- Table data (表数据)
-
有关连接器
table.include.list属性中命名的表的INSERT、UPDATE和DELETE操作的信息。 - Schema data (模式数据)
-
DDL statements that describe the structural changes that are applied to tables. Schema data is persisted to both the internal schema history topic, and to the connector’s schema change topic, if one is configured. (描述应用于表的结构化更改的 DDL 语句。模式数据将持久化到内部模式历史主题,以及连接器的模式变更主题(如果已配置)。)
After you run an initial snapshot, you might notice that the snapshot captures schema information for tables that are not designated for capture. By default, initial snapshots are designed to capture schema information for every table that is present in the database, not only from tables that are designated for capture. Connectors require that the table’s schema is present in the schema history topic before they can capture a table. By enabling the initial snapshot to capture schema data for tables that are not part of the original capture set, Debezium prepares the connector to readily capture event data from these tables should that later become necessary. If the initial snapshot does not capture a table’s schema, you must add the schema to the history topic before the connector can capture data from the table. (运行初始快照后,您可能会注意到快照捕获了未指定捕获的表的模式信息。默认情况下,初始快照旨在捕获数据库中存在的所有表的模式信息,而不仅仅是指定捕获的表。连接器要求表的模式存在于模式历史主题中,然后才能捕获表。通过允许初始快照捕获非原始捕获集一部分的表的模式数据,Debezium 会为连接器做好准备,以便在将来需要时能够轻松地从这些表中捕获事件数据。如果初始快照未捕获表的模式,您必须在连接器能够从表中捕获数据之前将模式添加到历史主题。)
In some cases, you might want to limit schema capture in the initial snapshot. This can be useful when you want to reduce the time required to complete a snapshot. Or when Debezium connects to the database instance through a user account that has access to multiple logical databases, but you want the connector to capture changes only from tables in a specific logic database. (在某些情况下,您可能希望在初始快照中限制模式捕获。当您想减少完成快照所需的时间时,这可能很有用。或者,当 Debezium 通过具有访问多个逻辑数据库的用户帐户连接到数据库实例时,而您只想让连接器捕获特定逻辑数据库中表的更改。)
-
设置
schema.history.internal.store.only.captured.tables.ddl属性以指定要捕获模式信息的表。 -
设置
schema.history.internal.store.only.captured.databases.ddl属性以指定要捕获模式更改的逻辑数据库。
捕获未被初始快照捕获的表的数据(无模式更改)
In some cases, you might want the connector to capture data from a table whose schema was not captured by the initial snapshot. Depending on the connector configuration, the initial snapshot might capture the table schema only for specific tables in the database. If the table schema is not present in the history topic, the connector fails to capture the table, and reports a missing schema error. (在某些情况下,您可能希望连接器捕获模式未被初始快照捕获的表中的数据。根据连接器配置,初始快照可能仅捕获数据库中特定表的模式。如果表模式不存在于历史主题中,连接器将无法捕获该表,并报告模式丢失错误。)
You might still be able to capture data from the table, but you must perform additional steps to add the table schema. (您仍然可以从该表中捕获数据,但必须执行额外步骤来添加表模式。)
-
You want to capture data from a table with a schema that the connector did not capture during the initial snapshot. (您想从一个连接器在初始快照期间未捕获其模式的表中捕获数据。)
-
在连接器读取的最早和最新的变更表条目 LSN 之间,未对表应用任何模式更改。有关捕获新表的结构化更改数据的详细信息,请参阅 捕获未被初始快照捕获的表的数据(模式更改)。
-
Stop the connector. (停止连接器。)
-
删除由
schema.history.internal.kafka.topic属性指定的内部数据库模式历史主题。 -
Clear the offsets in the configured Kafka Connect
offset.storage.topic. For more information about how to remove offsets, see the Debezium community FAQ. (清除配置的 Kafka Connectoffset.storage.topic中的偏移量。有关如何删除偏移量的更多信息,请参阅Debezium 社区 FAQ。)Removing offsets should be performed only by advanced users who have experience in manipulating internal Kafka Connect data. This operation is potentially destructive, and should be performed only as a last resort. (仅应由有经验处理内部 Kafka Connect 数据的用户执行移除偏移量的操作。此操作可能具有破坏性,应仅作为最后的手段执行。)
-
Apply the following changes to the connector configuration (对连接器配置应用以下更改:)
-
(可选) 将
schema.history.internal.captured.tables.ddl属性的值设置为false。此设置会导致快照捕获所有表的模式,并保证连接器将来可以重建所有表的模式历史。捕获所有表模式的 snapshot 需要更长的时间来完成。
-
将要捕获的表添加到
table.include.list。 -
将
snapshot.mode设置为以下值之一initial (初始)-
当您重新启动连接器时,它将对数据库进行完整 snapshot,捕获表数据和表结构。
如果选择此选项,请考虑将schema.history.internal.captured.tables.ddl属性的值设置为false,以使连接器能够捕获所有表的模式。 schema_only (仅模式)-
当您重新启动连接器时,它将执行一个仅捕获表模式的 snapshot。与完整数据 snapshot 不同,此选项不捕获任何表数据。如果您希望连接器比完整 snapshot 更快地重新启动,可以使用此选项。
-
-
重新启动连接器。连接器将完成由
snapshot.mode指定的 snapshot 类型。 -
(可选) 如果连接器执行了
schema_only快照,则在快照完成后,启动增量快照以捕获您添加的表的 数据。连接器在继续从表中流式传输实时更改的同时运行快照。运行增量快照可捕获以下数据更改-
对于连接器之前已捕获的表,增量 snapshot 会捕获在连接器停机期间发生的更改,即在连接器停止和当前重新启动之间的时间间隔。
-
对于新添加的表,增量 snapshot 会捕获所有现有的表行。
-
捕获未被初始快照捕获的表的数据(模式更改)
If a schema change is applied to a table, records that are committed before the schema change have different structures than those that were committed after the change. When Debezium captures data from a table, it reads the schema history to ensure that it applies the correct schema to each event. If the schema is not present in the schema history topic, the connector is unable to capture the table, and an error results. (如果模式更改应用于某个表,则在模式更改之前提交的记录与更改之后提交的记录具有不同的结构。当 Debezium 从表中捕获数据时,它会读取模式历史记录以确保它将正确的模式应用于每个事件。如果模式不存在于模式历史主题中,连接器将无法捕获该表,并导致错误。)
If you want to capture data from a table that was not captured by the initial snapshot, and the schema of the table was modified, you must add the schema to the history topic, if it is not already available. You can add the schema by running a new schema snapshot, or by running an initial snapshot for the table. (如果您想从初始快照未捕获的表中捕获数据,并且该表的模式已修改,则必须将模式添加到历史主题(如果尚未提供)。您可以通过运行新的模式快照或为该表运行初始快照来添加模式。)
-
You want to capture data from a table with a schema that the connector did not capture during the initial snapshot. (您想从一个连接器在初始快照期间未捕获其模式的表中捕获数据。)
-
A schema change was applied to the table so that the records to be captured do not have a uniform structure. (已对表应用了模式更改,以便要捕获的记录没有统一的结构。)
- Initial snapshot captured the schema for all tables (
store.only.captured.tables.ddlwas set tofalse) (初始快照捕获了所有表的模式(store.only.captured.tables.ddl设置为false)) -
-
编辑
table.include.list属性以指定要捕获的表。 -
Restart the connector. (重新启动连接器。)
-
如果想捕获新表中已有的数据,请启动增量快照。
-
- Initial snapshot did not capture the schema for all tables (
store.only.captured.tables.ddlwas set totrue) (初始快照未捕获所有表的模式(store.only.captured.tables.ddl设置为true)) -
If the initial snapshot did not save the schema of the table that you want to capture, complete one of the following procedures (如果初始快照未保存您要捕获的表的模式,请完成以下任一程序:)
- Procedure 1: Schema snapshot, followed by incremental snapshot (过程 1:模式快照,然后是增量快照)
-
In this procedure, the connector first performs a schema snapshot. You can then initiate an incremental snapshot to enable the connector to synchronize data. (在此过程中,连接器首先执行模式快照。然后,您可以启动增量快照以使连接器能够同步数据。)
-
Stop the connector. (停止连接器。)
-
删除由
schema.history.internal.kafka.topic属性指定的内部数据库模式历史主题。 -
Clear the offsets in the configured Kafka Connect
offset.storage.topic. For more information about how to remove offsets, see the Debezium community FAQ. (清除配置的 Kafka Connectoffset.storage.topic中的偏移量。有关如何删除偏移量的更多信息,请参阅Debezium 社区 FAQ。)Removing offsets should be performed only by advanced users who have experience in manipulating internal Kafka Connect data. This operation is potentially destructive, and should be performed only as a last resort. (仅应由有经验处理内部 Kafka Connect 数据的用户执行移除偏移量的操作。此操作可能具有破坏性,应仅作为最后的手段执行。)
-
Set values for properties in the connector configuration as described in the following steps (按以下步骤为连接器配置中的属性设置值:)
-
将
snapshot.mode属性的值设置为schema_only。 -
编辑
table.include.list以添加您要捕获的表。
-
-
Restart the connector. (重新启动连接器。)
-
Wait for Debezium to capture the schema of the new and existing tables. Data changes that occurred any tables after the connector stopped are not captured. (等待 Debezium 捕获新表和现有表的模式。连接器停止后在任何表上发生的数据更改都不会被捕获。)
-
为确保不丢失任何数据,请启动增量快照。
-
- Procedure 2: Initial snapshot, followed by optional incremental snapshot (过程 2:初始快照,然后是可选的增量快照)
-
In this procedure the connector performs a full initial snapshot of the database. As with any initial snapshot, in a database with many large tables, running an initial snapshot can be a time-consuming operation. After the snapshot completes, you can optionally trigger an incremental snapshot to capture any changes that occur while the connector is off-line. (在此过程中,连接器将执行数据库的完整初始快照。与任何初始快照一样,在具有许多大表的数据库中,运行初始快照可能是一项耗时的操作。快照完成后,您可以选择触发增量快照以捕获连接器离线期间发生的任何更改。)
-
Stop the connector. (停止连接器。)
-
删除由
schema.history.internal.kafka.topic属性指定的内部数据库模式历史主题。 -
Clear the offsets in the configured Kafka Connect
offset.storage.topic. For more information about how to remove offsets, see the Debezium community FAQ. (清除配置的 Kafka Connectoffset.storage.topic中的偏移量。有关如何删除偏移量的更多信息,请参阅Debezium 社区 FAQ。)Removing offsets should be performed only by advanced users who have experience in manipulating internal Kafka Connect data. This operation is potentially destructive, and should be performed only as a last resort. (仅应由有经验处理内部 Kafka Connect 数据的用户执行移除偏移量的操作。此操作可能具有破坏性,应仅作为最后的手段执行。)
-
编辑
table.include.list以添加您要捕获的表。 -
Set values for properties in the connector configuration as described in the following steps (按以下步骤为连接器配置中的属性设置值:)
-
将
snapshot.mode属性的值设置为initial。 -
(可选) 设置
schema.history.internal.store.only.captured.tables.ddl为false。
-
-
Restart the connector. The connector takes a full database snapshot. After the snapshot completes, the connector transitions to streaming. (重新启动连接器。连接器将进行完整的数据库快照。快照完成后,连接器将过渡到流式传输。)
-
(可选) 要捕获连接器离线期间发生的任何数据更改,请启动增量快照。
-
临时快照
By default, a connector runs an initial snapshot operation only after it starts for the first time. Following this initial snapshot, under normal circumstances, the connector does not repeat the snapshot process. Any future change event data that the connector captures comes in through the streaming process only. (默认情况下,连接器仅在首次启动后运行初始快照操作。在初始快照之后,在正常情况下,连接器不会重复快照过程。连接器捕获的任何未来变更事件数据仅通过流式传输过程进入。)
However, in some situations the data that the connector obtained during the initial snapshot might become stale, lost, or incomplete. To provide a mechanism for recapturing table data, Debezium includes an option to perform ad hoc snapshots. You might want to perform an ad hoc snapshot after any of the following changes occur in your Debezium environment (但是,在某些情况下,连接器在初始快照期间获取的数据可能会过时、丢失或不完整。为了提供重新捕获表数据的机制,Debezium 提供了一个执行即席快照的选项。您可能希望在 Debezium 环境中发生以下任何更改后执行即席快照:)
-
The connector configuration is modified to capture a different set of tables. (修改了连接器配置以捕获不同的表集。)
-
Kafka topics are deleted and must be rebuilt. (Kafka 主题被删除且必须重建。)
-
Data corruption occurs due to a configuration error or some other problem. (由于配置错误或其他问题导致数据损坏。)
You can re-run a snapshot for a table for which you previously captured a snapshot by initiating a so-called ad hoc snapshot. Ad hoc snapshots require the use of signaling tables. You initiate an ad hoc snapshot by sending a signal request to the Debezium signaling table. (您可以通过启动所谓的即席快照来重新运行之前捕获了快照的表的快照。即席快照需要使用信号表。通过向 Debezium 信号表发送信号请求来启动即席快照。)
When you initiate an ad hoc snapshot of an existing table, the connector appends content to the topic that already exists for the table. If a previously existing topic was removed, Debezium can create a topic automatically if automatic topic creation is enabled. (当您启动现有表的即席快照时,连接器会将内容追加到该表已存在的主题中。如果之前存在的主题已被删除,并且启用了自动主题创建,则 Debezium 可以自动创建主题。)
Ad hoc snapshot signals specify the tables to include in the snapshot. The snapshot can capture the entire contents of the database, or capture only a subset of the tables in the database. Also, the snapshot can capture a subset of the contents of the table(s) in the database. (即席快照信号指定要包含在快照中的表。快照可以捕获数据库的全部内容,或仅捕获数据库中表的部分内容。此外,快照还可以捕获数据库中表的部分内容。)
You specify the tables to capture by sending an execute-snapshot message to the signaling table. Set the type of the execute-snapshot signal to incremental or blocking, and provide the names of the tables to include in the snapshot, as described in the following table (您可以通过向信号表发送 execute-snapshot 消息来指定要捕获的表。将 execute-snapshot 信号的类型设置为 incremental 或 blocking,并提供要在快照中包含的表名称,如下表所示:)
| Field (字段) | Default (默认值) | Value (值) |
|---|---|---|
|
|
Specifies the type of snapshot that you want to run. (指定您要运行的快照类型。) |
|
N/A |
An array that contains regular expressions matching the fully-qualified names of the tables to include in the snapshot. (一个包含正则表达式的数组,匹配要包含在快照中的表的完全限定名称。) |
|
N/A |
An optional array that specifies a set of additional conditions that the connector evaluates to determine the subset of records to include in a snapshot. (一个可选数组,指定连接器用于确定要包含在快照中的记录子集的附加条件集。)
|
|
N/A |
An optional string that specifies the column name that the connector uses as the primary key of a table during the snapshot process. (一个可选字符串,指定连接器在快照过程中用作表主键的列名。) |
您可以通过向信号表添加一个带有 execute-snapshot 信号类型的条目,或者通过向 Kafka 信号主题发送信号消息来启动临时增量快照。在连接器处理完消息后,它将开始快照操作。快照过程读取第一个和最后一个主键值,并将这些值用作每个表的起始点和结束点。根据表中的条目数量和配置的块大小,Debezium 将表分成块,并按顺序逐个快照每个块。
有关更多信息,请参阅 增量快照。
You initiate an ad hoc blocking snapshot by adding an entry with the execute-snapshot signal type to the signaling table or signaling topic. After the connector processes the message, it begins the snapshot operation. The connector temporarily stops streaming, and then initiates a snapshot of the specified table, following the same process that it uses during an initial snapshot. After the snapshot completes, the connector resumes streaming. (您可以通过向信号表或信号主题添加具有 execute-snapshot 信号类型的条目来启动即席阻塞快照。在连接器处理消息后,它将开始快照操作。连接器将暂时停止流式传输,然后启动指定表的快照,遵循其在初始快照期间使用的相同过程。快照完成后,连接器将恢复流式传输。)
有关更多信息,请参阅 阻塞快照。
增量快照
To provide flexibility in managing snapshots, Debezium includes a supplementary snapshot mechanism, known as incremental snapshotting. Incremental snapshots rely on the Debezium mechanism for sending signals to a Debezium connector. Incremental snapshots are based on the DDD-3 design document. (为了在管理快照时提供灵活性,Debezium 提供了一个补充快照机制,称为增量快照。增量快照依赖于 Debezium 向 Debezium 连接器发送信号的机制。增量快照基于DDD-3 设计文档。)
在增量快照中,Debezium 不是一次性捕获数据库的完整状态,而是在一系列可配置的块中分阶段捕获每个表。您可以指定快照要捕获的表以及每个块的大小。块大小决定了快照在每次从数据库提取数据时收集的行数。增量快照的默认块大小为 1024 行。
As an incremental snapshot proceeds, Debezium uses watermarks to track its progress, maintaining a record of each table row that it captures. This phased approach to capturing data provides the following advantages over the standard initial snapshot process (随着增量快照的进行,Debezium 使用水位标记来跟踪其进度,并维护捕获的每个表行的记录。与标准的初始快照过程相比,这种分阶段的数据捕获方法提供了以下优势:)
-
You can run incremental snapshots in parallel with streamed data capture, instead of postponing streaming until the snapshot completes. The connector continues to capture near real-time events from the change log throughout the snapshot process, and neither operation blocks the other. (您可以与流式数据捕获并行运行增量快照,而不是将流式传输推迟到快照完成。在整个快照过程中,连接器会继续从变更日志中捕获近乎实时事件,并且任一操作都不会阻塞另一个操作。)
-
If the progress of an incremental snapshot is interrupted, you can resume it without losing any data. After the process resumes, the snapshot begins at the point where it stopped, rather than recapturing the table from the beginning. (如果增量快照的进度被中断,您可以恢复它而不会丢失任何数据。在过程恢复后,快照将从停止的点开始,而不是从头重新捕获表。)
-
您可以随时按需运行增量快照,并根据需要重复该过程以适应数据库更新。例如,在修改连接器配置以在
table.include.list属性中添加表后,您可能会重新运行快照。
运行增量快照时,Debezium 按主键对每个表进行排序,然后根据配置的块大小将表分成块。逐块工作,然后捕获块中的每一行。对于它捕获的每一行,快照都会发出一个 READ 事件。该事件代表块开始时行的值。
As a snapshot proceeds, it’s likely that other processes continue to access the database, potentially modifying table records. To reflect such changes, INSERT, UPDATE, or DELETE operations are committed to the transaction log as per usual. Similarly, the ongoing Debezium streaming process continues to detect these change events and emits corresponding change event records to Kafka. (随着快照的进行,其他进程很可能会继续访问数据库,可能修改表记录。为了反映这些更改,INSERT、UPDATE 或 DELETE 操作照常提交到事务日志。同样,正在进行的 Debezium 流式传输过程会继续检测这些变更事件,并将相应的变更事件记录发送到 Kafka。)
In some cases, the UPDATE or DELETE events that the streaming process emits are received out of sequence. That is, the streaming process might emit an event that modifies a table row before the snapshot captures the chunk that contains the READ event for that row. When the snapshot eventually emits the corresponding READ event for the row, its value is already superseded. To ensure that incremental snapshot events that arrive out of sequence are processed in the correct logical order, Debezium employs a buffering scheme for resolving collisions. Only after collisions between the snapshot events and the streamed events are resolved does Debezium emit an event record to Kafka. (在某些情况下,流式传输过程发出的 UPDATE 或 DELETE 事件可能会乱序接收。也就是说,流式传输过程可能会在快照捕获包含该行 READ 事件的块之前发出修改表行的事件。当快照最终发出行的相应 READ 事件时,其值已过时。为了确保乱序到达的增量快照事件按正确的逻辑顺序处理,Debezium 采用缓冲方案来解决冲突。仅当快照事件与流式事件之间的冲突得到解决后,Debezium 才会向 Kafka 发送事件记录。)
To assist in resolving collisions between late-arriving READ events and streamed events that modify the same table row, Debezium employs a so-called snapshot window. The snapshot window demarcates the interval during which an incremental snapshot captures data for a specified table chunk. Before the snapshot window for a chunk opens, Debezium follows its usual behavior and emits events from the transaction log directly downstream to the target Kafka topic. But from the moment that the snapshot for a particular chunk opens, until it closes, Debezium performs a de-duplication step to resolve collisions between events that have the same primary key. (为了帮助解决延迟到达的 READ 事件与修改同一表行的流式事件之间的冲突,Debezium 采用所谓的快照窗口。快照窗口划定了增量快照捕获指定表块数据的间隔。在某个块的快照窗口打开之前,Debezium 会遵循其常规行为,将事务日志中的事件直接向下游发送到目标 Kafka 主题。但在某个块的快照打开到关闭的整个过程中,Debezium 会执行去重步骤以解决具有相同主键的事件之间的冲突。)
For each data collection, the Debezium emits two types of events, and stores the records for them both in a single destination Kafka topic. The snapshot records that it captures directly from a table are emitted as READ operations. Meanwhile, as users continue to update records in the data collection, and the transaction log is updated to reflect each commit, Debezium emits UPDATE or DELETE operations for each change. (对于每个数据集合,Debezium 会发出两种类型的事件,并将两者的记录存储在单个目标 Kafka 主题中。它直接从表中捕获的快照记录作为 READ 操作发出。同时,随着用户继续更新数据集合中的记录,并且事务日志更新以反映每次提交,Debezium 会为每个更改发出 UPDATE 或 DELETE 操作。)
As the snapshot window opens, and Debezium begins processing a snapshot chunk, it delivers snapshot records to a memory buffer. During the snapshot windows, the primary keys of the READ events in the buffer are compared to the primary keys of the incoming streamed events. If no match is found, the streamed event record is sent directly to Kafka. If Debezium detects a match, it discards the buffered READ event, and writes the streamed record to the destination topic, because the streamed event logically supersede the static snapshot event. After the snapshot window for the chunk closes, the buffer contains only READ events for which no related transaction log events exist. Debezium emits these remaining READ events to the table’s Kafka topic. (随着快照窗口的打开,Debezium 开始处理快照块,它会将快照记录传递到内存缓冲区。在快照窗口期间,缓冲区中 READ 事件的主键与传入的流式事件的主键进行比较。如果未找到匹配项,则将流式事件记录直接发送到 Kafka。如果 Debezium 检测到匹配,它将丢弃已缓冲的 READ 事件,并将流式记录写入目标主题,因为流式事件在逻辑上取代了静态快照事件。当块的快照窗口关闭后,缓冲区将仅包含没有相关事务日志事件的 READ 事件。Debezium 将这些剩余的 READ 事件发送到表的 Kafka 主题。)
The connector repeats the process for each snapshot chunk. (连接器对每个快照块重复此过程。)
|
To enable Debezium to perform incremental snapshots, you must grant the connector permission to write to the signaling table. (要使 Debezium 能够执行增量快照,您必须授予连接器写入信号表的权限。) Write permission is unnecessary only for connectors that can be configured to perform read-only incrementals snapshots (MariaDB, MySQL, or PostgreSQL). (仅对于可以配置为执行只读增量快照的连接器(MariaDB、MySQL 或 PostgreSQL)来说,写入权限是可选的。) |
Currently, you can use either of the following methods to initiate an incremental snapshot (当前,您可以使用以下任一方法启动增量快照:)
|
Debezium Informix 连接器不支持在增量快照运行时进行模式更改。 |
触发增量快照
To initiate an incremental snapshot, you can send an ad hoc snapshot signal to the signaling table on the source database. You submit snapshot signals as SQL INSERT queries. (要启动增量快照,您可以将即席快照信号发送到源数据库上的信号表。您将快照信号作为 SQL INSERT 查询提交。)
After Debezium detects the change in the signaling table, it reads the signal, and runs the requested snapshot operation. (在 Debezium 检测到信号表中的更改后,它会读取信号并运行请求的快照操作。)
The query that you submit specifies the tables to include in the snapshot, and, optionally, specifies the type of snapshot operation. Debezium currently supports the incremental and blocking snapshot types. (您提交的查询指定了要包含在快照中的表,并可选地指定了快照操作的类型。Debezium 目前支持 incremental 和 blocking 快照类型。)
To specify the tables to include in the snapshot, provide a data-collections array that lists the tables, or an array of regular expressions used to match tables, for example, (要指定要包含在快照中的表,请提供一个列出表的 data-collections 数组,或者一个用于匹配表的正则表达式数组,例如:)
{"data-collections": ["public.MyFirstTable", "public.MySecondTable"]}
The data-collections array for an incremental snapshot signal has no default value. If the data-collections array is empty, Debezium interprets the empty array to mean that no action is required, and it does not perform a snapshot. (增量快照信号的 data-collections 数组没有默认值。如果 data-collections 数组为空,Debezium 会将空数组解释为无需执行任何操作,并且不会执行快照。)
|
If the name of a table that you want to include in a snapshot contains a dot ( |
-
-
A signaling data collection exists on the source database. (源数据库上存在信号数据集合。)
-
信号数据集合在
signal.data.collection属性中指定。
-
-
Send a SQL query to add the ad hoc incremental snapshot request to the signaling table (发送 SQL 查询将即席增量快照请求添加到信号表)
INSERT INTO <signalTable> (id, type, data) VALUES ('<id>', '<snapshotType>', '{"data-collections": ["<fullyQualfiedTableName>","<fullyQualfiedTableName>"],"type":"<snapshotType>","additional-conditions":[{"data-collection": "<fullyQualfiedTableName>", "filter": "<additional-condition>"}]}');For example, (例如,)
INSERT INTO db1.myschema.debezium_signal (id, type, data) (1) values ('ad-hoc-1', (2) 'execute-snapshot', (3) '{"data-collections": ["db1.schema1.table1", "db1.schema1.table2"], (4) "type":"incremental", (5) "additional-conditions":[{"data-collection": "db1.schema1.table1" ,"filter":"color=\'blue\'"}]}'); (6)
The values of the id,type, and data parameters in the command correspond to the fields of the signaling table. (命令中的 id、type 和 data 参数的值对应于信号表的字段。)
The following table describes the parameters in the example (下表描述了示例中的参数:)
+ .向信号表发送增量快照 SQL 命令的字段描述
| Item | Value (值) | 描述 |
|---|---|---|
1 |
|
Specifies the fully-qualified name of the signaling table on the source database. (指定源数据库上信号表的完全限定名称。) |
2 |
|
The |
3 |
|
The |
4 |
|
A required component of the |
5 |
|
An optional |
6 |
|
An optional array that specifies a set of additional conditions that the connector evaluates to determine the subset of records to include in a snapshot. (一个可选数组,指定连接器用于确定要包含在快照中的记录子集的附加条件集。) |
使用 additional-conditions 运行临时增量快照
If you want a snapshot to include only a subset of the content in a table, you can modify the signal request by appending an additional-conditions parameter to the snapshot signal. (如果您希望快照仅包含表内容的子集,则可以通过将 additional-conditions 参数附加到快照信号来修改信号请求。)
The SQL query for a typical snapshot takes the following form (典型快照的 SQL 查询形式如下:)
SELECT * FROM <tableName> ....
By adding an additional-conditions parameter, you append a WHERE condition to the SQL query, as in the following example (通过添加 additional-conditions 参数,您可以将 WHERE 条件附加到 SQL 查询,如下例所示:)
SELECT * FROM <data-collection> WHERE <filter> ....
The following example shows a SQL query to send an ad hoc incremental snapshot request with an additional condition to the signaling table (以下示例显示了一个 SQL 查询,用于向信号表发送带有附加条件的即席增量快照请求:)
INSERT INTO <signalTable> (id, type, data) VALUES ('<id>', '<snapshotType>', '{"data-collections": ["<fullyQualfiedTableName>","<fullyQualfiedTableName>"],"type":"<snapshotType>","additional-conditions":[{"data-collection": "<fullyQualfiedTableName>", "filter": "<additional-condition>"}]}');
For example, suppose you have a products table that contains the following columns (例如,假设您有一个 products 表,其中包含以下列:)
-
id(primary key) -
color (颜色) -
quantity (数量)
If you want an incremental snapshot of the products table to include only the data items where color=blue, you can use the following SQL statement to trigger the snapshot (如果您希望 products 表的增量快照仅包含 color=blue 的数据项,您可以使用以下 SQL 语句来触发快照:)
INSERT INTO db1.myschema.debezium_signal (id, type, data) VALUES('ad-hoc-1', 'execute-snapshot', '{"data-collections": ["db1.schema1.products"],"type":"incremental", "additional-conditions":[{"data-collection": "db1.schema1.products", "filter": "color=blue"}]}');
The additional-conditions parameter also enables you to pass conditions that are based on more than one column. For example, using the products table from the previous example, you can submit a query that triggers an incremental snapshot that includes the data of only those items for which color=blue and quantity>10 (additional-conditions 参数还允许您传递基于多个列的条件。例如,使用前面示例中的 products 表,您可以提交一个查询来触发增量快照,其中仅包含 color=blue 且 quantity>10 的项目数据:)
INSERT INTO db1.myschema.debezium_signal (id, type, data) VALUES('ad-hoc-1', 'execute-snapshot', '{"data-collections": ["db1.schema1.products"],"type":"incremental", "additional-conditions":[{"data-collection": "db1.schema1.products", "filter": "color=blue AND quantity>10"}]}');
The following example, shows the JSON for an incremental snapshot event that is captured by a connector. (以下示例显示了连接器捕获的增量快照事件的 JSON。)
{
"before":null,
"after": {
"pk":"1",
"value":"New data"
},
"source": {
...
"snapshot":"incremental" (1)
},
"op":"r", (2)
"ts_ms":"1620393591654",
"ts_us":"1620393591654547",
"ts_ns":"1620393591654547920",
"transaction":null
}
| Item | Field name (字段名) | 描述 |
|---|---|---|
1 |
|
Specifies the type of snapshot operation to run. (指定要运行的快照操作的类型。) |
2 |
|
Specifies the event type. (指定事件类型。) |
使用 Kafka 信号通道触发增量快照
You can send a message to the configured Kafka topic to request the connector to run an ad hoc incremental snapshot. (您可以向配置的 Kafka 主题发送消息,请求连接器运行即席增量快照。)
The key of the Kafka message must match the value of the topic.prefix connector configuration option. (Kafka 消息的键必须与 topic.prefix 连接器配置选项的值匹配。)
The value of the message is a JSON object with type and data fields. (消息的值是一个带有 type 和 data 字段的 JSON 对象。)
The signal type is execute-snapshot, and the data field must have the following fields (信号类型为 execute-snapshot,data 字段必须具有以下字段:)
| Field (字段) | Default (默认值) | Value (值) |
|---|---|---|
|
|
The type of the snapshot to be executed. Currently Debezium supports the |
|
N/A |
An array of comma-separated regular expressions that match the fully-qualified names of tables to include in the snapshot. (一个逗号分隔的正则表达式数组,匹配要包含在快照中的表的完全限定名称。) |
|
N/A |
An optional array of additional conditions that specifies criteria that the connector evaluates to designate a subset of records to include in a snapshot. (一个可选的附加条件数组,指定连接器评估以指定要包含在快照中的记录子集的标准。) |
execute-snapshot Kafka message (示例 2. 一个 execute-snapshot Kafka 消息)Key = `test_connector`
Value = `{"type":"execute-snapshot","data": {"data-collections": ["{collection-container}.table1", "{collection-container}.table2"], "type": "INCREMENTAL"}}`
Debezium uses the additional-conditions field to select a subset of a table’s content. (Debezium 使用 additional-conditions 字段来选择表内容的子集。)
Typically, when Debezium runs a snapshot, it runs a SQL query such as (通常,当 Debezium 运行快照时,它会运行一个 SQL 查询,例如:)
SELECT * FROM <tableName> ….
When the snapshot request includes an additional-conditions property, the data-collection and filter parameters of the property are appended to the SQL query, for example (当快照请求包含 additional-conditions 属性时,该属性的 data-collection 和 filter 参数将被附加到 SQL 查询中,例如:)
SELECT * FROM <data-collection> WHERE <filter> ….
For example, given a products table with the columns id (primary key), color, and brand, if you want a snapshot to include only content for which color='blue', when you request the snapshot, you could add the additional-conditions property to filter the content: :leveloffset: +1 (例如,给定一个具有 id(主键)、color 和 brand 列的 products 表,如果您希望快照仅包含 color='blue' 的内容,在请求快照时,您可以添加 additional-conditions 属性来过滤内容::leveloffset: +1)
Key = `test_connector`
Value = `{"type":"execute-snapshot","data": {"data-collections": ["db1.schema1.products"], "type": "INCREMENTAL", "additional-conditions": [{"data-collection": "db1.schema1.products" ,"filter":"color='blue'"}]}}`
You can also use the additional-conditions property to pass conditions based on multiple columns. For example, using the same products table as in the previous example, if you want a snapshot to include only the content from the products table for which color='blue', and brand='MyBrand', you could send the following request: :leveloffset: +1 (您还可以使用 additional-conditions 属性来传递基于多个列的条件。例如,使用前面示例中的相同 products 表,如果您希望快照仅包含 products 表中 color='blue' 且 brand='MyBrand' 的内容,您可以发送以下请求::leveloffset: +1)
Key = `test_connector`
Value = `{"type":"execute-snapshot","data": {"data-collections": ["db1.schema1.products"], "type": "INCREMENTAL", "additional-conditions": [{"data-collection": "db1.schema1.products" ,"filter":"color='blue' AND brand='MyBrand'"}]}}`
停止增量快照
In some situations, it might be necessary to stop an incremental snapshot. For example, you might realize that snapshot was not configured correctly, or maybe you want to ensure that resources are available for other database operations. You can stop a snapshot that is already running by sending a signal to the signaling table on the source database. (在某些情况下,可能需要停止增量快照。例如,您可能发现快照配置不正确,或者您想确保资源可用于其他数据库操作。您可以通过向源数据库上的信号表发送信号来停止正在运行的快照。)
You submit a stop snapshot signal to the signaling table by sending it in a SQL INSERT query. The stop-snapshot signal specifies the type of the snapshot operation as incremental, and optionally specifies the tables that you want to omit from the currently running snapshot. After Debezium detects the change in the signaling table, it reads the signal, and stops the incremental snapshot operation if it’s in progress. (您通过在 SQL INSERT 查询中发送来将停止快照信号提交到信号表。stop-snapshot 信号将快照操作的 type 指定为 incremental,并可选地指定您希望从当前正在运行的快照中排除的表。在 Debezium 检测到信号表中的更改后,它会读取信号,并在增量快照操作进行中时停止它。)
您还可以通过向Kafka 信号主题发送 JSON 消息来停止增量快照。
-
-
A signaling data collection exists on the source database. (源数据库上存在信号数据集合。)
-
信号数据集合在
signal.data.collection属性中指定。
-
-
Send a SQL query to stop the ad hoc incremental snapshot to the signaling table (发送 SQL 查询以停止添加到信号表的即席增量快照)
INSERT INTO <signalTable> (id, type, data) values ('<id>', 'stop-snapshot', '{"data-collections": ["<fullyQualfiedTableName>","<fullyQualfiedTableName>"],"type":"incremental"}');For example, (例如,)
INSERT INTO db1.myschema.debezium_signal (id, type, data) (1) values ('ad-hoc-1', (2) 'stop-snapshot', (3) '{"data-collections": ["db1.schema1.table1", "db1.schema1.table2"], (4) "type":"incremental"}'); (5)
The values of the id, type, and data parameters in the signal command correspond to the fields of the signaling table. (信号命令中的 id、type 和 data 参数的值对应于信号表的字段。)
The following table describes the parameters in the example (下表描述了示例中的参数:)
+ .向信号表发送停止增量快照信号的 SQL 命令的字段描述
| Item | Value (值) | 描述 |
|---|---|---|
1 |
|
Specifies the fully-qualified name of the signaling table on the source database. (指定源数据库上信号表的完全限定名称。) |
2 |
|
The |
3 |
|
Specifies |
4 |
|
An optional component of the If you omit this component from the |
5 |
|
A required component of the |
使用 Kafka 信号通道停止增量快照
You can send a signal message to the configured Kafka signaling topic to stop an ad hoc incremental snapshot. (您可以向配置的 Kafka 信号主题发送信号消息,以停止即席增量快照。)
The key of the Kafka message must match the value of the topic.prefix connector configuration option. (Kafka 消息的键必须与 topic.prefix 连接器配置选项的值匹配。)
The value of the message is a JSON object with type and data fields. (消息的值是一个带有 type 和 data 字段的 JSON 对象。)
The signal type is stop-snapshot, and the data field must have the following fields (信号类型为 stop-snapshot,data 字段必须具有以下字段:)
| Field (字段) | Default (默认值) | Value (值) |
|---|---|---|
|
|
The type of the snapshot to be executed. Currently Debezium supports only the |
|
N/A |
An optional array of comma-separated regular expressions that match the fully-qualified names of the tables an array of table names or regular expressions to match table names to remove from the snapshot. (一个可选的逗号分隔的正则表达式数组,匹配要从快照中删除的表的表名称或匹配表名称的正则表达式数组。) |
The following example shows a typical stop-snapshot Kafka message (以下示例显示了一个典型的 stop-snapshot Kafka 消息:)
Key = `test_connector`
Value = `{"type":"stop-snapshot","data": {"data-collections": ["db1.schema1.table1", "db1.schema1.table2"], "type": "INCREMENTAL"}}`
Custom snapshotter SPI (自定义快照器 SPI)
For more advanced uses, you can fine-tune control of the snapshot by implementing one of the following interfaces (对于更高级的用途,您可以实现以下接口之一来微调快照的控制:)
io.debezium.snapshot.spi.Snapshotter-
Controls whether the connector takes a snapshot. (控制连接器是否执行快照。)
io.debezium.snapshot.spi.SnapshotQuery-
Controls how data is queried during a snapshot. (控制快照期间如何查询数据。)
io.debezium.snapshot.spi.SnapshotLock-
Controls whether the connector locks tables when taking a snapshot. (控制连接器在进行快照时是否锁定表。)
io.debezium.snapshot.spi.Snapshotter 接口。所有内置快照模式都实现了此接口。)/**
* {@link Snapshotter} is used to determine the following details about the snapshot process:
* <p>
* - Whether a snapshot occurs. <br>
* - Whether streaming continues during the snapshot. <br>
* - Whether the snapshot includes schema (if supported). <br>
* - Whether to snapshot data or schema following an error.
* <p>
* Although Debezium provides many default snapshot modes,
* to provide more advanced functionality, such as partial snapshots,
* you can customize implementation of the interface.
* For more information, see the documentation.
*
*
*
*/
@Incubating
public interface Snapshotter extends Configurable {
/**
* @return the name of the snapshotter.
*
*
*/
String name();
/**
* @param offsetExists is {@code true} when the connector has an offset context (i.e. restarted)
* @param snapshotInProgress is {@code true} when the connector is started, but a snapshot is already in progress
*
* @return {@code true} if the snapshotter should take a data snapshot
*/
boolean shouldSnapshotData(boolean offsetExists, boolean snapshotInProgress);
/**
* @param offsetExists is {@code true} when the connector has an offset context (i.e. restarted)
* @param snapshotInProgress is {@code true} when the connector is started, but a snapshot is already in progress
*
* @return {@code true} if the snapshotter should take a schema snapshot
*/
boolean shouldSnapshotSchema(boolean offsetExists, boolean snapshotInProgress);
/**
* @return {@code true} if the snapshotter should stream after taking a snapshot
*/
boolean shouldStream();
/**
* @return {@code true} whether the schema can be recovered if database schema history is corrupted.
*/
boolean shouldSnapshotOnSchemaError();
/**
* @return {@code true} whether the snapshot should be re-executed when there is a gap in data stream.
*/
boolean shouldSnapshotOnDataError();
/**
*
* @return {@code true} if streaming should resume from the start of the snapshot
* transaction, or {@code false} for when a connector resumes and takes a snapshot,
* streaming should resume from where streaming previously left off.
*/
default boolean shouldStreamEventsStartingFromSnapshot() {
return true;
}
/**
* Lifecycle hook called after the snapshot phase is successful.
*/
default void snapshotCompleted() {
// no operation
}
/**
* Lifecycle hook called after the snapshot phase is aborted.
*/
default void snapshotAborted() {
// no operation
}
}
io.debezium.snapshot.spi.SnapshotQuery 接口。所有内置快照查询模式都实现了此接口。)/**
* {@link SnapshotQuery} is used to determine the query used during a data snapshot
*
*
*/
public interface SnapshotQuery extends Configurable, Service {
/**
* @return the name of the snapshot lock.
*
*
*/
String name();
/**
* Generate a valid query string for the specified table, or an empty {@link Optional}
* to skip snapshotting this table (but that table will still be streamed from)
*
* @param tableId the table to generate a query for
* @param snapshotSelectColumns the columns to be used in the snapshot select based on the column
* include/exclude filters
* @return a valid query string, or none to skip snapshotting this table
*/
Optional<String> snapshotQuery(String tableId, List<String> snapshotSelectColumns);
}
io.debezium.snapshot.spi.SnapshotLock 接口。所有内置快照锁定模式都实现了此接口。)/**
* {@link SnapshotLock} is used to determine the table lock mode used during schema snapshot
*
*
*/
public interface SnapshotLock extends Configurable, Service {
/**
* @return the name of the snapshot lock.
*
*
*/
String name();
/**
* Returns a SQL statement for locking the given table during snapshotting, if required by the specific snapshotter
* implementation.
*/
Optional<String> tableLockingStatement(Duration lockTimeout, String tableId);
}
阻塞快照
To provide more flexibility in managing snapshots, Debezium includes a supplementary ad hoc snapshot mechanism, known as a blocking snapshot. Blocking snapshots rely on the Debezium mechanism for sending signals to a Debezium connector. (为了在管理快照时提供更大的灵活性,Debezium 提供了一个补充的即席快照机制,称为阻塞快照。阻塞快照依赖于 Debezium 向 Debezium 连接器发送信号的机制。)
A blocking snapshot behaves just like an initial snapshot, except that you can trigger it at run time. (阻塞快照的行为与初始快照完全相同,只是您可以随时在运行时触发它。)
You might want to run a blocking snapshot rather than use the standard initial snapshot process in the following situations (您可能希望在以下情况下运行阻塞快照,而不是使用标准的初始快照过程:)
-
You add a new table and you want to complete the snapshot while the connector is running. (添加了一个新表,并且您希望在连接器运行时完成快照。)
-
You add a large table, and you want the snapshot to complete in less time than is possible with an incremental snapshot. (添加了一个大表,并且您希望快照的完成时间比增量快照更快。)
When you run a blocking snapshot, Debezium stops streaming, and then initiates a snapshot of the specified table, following the same process that it uses during an initial snapshot. After the snapshot completes, the streaming is resumed. (运行阻塞快照时,Debezium 会停止流式传输,然后启动指定表的快照,遵循其在初始快照期间使用的相同过程。快照完成后,流式传输将恢复。)
You can set the following properties in the data component of a signal (您可以在信号的 data 组件中设置以下属性:)
-
data-collections: to specify which tables must be snapshot. (data-collections:用于指定必须进行快照的表。)
-
data-collections: Specifies the tables that you want the snapshot to include. (data-collections:指定您希望快照包含的表。)
This property accepts a comma-separated list of regular expressions that match fully-qualified table names. The behavior of the property is similar to the behavior of thetable.include.listproperty, which specifies the tables to capture in a blocking snapshot. (此属性接受逗号分隔的正则表达式列表,这些表达式匹配完全限定的表名。此属性的行为类似于table.include.list属性的行为,后者指定要在阻塞快照中捕获的表。) -
additional-conditions: You can specify different filters for different table. (additional-conditions:您可以为不同的表指定不同的过滤器。)
-
The
data-collectionproperty is the fully-qualified name of the table for which the filter will be applied, and can be case-sensitive or case-insensitive depending on the database. (data-collection属性是过滤器将应用的表的完全限定名称,并且根据数据库的不同,可能区分大小写或不区分大小写。) -
The
filterproperty will have the same value used in thesnapshot.select.statement.overrides, the fully-qualified name of the table that should match by case. (filter属性将具有与snapshot.select.statement.overrides中使用的值相同的值,即应区分大小写匹配的表的完全限定名称。)
-
For example (例如:)
{"type": "blocking", "data-collections": ["schema1.table1", "schema1.table2"], "additional-conditions": [{"data-collection": "schema1.table1", "filter": "SELECT * FROM [schema1].[table1] WHERE column1 = 0 ORDER BY column2 DESC"}, {"data-collection": "schema1.table2", "filter": "SELECT * FROM [schema1].[table2] WHERE column2 > 0"}]}
A delay might exist between the time that you send the signal to trigger the snapshot, and the time when streaming stops and the snapshot starts. As a result of this delay, after the snapshot completes, the connector might emit some event records that duplicate records captured by the snapshot. (从您发送触发快照的信号到流式传输停止并开始快照之间可能存在延迟。由于此延迟,快照完成后,连接器可能会发出一些重复快照捕获记录的事件记录。)
变更流记录
完成快照后,当 Debezium Informix 连接器首次启动时,它将开始消耗处于捕获模式的源表的变更流记录。连接器执行以下操作:
-
从当前 LSN 读取可用的更改记录。
-
按事务 ID 对记录进行分组,并按每条记录的更改 LSN 进行排序。
-
在事务提交时处理记录。
-
将开始、提交和更改 LSN 作为偏移量传递给 Kafka Connect。
-
存储连接器传递给 Kafka Connect 的最高提交 LSN 和最低未提交开始 LSN。
重启后,连接器将从上次中断的偏移量(开始、提交和更改 LSN)处恢复发出更改事件。它通过以下方式实现:
-
读取在最后存储的最低未提交开始 LSN 和当前 LSN 之间创建的更改记录。
-
按事务 ID 对记录进行分组,并按每个事件的更改 LSN 进行排序。
-
丢弃已处理的事务(提交 LSN 低于最后存储的提交 LSN)。
-
丢弃最后一个未完整处理事务的已处理记录(如果有)(更改 LSN 低于最后存储的更改 LSN 且提交 LSN 等于最后存储的提交 LSN)。
-
处理任何未完整处理事务的剩余记录。
-
在事务提交时继续处理记录。
主题名称
默认情况下,Informix 连接器将表中发生的所有 INSERT、UPDATE 和 DELETE 操作的更改事件写入一个特定于该表的 Apache Kafka 主题。连接器使用以下约定命名更改事件主题:
topicPrefix.schemaName.tableName
以下列表提供了默认名称组件的定义:
- topicPrefix
-
由
topic.prefix连接器配置属性指定的 the topic prefix。 - schemaName (模式名称)
-
操作发生的模式(schema)的名称。
- tableName
-
操作发生的表的名称。
例如,考虑一个 Informix 安装,其中包含一个名为 mydatabase 的数据库,该数据库在 myschema schema 中包含以下表:
-
products -
products_on_hand -
customers -
ordersThe connector would emit events to the following Kafka topics:
-
mydatabase.myschema.products -
mydatabase.myschema.products_on_hand -
mydatabase.myschema.customers -
mydatabase.myschema.orders
如果默认主题名称不满足您的要求,您可以配置自定义主题名称。要配置自定义主题名称,请在逻辑主题路由 SMT 中指定正则表达式。有关使用逻辑主题路由 SMT 自定义主题名称的更多信息,请参阅 主题路由。
模式历史主题
当数据库客户端查询数据库时,客户端使用数据库的当前模式。但是,数据库模式可以随时更改,这意味着连接器必须能够识别在记录每个插入、更新或删除操作时模式是什么。另外,连接器不一定能将当前模式应用于每个事件。如果一个事件相对较旧,它可能是在当前模式应用之前记录的。
为了确保对模式更改后发生的事件进行正确处理,Debezium Informix 连接器会存储新模式的快照,该快照基于 Informix 更改数据表的结构,这些表镜像了其关联数据表的结构。连接器将表模式信息与导致模式更改的操作的 LSN 一起存储在数据库模式历史 Kafka 主题中。连接器使用存储的模式表示来生成更改事件,这些事件正确地镜像了每个插入、更新或删除操作发生时表的结构。
当连接器在崩溃或正常停止后重新启动时,它将从它上次读取的位置恢复读取 Informix 更改数据表中的条目。根据连接器从数据库模式历史主题读取的模式信息,连接器将应用连接器重新启动时存在的表结构。
如果您更新了处于捕获模式的 Informix 表的模式,那么您也必须更新相应的更改表的模式。您必须是具有提升特权的 Informix 数据库管理员才能更新数据库模式。有关如何在 Debezium 环境中更新 Informix 数据库模式的更多信息,请参阅 模式历史演变。
数据库模式历史主题仅供连接器内部使用。可选地,连接器还可以将模式更改事件发送到另一个供消费者应用程序使用的主题。
模式更改主题
您可以配置 Debezium Informix 连接器以生成描述应用于数据库表中模式更改的模式更改事件。
在源数据库中发生以下操作后,Debezium 会向模式更改主题发出消息:
-
您启用 Debezium 以捕获新表的更改。
-
您禁用 Debezium 之前捕获更改的表的捕获。
连接器将模式更改事件写入名为 <topicPrefix> 的 Kafka 模式更改主题,其中 <topicPrefix> 是在 topic.prefix 连接器配置属性中指定的 the topic prefix。该主题用于所有从该连接器接收记录的 Kafka 主题。
模式变更事件的模式具有以下元素:
name (名称)-
模式变更事件消息的名称。
type-
事件消息类型的类型。
version (版本)-
模式的版本。版本是一个整数,每次模式更改时都会递增。
fields (字段)-
变更事件消息中包含的字段。
以下示例以 JSON 格式显示了典型的模式。
{
"schema": {
"type": "struct",
"fields": [
{
"type": "string",
"optional": false,
"field": "databaseName"
}
],
"optional": false,
"name": "io.debezium.connector.informix.SchemaChangeKey",
"version": 1
},
"payload": {
"databaseName": "inventory"
}
}
连接器发送到模式更改主题的消息包含一个载荷,其中包括以下元素:
databaseName (数据库名称)-
应用于语句的数据库名称。
databaseName的值用作消息键。 pos (位置)-
语句在事务日志中出现的位置。
tableChanges (表变更)-
模式更改后整个表模式的结构化表示。
tableChanges字段包含一个数组,其中包含表每个列的条目。由于结构化表示以 JSON 或 Avro 格式呈现数据,因此消费者无需先通过 DDL 解析器处理消息即可轻松读取消息。
|
对于处于捕获模式的表,连接器不仅将模式更改历史记录存储在模式更改主题中,还将存储在内部数据库模式历史主题中。内部数据库模式历史主题仅供连接器使用,不用于使用者应用程序的直接使用。确保需要模式更改通知的应用程序仅从模式更改主题中获取该信息。 |
|
切勿分区数据库模式历史主题。为了使数据库模式历史主题正常工作,它必须维护连接器发送到它的事件记录的一致的全局顺序。 为了确保主题不会在分区之间分割,请使用以下任一方法设置主题的分区计数:
|
|
连接器发出的模式更改主题消息的格式仍处于孵化状态,可能会随时更改。 |
以下示例显示了模式更改主题中的一条消息。该消息包含表的逻辑表示。
{
"schema": {
...
},
"payload": {
"source": {
"version": "3.3.1.Final",
"connector": "informix",
"name": "informix",
"ts_ms": 1588252618953,
"snapshot": "true",
"db": "testdb",
"schema": "informix",
"table": "customers",
"commit_lsn": "0",
"change_lsn": "0",
"txId": null,
"begin_lsn": "0"
},
"ts_ms": 1588252618953, (1)
"databaseName": "testdb", (2)
"schemaName": "informix",
"ddl": null, (3)
"tableChanges": [ (4)
{
"type": "CREATE", (5)
"id": "\"testdb\".\"informix\".\"customers\"", (6)
"table": { (7)
"defaultCharsetName": null,
"primaryKeyColumnNames": [ (8)
"id"
],
"columns": [ (9)
{
"name": "id",
"jdbcType": 4,
"nativeType": null,
"typeName": "int identity",
"typeExpression": "int identity",
"charsetName": null,
"length": 10,
"scale": 0,
"position": 1,
"optional": false,
"autoIncremented": false,
"generated": false
},
{
"name": "first_name",
"jdbcType": 12,
"nativeType": null,
"typeName": "varchar",
"typeExpression": "varchar",
"charsetName": null,
"length": 255,
"scale": null,
"position": 2,
"optional": false,
"autoIncremented": false,
"generated": false
},
{
"name": "last_name",
"jdbcType": 12,
"nativeType": null,
"typeName": "varchar",
"typeExpression": "varchar",
"charsetName": null,
"length": 255,
"scale": null,
"position": 3,
"optional": false,
"autoIncremented": false,
"generated": false
},
{
"name": "email",
"jdbcType": 12,
"nativeType": null,
"typeName": "varchar",
"typeExpression": "varchar",
"charsetName": null,
"length": 255,
"scale": null,
"position": 4,
"optional": false,
"autoIncremented": false,
"generated": false
}
],
"attributes": [ (10)
{
"customAttribute": "attributeValue"
}
]
}
}
]
}
}
| Item | Field name (字段名) | 描述 | ||||||
|---|---|---|---|---|---|---|---|---|
1 |
|
可选字段,显示连接器处理事件的时间。时间基于运行 Kafka Connect 任务的 JVM 中的系统时钟。 在 source 对象中, |
||||||
2 |
|
标识包含更改的数据库和模式。 |
||||||
3 |
|
对于 Informix 连接器,始终为 |
||||||
4 |
|
包含 DDL 命令生成的模式变更的一个或多个项目的数组。 |
||||||
5 |
|
描述更改的类型。该字段包含以下值之一:
|
||||||
6 |
|
已创建、已修改或已删除的表的完整标识符。 |
||||||
7 |
|
表示应用更改后表的元数据。 |
||||||
8 |
|
构成表主键的列列表。 |
||||||
9 |
|
已更改表中每个列的元数据。 |
||||||
10 |
|
每个表变更的自定义属性元数据。 |
在连接器发送到模式更改主题的消息中,消息键是包含模式更改的数据库的名称。在以下示例中,payload 字段包含键:
{
"schema": {
"type": "struct",
"fields": [
{
"type": "string",
"optional": false,
"field": "databaseName"
}
],
"optional": false,
"name": "io.debezium.connector.informix.SchemaChangeKey",
"version": 1
},
"payload": {
"databaseName": "testdb"
}
}
事务元数据
Debezium 可以生成代表事务边界并丰富更改事件消息的事件。
|
Debezium 接收事务元数据的限制
Debezium 仅为部署连接器后发生的事务注册和接收元数据。部署连接器之前发生的事务的元数据不可用。 |
Debezium 为每个事务中的 BEGIN 和 END 分隔符生成事务边界事件。事务边界事件包含以下字段:
status-
BEGIN或END。 id-
由 Informix 事务 ID 本身和给定操作的 LSN 组成的唯一事务标识符的字符串表示形式,用冒号分隔,即格式为
txID:LSN。 ts_ms-
数据源中事务边界事件(
BEGIN或END事件)的时间。如果数据源未向 Debezium 提供事件时间,则该字段将代表 Debezium 处理事件的时间。 event_count(针对END事件)-
事务发出的事件总数。
data_collections(针对END事件)-
一对
data_collection和event_count元素的数组,指示连接器为源自数据集合的更改发出的事件数量。
{
"status": "BEGIN",
"id": "571:53195829",
"ts_ms": 1486500577125,
"event_count": null,
"data_collections": null
}
{
"status": "END",
"id": "571:53195832",
"ts_ms": 1486500577691,
"event_count": 2,
"data_collections": [
{
"data_collection": "testdb.informix.tablea",
"event_count": 1
},
{
"data_collection": "testdb.informix.tableb",
"event_count": 1
}
]
}
默认情况下,连接器将事务事件发送到名为 <topic.prefix>.transaction 的主题。您可以通过更改 topic.transaction 属性的值来覆盖默认设置。
启用事务元数据后,连接器会使用新的 transaction 字段丰富更改事件 Envelope。该字段以字段的组合形式提供每个事件的信息:
id-
唯一事务标识符的字符串表示。
total_order-
事件在事务生成的所有事件中的绝对位置。
data_collection_order-
事件在事务发出的所有事件中,每个数据集合的位置。
以下是消息示例
{
"before": null,
"after": {
"pk": "2",
"aa": "1"
},
"source": {
...
},
"op": "c",
"ts_ms": "1580390884335",
"ts_us": "1580390884335641",
"ts_ns": "1580390884335641387",
"transaction": {
"id": "571:53195832",
"total_order": "1",
"data_collection_order": "1"
}
}
数据更改事件
Debezium Informix 连接器为每个行级别的 INSERT、UPDATE 和 DELETE 操作生成一个数据更改事件。每个事件都包含一个键和一个值。键和值的结构取决于发生更改的表。
Debezium 和 Kafka Connect 设计用于处理连续的事件消息流。然而,由于这些事件的结构可能会随时间变化,消费者在处理某些 Debezium 事件时可能会遇到困难。为了解决这个问题,每个事件都被设计成自包含的。也就是说,事件包含其内容的模式,或者在使用模式注册表的环境中,包含消费者可用于从注册表中获取模式的模式 ID。
以下示例中的 JSON 结构显示了典型的 Debezium 事件记录如何表示更改事件的四个基本组件。事件的确切表示取决于您为应用程序配置的 Kafka Connect 转换器。schema 字段仅在您配置转换器生成它时才存在于更改事件中。同样,如果配置转换器生成它们,则事件键和事件负载才会出现在更改事件中。如果您使用 JSON 转换器并配置它生成所有四个基本更改事件部分,更改事件将具有以下结构:
{
"schema": { (1)
...
},
"payload": { (2)
...
},
"schema": { (3)
...
},
"payload": { (4)
...
},
}
| Item | Field name (字段名) | 描述 |
|---|---|---|
1 |
|
第一个 |
2 |
|
第一个 |
3 |
|
第二个 |
4 |
|
第二个 |
默认情况下,连接器将更改事件记录流式传输到名称与事件的源表相同的命名主题。有关更多信息,请参阅 主题名称。
|
Debezium Informix 连接器确保所有 Kafka Connect 模式名称都符合Avro 模式名称格式。符合 Avro 模式名称格式意味着逻辑服务器名称以拉丁字母或下划线(即 使用下划线替换无效字符可能导致意外冲突。例如,当逻辑服务器、数据库或表的名称包含一个或多个无效字符,并且这些字符是区分该名称与同一类型其他实体名称的唯一字符时,就会发生冲突。 命名冲突也可能发生,因为 Informix 中的数据库、模式和表的名称可能区分大小写。在某些情况下,连接器可能会将来自多个表的事件记录发送到同一个 Kafka 主题。 |
更改事件键
更改事件的键包含已更改表的键的模式和已更改行的实际键。模式和相应的有效负载都包含已更改表的
PRIMARY KEY(或唯一约束)在连接器创建事件时的每个列的字段。
考虑以下 customers 表,后面是该表更改事件键的示例。
CREATE TABLE customers (
id INTEGER IDENTITY(1001,1) NOT NULL PRIMARY KEY,
first_name VARCHAR(255) NOT NULL,
last_name VARCHAR(255) NOT NULL,
email VARCHAR(255) NOT NULL UNIQUE
);
当 Debezium 从 customers 表捕获更改时,它会发出一个包含事件键模式的更改事件记录。只要 customers 表的定义保持不变,Debezium 从 customers 表捕获的每个更改都会导致一个具有相同键结构的事件记录。以下示例显示了事件结构的 JSON 表示:
{
"schema": { (1)
"type": "struct",
"fields": [ (2)
{
"type": "int32",
"optional": false,
"field": "ID"
}
],
"optional": false, (3)
"name": "mydatabase.myschema.customers.Key" (4)
},
"payload": { (5)
"ID": 1004
}
}
| Item | Field name (字段名) | 描述 |
|---|---|---|
1 |
|
键的 schema 元素显示了描述键 |
2 |
|
指定 |
3 |
|
指示事件键是否必须在其 |
4 |
|
定义键 payload 结构 的模式的名称。此模式描述了所更改表的 主键 的结构。键模式名称的格式如下: 在前面的示例中,模式名称由以下元素组成:
|
5 |
|
包含更改事件发生的表行的键。在前面的示例中,键包含一个名为 |
更改事件值
更改事件中的值比键要复杂一些。与事件键一样,值也包括一个 schema 元素和一个 payload 元素。schema 元素包含描述 payload 元素(包括其嵌套字段)的 Envelope 结构的模式。创建、更新或删除数据的操作的更改事件都具有带有信封结构的(值)负载。
考虑用于更改事件键示例的示例 `customers` 表
CREATE TABLE customers (
id INTEGER IDENTITY(1001,1) NOT NULL PRIMARY KEY,
first_name VARCHAR(255) NOT NULL,
last_name VARCHAR(255) NOT NULL,
email VARCHAR(255) NOT NULL UNIQUE
);
Debezium 从 customers 表捕获的每个更改事件的值元素都使用相同的模式。每个事件值的 payload 结构都根据事件类型而变化:
create 事件
以下示例显示了连接器为在 customers 表中创建数据的操作生成的更改事件的值部分:
{
"schema": { (1)
"type": "struct",
"fields": [
{
"type": "struct",
"fields": [
{
"type": "int32",
"optional": false,
"field": "id"
},
{
"type": "string",
"optional": false,
"field": "first_name"
},
{
"type": "string",
"optional": false,
"field": "last_name"
},
{
"type": "string",
"optional": false,
"field": "email"
}
],
"optional": true,
"name": "mydatabase.myschema.customers.Value", (2)
"field": "before"
},
{
"type": "struct",
"fields": [
{
"type": "int32",
"optional": false,
"field": "id"
},
{
"type": "string",
"optional": false,
"field": "first_name"
},
{
"type": "string",
"optional": false,
"field": "last_name"
},
{
"type": "string",
"optional": false,
"field": "email"
}
],
"optional": true,
"name": "mydatabase.myschema.customers.Value",
"field": "after"
},
{
"type": "struct",
"fields": [
{
"type": "string",
"optional": false,
"field": "version"
},
{
"type": "string",
"optional": false,
"field": "connector"
},
{
"type": "string",
"optional": false,
"field": "name"
},
{
"type": "int64",
"optional": false,
"field": "ts_ms"
},
{
"type": "int64",
"optional": false,
"field": "ts_us"
},
{
"type": "int64",
"optional": false,
"field": "ts_ns"
},
{
"type": "boolean",
"optional": true,
"default": false,
"field": "snapshot"
},
{
"type": "string",
"optional": false,
"field": "db"
},
{
"type": "string",
"optional": false,
"field": "schema"
},
{
"type": "string",
"optional": false,
"field": "table"
},
{
"type": "string",
"optional": true,
"field": "commit_lsn"
},
{
"type": "string",
"optional": true,
"field": "change_lsn"
},
{
"type": "string",
"optional": true,
"field": "txId"
},
{
"type": "string",
"optional": true,
"field": "begin_lsn"
}
],
"optional": false,
"name": "io.debezium.connector.informix.Source", (3)
"field": "source"
},
{
"type": "string",
"optional": false,
"field": "op"
},
{
"type": "int64",
"optional": true,
"field": "ts_ms"
},
{
"type": "int64",
"optional": true,
"field": "ts_us"
},
{
"type": "int64",
"optional": true,
"field": "ts_ns"
}
],
"optional": false,
"name": "mydatabase.myschema.customers.Envelope" (4)
},
"payload": { (5)
"before": null, (6)
"after": { (7)
"id": 1005,
"first_name": "john",
"last_name": "doe",
"email": "john.doe@example.org"
},
"source": { (8)
"version": "3.3.1.Final",
"connector": "informix",
"name": "myconnector",
"ts_ms": 1559729468470,
"ts_us": 1559729468470000,
"ts_ns": 1559729468470000000,
"snapshot": false,
"db": "mydatabase",
"schema": "myschema",
"table": "customers",
"commit_lsn": "627404540760620",
"change_lsn": "627404540485812",
"txId": "157",
"begin_lsn": "627404540372400"
},
"op": "c", (9)
"ts_ms": 1559729471739, (10)
"ts_us": 1559729471739241, (10)
"ts_ns": 1559729471739241367 (10)
}
}
| Item | Field name (字段名) | 描述 | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
1 |
|
值的模式,该模式描述了值 payload 的结构。在连接器为特定表生成的每个更改事件中,更改事件的模式与值相同。 |
||||||||
2 |
|
在 |
||||||||
3 |
|
|
||||||||
4 |
|
|
||||||||
5 |
|
值的数据。payload 提供了有关事件如何更改表行中数据的详细信息。 |
||||||||
6 |
|
一个可选字段,表示事件发生前行的状态。当 |
||||||||
7 |
|
一个可选字段,指定事件发生后行的状态。在此示例中, |
||||||||
8 |
|
必需字段,描述事件的源元数据。
|
||||||||
9 |
|
必需字符串,描述导致连接器生成事件的操作类型。在前面的示例中,
|
||||||||
10 |
|
一个可选字段,显示连接器处理事件的时间。时间基于运行 Kafka Connect 任务的 JVM 中的系统时钟。 |
update 事件
示例 customers 表中更新的更改事件的值的模式与该表的create 事件的模式相同。同样,update 事件的值的 payload 结构也与其create 事件的值 payload 的结构相对应。然而,update 事件和create 事件的 value payload 并不包含相同的值。以下示例显示了连接器响应 customers 表更新而生成的事件记录的更改事件值:
{
"schema": { ... },
"payload": {
"before": { (1)
"id": 1005,
"first_name": "john",
"last_name": "doe",
"email": "john.doe@example.org"
},
"after": { (2)
"ID": 1005,
"first_name": "john",
"last_name": "doe",
"email": "noreply@example.org"
},
"source": { (3)
"version": "3.3.1.Final",
"connector": "informix",
"name": "myconnector",
"ts_ms": 1559729995937,
"ts_us": 1559729995937000,
"ts_ns": 1559729995937000000,
"snapshot": false,
"db": "mydatabase",
"schema": "myschema",
"table": "customers",
"commit_lsn": "627404540760620",
"change_lsn": "627404540485812",
"txId": "157",
"begin_lsn": "627404540372400"
},
"op": "u", (4)
"ts_ms": 1559729998706, (5)
"ts_us": 1559729998706742, (5)
"ts_ns": 1559729998706742877 (5)
}
}
| Item | Field name (字段名) | 描述 |
|---|---|---|
1 |
|
一个可选字段,指定事件发生前行的状态。在update 事件值中, |
2 |
|
一个可选字段,指定事件发生后行的状态。通过比较 |
3 |
|
必需字段,描述事件的源元数据。
|
4 |
|
描述操作类型的 必需字符串。在更新事件值中, |
5 |
|
一个可选字段,显示连接器处理事件的时间。时间基于运行 Kafka Connect 任务的 JVM 中的系统时钟。 |
|
如果您更新了行主键或唯一键的列,您将更改了该行键的值。键更改后,Debezium 会发出以下事件:
|
delete 事件
表中删除操作的更改事件的 value 具有与该表的create 和update 事件中 schema 元素相似的 schema 部分。在用户执行了 customers 表中的delete 操作后,Debezium 会发出一个事件消息,如下例所示:
{
"schema": { ... },
},
"payload": {
"before": { (1)
"id": 1005,
"first_name": "john",
"last_name": "doe",
"email": "noreply@example.org"
},
"after": null, (2)
"source": { (3)
"version": "3.3.1.Final",
"connector": "informix",
"name": "myconnector",
"ts_ms": 1559730445243,
"ts_us": 1559730445243000,
"ts_ns": 1559730445243000000,
"snapshot": false,
"db": "mydatabase",
"schema": "myschema",
"table": "customers",
"commit_lsn": "627404540760620",
"change_lsn": "627404540485812",
"txId": "157",
"begin_lsn": "627404540372400"
},
"op": "d", (4)
"ts_ms": 1559730450205, (5)
"ts_us": 1559730450205104, (5)
"ts_ns": 1559730450205104870 (5)
}
}
| Item | Field name (字段名) | 描述 |
|---|---|---|
1 |
|
一个可选字段,指定事件发生前行的状态。在delete 事件值中, |
2 |
|
一个可选字段,指定事件发生后行的状态。在删除事件值中, |
3 |
|
必需字段,描述事件的源元数据。在delete 事件值中,
|
4 |
|
必需字符串,描述操作类型。 |
5 |
|
可选字段,显示连接器处理事件的时间。时间基于运行 Kafka Connect 任务的 JVM 中的系统时钟。 |
delete 更改事件记录为消费者提供了处理行删除所需的信息。该记录包含先前的值,以支持可能需要它们来处理删除的消费者。
Informix 连接器事件旨在与Kafka 日志压缩配合使用。日志压缩允许删除一些较旧的消息,只要保留每条键的最新消息。保留最新消息可让 Kafka 重新占用存储空间,同时确保主题包含可用于重新加载基于键的状态的完整数据集。
当一行被删除时,delete 事件值仍然可以与日志压缩一起使用,因为 Kafka 可以删除具有相同键的所有先前消息。但是,为了让 Kafka 删除具有相同键的所有消息,消息值必须为 null。为了实现这一点,在 Debezium 的 Informix 连接器发出delete 事件后,连接器会发出一个特殊的墓碑事件,该事件具有相同的键但值为 null。
数据类型映射
有关 Informix 支持的数据类型的完整描述,请参阅 Informix 文档中的数据类型。
Informix 连接器通过发出其结构镜像更改事件发生所在的源表的结构的事件来表示对行的更改。事件记录包含每个列值的字段。为了从源列中填充这些字段的值,连接器使用默认映射将值从原始 Informix 数据类型转换为 Kafka Connect 模式类型或语义类型。连接器为以下 Informix 数据类型提供默认映射:
如果默认数据类型转换不满足您的需求,您可以创建自定义转换器以供连接器使用。
基本类型
下表描述了连接器如何将每种 Informix 数据类型映射到事件字段中的文字类型和语义类型。
-
字面类型使用 Kafka Connect 模式类型描述了值的表示方式:
INT8、INT16、INT32、INT64、FLOAT32、FLOAT64、BOOLEAN、STRING、BYTES、ARRAY、MAP和STRUCT。 -
语义类型使用 Kafka Connect 模式的名称描述了 Kafka Connect 模式如何捕获字段的*含义*。
| Informix 数据类型 | 字面类型 (模式类型) | 语义类型 (模式名称) 和注释 |
|---|---|---|
|
|
n/a |
|
|
n/a |
|
|
n/a |
|
|
n/a |
|
|
n/a |
|
|
n/a |
|
|
n/a |
|
|
|
|
|
|
|
|
|
|
|
n/a |
|
|
n/a |
|
|
n/a |
|
|
n/a |
|
|
|
|
|
n/a |
|
|
n/a |
|
|
n/a |
|
|
n/a |
|
|
0 到 255 之间的 8 位无符号整数值,因此需要存储为 int16 |
|
|
n/a |
|
|
n/a |
如果存在,列的默认值将传播到相应字段的 Kafka Connect 模式。除非指定了显式列值,否则更改事件将包含字段的默认值。因此,很少需要从模式中获取默认值。传递默认值有助于在使用 Avro 作为序列化格式并结合 Confluent 模式注册表时满足兼容性规则。
时间类型
Informix 根据 time.precision.mode 连接器配置属性的值映射时间类型。以下各节描述了这些映射:
time.precision.mode=adaptive为确保事件精确表示数据库中的值,当 time.precision.mode 配置属性设置为默认值 adaptive 时,连接器将根据列的数据类型定义确定文字和语义类型。
| Informix 数据类型 | 字面类型 (模式类型) | 语义类型 (模式名称) 和注释 |
|---|---|---|
|
|
|
|
|
|
time.precision.mode=connect当 time.precision.mode 配置属性设置为 connect 时,连接器将使用 Kafka Connect 逻辑类型。此设置对于只能处理内置 Kafka Connect 逻辑类型而无法处理可变精度时间值的消费者很有用。然而,由于 Informix 支持数十微秒的精度,如果一个连接器配置为使用 connect 时间精度,并且数据库列具有大于 3 的小数秒精度值,则连接器将生成导致精度损失的事件。
| Informix 数据类型 | 字面类型 (模式类型) | 语义类型 (模式名称) 和注释 |
|---|---|---|
|
|
|
|
|
|
Informix Change Stream 客户端不支持 INTERVAL 类型。
时间戳类型
DATETIME 类型表示不带时区信息的时间戳。此类列将被转换为等效的 Kafka Connect 值(基于 UTC)。例如,DATETIME 值 "2018-06-20 15:13:16.94514" 由值 "1529507596000" 的 io.debezium.time.Timestamp 表示。
运行 Kafka Connect 和 Debezium 的 JVM 的时区不影响此转换。
Decimal 类型
| Informix 数据类型 | 字面类型 (模式类型) | 语义类型 (模式名称) 和注释 |
|---|---|---|
|
|
|
|
|
|
设置 Informix
为了让 Debezium 捕获已提交到 Informix 表的更改事件,具有必要权限的 Informix 数据库管理员必须为数据库配置变更数据捕获。
执行以下任务以准备使用 Change Data Capture API:
-
以
informix用户身份运行$INFORMIXDIR/etc目录下的syscdcv1.sql脚本。这将安装syscdcv1数据库。 -
通过以
informix用户身份创建连接到它来验证syscdcv1数据库是否存在。 -
将
DB_LOCALE环境变量设置为与您要从中捕获数据的数据库的区域设置相同。
|
有关优化 Informix 以进行变更数据捕获的具体指导超出了本文档的范围。 |
部署
要部署 Debezium Informix 连接器,请安装 Debezium Informix 连接器存档,配置连接器,并通过将其配置添加到 Kafka Connect 来启动连接器。
-
已安装 Apache Kafka 和 Kafka Connect。
-
Informix 已安装,并且表已启用捕获模式,为使用 Debezium 连接器准备数据库。
-
从 Maven Central 下载Debezium Informix 连接器插件存档。
-
将 JAR 文件提取到您的 Kafka Connect 环境中。
-
从 Maven Central 下载 Informix JDBC 驱动程序和 Informix Change Stream 客户端,并将下载的 JAR 文件复制到包含 Debezium Informix 连接器 JAR 文件的目录(即
debezium-connector-informix-3.3.1.Final.jar)。由于许可要求,Debezium Informix 连接器存档不包含 Debezium 连接到 Informix 数据库所需的 Informix JDBC 驱动程序和 Change Stream 客户端。要使连接器能够访问数据库,您必须将驱动程序和客户端库添加到您的连接器环境中。
-
将包含 JAR 文件的目录添加到Kafka Connect 的
plugin.path。 -
重新启动您的 Kafka Connect 进程以加载新 JAR 文件。
如果您正在使用不可变容器,请参阅 Debezium 的容器镜像,其中已安装 Apache Kafka 和 Kafka Connect 以及 Informix 连接器,并已准备好运行。
|
从 |
Informix 连接器配置示例
以下示例显示了一个连接器实例的配置,该实例捕获来自端口 9088、位于 192.168.99.100 的 Informix 服务器(逻辑名称为 fullfillment)的数据。通常,您通过设置连接器可用的配置属性来以 JSON 文件形式配置 Debezium Informix 连接器。
您可以选择为数据库中的模式和表的子集生成事件。可选地,您可以忽略、掩盖或截断包含敏感数据、大于指定大小或您不需要的列。
{
"name": "informix-connector", (1)
"config": {
"connector.class": "io.debezium.connector.informix.InformixConnector", (2)
"database.hostname": "192.168.99.100", (3)
"database.port": "9088", (4)
"database.user": "informix", (5)
"database.password": "in4mix", (6)
"database.dbname": "mydatabase", (7)
"topic.prefix": "fullfillment", (8)
"table.include.list": "mydatabase.myschema.customers", (9)
"schema.history.internal.kafka.bootstrap.servers": "kafka:9092", (10)
"schema.history.internal.kafka.topic": "schemahistory.fullfillment" (11)
}
}
| 1 | 连接器在 Kafka Connect 服务中注册时的名称。 |
| 2 | 此 Informix 连接器类的名称。 |
| 3 | Informix 实例的地址。 |
| 4 | Informix 实例的端口号。 |
| 5 | Informix 用户的名称。 |
| 6 | Informix 用户的密码。 |
| 7 | 要从中捕获更改的数据库名称。 |
| 8 | Informix 实例/集群的逻辑名称,它形成一个命名空间,并在连接器写入的所有 Kafka 主题名称、Kafka Connect 模式名称以及使用Avro 连接器时对应的 Avro 模式的命名空间中 all used。 |
| 9 | Debezium 要捕获其更改的所有表的列表。 |
| 10 | 此连接器用于读取和恢复 DDL 语句到数据库模式历史主题的 Kafka 代理列表。 |
| 11 | 连接器读取和恢复 DDL 语句的数据库模式历史主题的名称。此主题仅供内部使用,使用者不应使用。 |
有关您可以为 Debezium Informix 连接器设置的配置属性的完整列表,请参阅 Informix 连接器属性。
您可以使用 POST 命令将此配置发送到正在运行的 Kafka Connect 服务。该服务会记录配置并启动一个连接器任务,该任务执行以下操作:
-
连接到 Informix 数据库。
-
读取处于捕获模式的表的更改数据表。
-
将更改事件记录流式传输到 Kafka 主题。
添加连接器配置
要开始运行 Informix 连接器,请创建连接器配置并将其添加到您的 Kafka Connect 集群。
-
Informix 复制已启用,为处于捕获模式的表公开更改数据。
-
Informix 连接器已安装。
-
为 Informix 连接器创建配置。
-
使用Kafka Connect REST API 将该连接器配置添加到您的 Kafka Connect 群集。
连接器启动后,它会执行 Informix 数据库表中连接器配置为捕获更改的表的 istent snapshot。然后,连接器开始生成行级操作的数据更改事件,并将更改事件记录流式传输到 Kafka 主题。
连接器属性
Debezium Informix 连接器有许多配置属性,您可以使用它们来实现适合您应用程序的正确连接器行为。许多属性都有默认值。有关属性的信息组织如下:
-
数据库模式历史连接器配置属性,用于控制 Debezium 如何处理从数据库模式历史主题读取的事件。
必需的 Debezium Informix 连接器配置属性
以下配置属性是必需的,除非有默认值可用。
| 属性 | Default (默认值) | 描述 | ||
|---|---|---|---|---|
无默认值 |
连接器的唯一名称。您只能注册一次指定名称的连接器。后续尝试将导致失败。所有 Kafka Connect 连接器都需要此属性。 |
|||
无默认值 |
连接器的 Java 类名称。对于 Informix 连接器,始终使用值 |
|||
|
此连接器可以创建的最大任务数。Informix 连接器始终使用单个任务,因此不使用此值,所以默认值始终是可接受的。 |
|||
无默认值 |
Informix 数据库服务器的 IP 地址或主机名。 |
|||
|
Informix 数据库服务器的整数端口号。 |
|||
无默认值 |
用于连接 Informix 数据库服务器的 Informix 数据库用户名。 |
|||
无默认值 |
连接到 Informix 数据库服务器时使用的密码。 |
|||
无默认值 |
要从中流式传输更改的 Informix 数据库的名称。 |
|||
无默认值 |
主题前缀,为 Debezium 正在捕获其更改的数据库所在的特定 Informix 数据库服务器提供命名空间。主题前缀名称只能使用字母数字字符、连字符、点和下划线。主题前缀用于接收来自此连接器的记录的所有 Kafka 主题。指定一个在 Kafka Connect 部署中的所有连接器之间唯一的名称。
|
|||
无默认值 |
一个可选的、逗号分隔的正则表达式列表,匹配要捕获其更改的表的完全限定表标识符。设置此属性后,连接器仅捕获指定表的更改。每个标识符的形式为 databaseName.schemaName.tableName。默认情况下,连接器捕获每个非系统表的更改。 要匹配表名,Debezium 会将您指定的正则表达式用作*锚定*正则表达式。也就是说,指定的表达式会与表的整个名称字符串进行匹配,而不是匹配表名中可能存在的子字符串。 |
|||
无默认值 |
一个可选的、逗号分隔的正则表达式列表,匹配您不希望连接器捕获其更改的表的完全限定表标识符。连接器捕获排除列表中未包含的每个非系统表的更改。每个标识符的形式为 databaseName.schemaName.tableName。 要匹配表名,Debezium 会将您指定的正则表达式用作*锚定*正则表达式。也就是说,指定的表达式会与表的整个名称字符串进行匹配,而不是匹配表名中可能存在的子字符串。 |
|||
空字符串 |
一个可选的、逗号分隔的正则表达式列表,匹配要包含在更改事件记录值中的列的完全限定名称。列的完全限定名称遵循以下格式之一:databaseName.tableName.columnName,或 databaseName.schemaName.tableName.columnName。 为了匹配 «列» 的名称,Debezium 将您指定的 «正则表达式» 应用为*锚定的* «正则表达式»。也就是说,指定的表达式会针对 «列» 的整个名称字符串进行匹配;它不会匹配可能存在于 «列» 名称中的子字符串。如果在此属性中包含此属性,请不要同时设置 |
|||
空字符串 |
一个可选的、逗号分隔的正则表达式列表,匹配要从更改事件值中排除的列的完全限定名称。列的完全限定名称遵循以下格式之一:databaseName.tableName.columnName,或 databaseName.schemaName.tableName.columnName。 要匹配列名,Debezium 会将您指定的正则表达式应用为锚定正则表达式。也就是说,指定的表达式与列的整个名称字符串匹配;它不匹配可能存在于列名中的子字符串。在生成的更改事件记录中,指定列的值将被替换为别名。 |
|||
n/a |
一个可选的、逗号分隔的正则表达式列表,匹配基于字符的列的完全限定名称。列的完全限定名称遵循以下格式之一:databaseName.tableName.columnName,或 databaseName.schemaName.tableName.columnName。 假名由应用指定的hashAlgorithm 和salt 产生的哈希值组成。根据使用的哈希函数,可以维护引用完整性,同时用假名替换列值。支持的哈希函数在 Java Cryptography Architecture 标准算法名称文档的MessageDigest 部分中进行了描述。 column.mask.hash.SHA-256.with.salt.CzQMA0cB5K = inventory.orders.customerName, inventory.shipment.customerName 如果需要,假名会自动截断为列的长度。连接器配置可以包含多个指定不同哈希算法和 salt 的属性。 |
|||
|
指定连接器用于表示时间、日期和时间戳值的数字精度。 |
|||
|
指定一个delete 事件后是否跟一个墓碑事件。 |
|||
|
一个布尔值,指定连接器是否将数据库模式中的更改发布到与主题前缀同名的 Kafka 主题。连接器将每个模式更改记录下来,键包含数据库名称,值为描述模式更新的 JSON 结构。此记录模式更改的机制独立于连接器对数据库模式历史记录更改的内部记录。 |
|||
n/a |
一个可选的、逗号分隔的正则表达式列表,匹配基于字符的列的完全限定名称。如果您希望在列数据超过属性名称中由 length 指定的字符数时截断这些列中的数据,请设置此属性。将 «列» 的 «完全限定» 名称遵循以下格式之一:databaseName.tableName.columnName,或 databaseName.schemaName.tableName.columnName。 您可以在单个配置中指定多个具有不同长度的属性。 |
|||
n/a |
一个可选的、逗号分隔的正则表达式列表,匹配基于字符的列的完全限定名称。如果您希望连接器掩盖一组列的值,请设置此属性(例如,如果它们包含敏感数据)。将 «列» 的 «完全限定» 名称遵循以下格式之一:databaseName.tableName.columnName,或 databaseName.schemaName.tableName.columnName。 您可以在单个配置中指定多个具有不同长度的属性。 |
|||
n/a |
一个可选的、逗号分隔的正则表达式列表,匹配您希望连接器为其发出表示列元数据的额外参数的列的完全限定名称。设置此属性时,连接器会将以下字段添加到事件记录的模式中:
这些参数分别传播列的原始类型名称和长度(对于可变宽度类型)。 «列» 的 «完全限定» 名称遵循以下格式之一:databaseName.tableName.columnName,或 databaseName.schemaName.tableName.columnName。 |
|||
n/a |
一个可选的、逗号分隔的 «正则表达式» 列表,用于指定数据库中 «列» 定义的 «数据类型» 的«完全限定»名称。设置此属性时,对于具有匹配 «数据类型» 的 «列»,连接器会发出包含以下额外字段的 «模式» 的事件记录:
这些参数会传播列原始数据类型的名称,以及可变宽度类型的长度和精度。 «列» 的 «完全限定» 名称遵循以下格式之一:databaseName.tableName.typeName,或 databaseName.schemaName.tableName.typeName。 有关 Informix 特定的数据类型名称列表,请参阅 Informix 数据类型映射。 |
|||
空字符串 |
«表达式» 列表,用于指定连接器用来为 «发布» 到指定表 «Kafka» «主题» 的更改事件 «记录» «形成» «自定义» «消息» «键» 的 «列»。 默认情况下,Debezium 使用表的 «主键» «列» 作为它发出的 «记录» 的 «消息» «键»。 «代替» 默认值,或为 «缺少» «主键» 的表指定 «键»,您可以根据一个或多个 «列» «配置» «自定义» «消息» «键»。
该 «属性» «可以» «列出» «多个» «表» 的 «条目»。使用 «分号» 来 «分隔» «列表» 中 «不同» «表» 的 «条目»。 |
|||
none |
指定如何调整模式名称以与连接器使用的消息转换器兼容。
|
|||
none |
指定如何调整字段名称以与连接器使用的消息转换器兼容。
有关 Avro 兼容性的更多信息,请参阅 Avro 命名。 |
高级连接器配置属性
以下*高级*配置属性的默认值在大多数情况下都适用,因此很少需要在连接器的配置中指定。
| 属性 | Default (默认值) | 描述 | ||
|---|---|---|---|---|
无默认值 |
枚举连接器可以使用*自定义转换器*的符号名称的逗号分隔列表。例如:
您必须设置 对于为连接器配置的每个转换器,您还必须添加一个
For example, (例如,) isbn.type: io.debezium.test.IsbnConverter 如果您想进一步控制已配置转换器的行为,您可以添加一个或多个配置参数将值传递给转换器。要将任何额外的配置参数与转换器关联,请在参数名称前加上转换器的 «符号名称»。 isbn.schema.name: io.debezium.informix.type.Isbn |
|||
initial (初始) |
指定连接器启动时执行快照的 «标准»。
有关更多信息,请参阅自定义快照程序 SPI。 |
|||
false |
如果 |
|||
false |
如果 |
|||
false |
如果 |
|||
false |
如果 |
|||
false |
如果 |
|||
无默认值 |
如果 |
|||
exclusive |
控制连接器是否以及锁定表多长时间。表锁可防止其他数据库客户端在快照期间执行某些表操作。您可以设置以下值:
|
|||
无默认值 |
当 |
|||
|
指定连接器在执行快照时如何查询数据。
与使用 |
|||
无默认值 |
当 |
|||
|
在快照期间,指定事务隔离级别以及连接器锁定处于捕获模式的表的时间长度。指定以下值之一:
|
|||
|
一个正整数值,指定对变更流客户端的读取调用的超时行为。
|
|||
|
一个正整数值,指定 Informix Change Stream Client 处理的每批记录的最大大小。 |
|||
|
一个布尔值,用于指定当流关闭时 Informix 是否应停止对已监视表的完整行日志记录。 |
|||
|
指定连接器在处理事件时如何处理异常。
|
|||
|
一个正整数值,用于指定在连接器开始处理一批事件之前等待新更改事件出现的时间(以毫秒为单位)。 |
|||
|
一个正整数值,指定连接器处理的每个事件批次的最大大小。 |
|||
|
一个正整数值,用于指定阻塞队列可以容纳的最大记录数。当 Debezium 读取从数据库流式传输的事件时,它会将事件放入阻塞队列,然后再写入 Kafka。在连接器提取消息的速度快于其写入 Kafka 的速度,或者 Kafka 不可用时,阻塞队列可以为从数据库读取更改事件提供反压。当连接器定期记录偏移量时,队列中保存的事件将被忽略。始终将 |
|||
|
一个长整数值,指定阻塞队列的最大字节容量。默认情况下,阻塞队列没有容量限制。要指定队列可以消耗的字节数,请将此属性设置为一个正长整型值。 |
|||
|
控制连接器向 Kafka 主题发送心跳消息的频率。默认行为是连接器不发送心跳消息。 |
|||
无默认值 |
指定连接器在发送心跳消息时在源数据库上执行的查询。 |
|||
无默认值 |
连接器在开始执行快照之前应等待的间隔(以毫秒为单位)。如果要在一组连接器中启动多个连接器,此属性对于避免快照中断(这可能导致连接器重新平衡)非常有用。 |
|||
0 |
指定连接器在完成快照后延迟开始流式传输过程的时间(以毫秒为单位)。设置延迟间隔有助于防止连接器在快照完成后但流式传输过程开始之前立即发生故障时重新启动快照。设置一个高于 Kafka Connect 工作节点设置的 |
|||
|
一个可选的、逗号分隔的正则表达式列表,用于匹配要包含在快照中的表的完全限定名称( 为了匹配表名,Debezium 会将您指定的正则表达式应用为锚定正则表达式。也就是说,指定的表达式会与表的整个名称字符串进行匹配;它不会匹配表中可能存在的子字符串。 |
|||
|
在快照期间,连接器以行批次的形式读取表内容。此属性指定批次中的最大行数。 |
|||
|
指定在执行快照时等待获取表锁的最大时间(以毫秒为单位)。如果在该时间间隔内连接器无法获取表锁,则快照将失败。有关更多信息,请参阅 连接器如何执行快照。
|
|||
无默认值 |
指定要包含在快照中的表行。如果您希望快照仅包含表中的一部分行,请使用此属性。此属性仅影响快照。它不适用于连接器在流式传输阶段从日志中读取的事件。 该属性包含一个逗号分隔的完全限定表名列表,格式为 从包含软删除列 "snapshot.select.statement.overrides": "mydatabase.customer.orders", "snapshot.select.statement.overrides.mydatabase.customer.orders": "SELECT * FROM customers.orders WHERE delete_flag = 0 ORDER BY id DESC" 在生成的快照中,连接器仅包含 |
|||
|
确定连接器是否生成带有事务边界的事件,以及是否在更改事件信封中丰富事务元数据。如果您希望连接器执行这些操作,请将值设置为 |
|||
|
在流式传输期间连接器跳过的操作类型的逗号分隔列表。您可以指定以下值
|
|||
无默认值 |
用于将信号发送到连接器的数据集合的完全限定名称。使用以下格式指定集合名称: |
|||
|
为连接器启用的信号通道名称列表。默认情况下,以下通道可用:
|
|||
无默认值 |
为连接器启用的通知通道名称列表。默认情况下,以下通道可用:
|
|||
|
在增量快照块期间,连接器获取并加载到内存中的最大行数。增加块大小可以提高效率,因为快照运行的快照查询次数较少但规模更大。但是,较大的块大小也需要更多内存来缓冲快照数据。将块大小调整为能为您的环境提供最佳性能的值。 |
|||
|
指定连接器在增量快照期间使用的水印机制,用于对可能被增量快照捕获,然后在流式传输恢复后重新捕获的事件进行去重。
|
|||
|
连接器用于构造数据更改、模式更改、事务、心跳和其他类型事件的主题名称的 |
|||
|
指定连接器用于构造主题名称的分隔符。 |
|||
|
为在有界并发哈希映射中存储主题名称而分配的缓存大小。此缓存有助于确定与给定数据集合对应的主题名称。 |
|||
|
指定一个字符串,连接器将其附加到它发送心跳消息的主题名称。主题名称具有以下模式 |
|||
|
指定一个字符串,连接器将其附加到它发送事务元数据消息的主题名称。主题名称具有以下模式 |
|||
|
指定连接器在执行初始快照时使用的最大线程数。要启用并行初始快照,请将此属性设置为大于 1 的值。在并行初始快照中,连接器会并行处理多个表。此功能处于孵化阶段。 |
|||
|
定义用于通过添加提供上下文信息的元数据来定制 MBean 对象名称的标签。指定键值对的逗号分隔列表。每个键代表 MBean 对象名称的标签,对应的值代表该键的值,例如: 连接器会将指定的标签附加到基本 MBean 对象名称。标签可以帮助您组织和分类指标数据。您可以定义标签来识别特定的应用程序实例、环境、区域、版本等。有关更多信息,请参阅 定制 MBean 名称。 |
|||
|
在失败之前,对可重试错误(例如连接错误)的最大重试次数(-1 = 无限制,0 = 禁用,> 0 = 重试次数)。 |
|||
|
指定连接器等待查询完成的时间(以毫秒为单位)。将值设置为 |
|||
true |
此属性指定 Debezium 是否将带有 这些头是 OpenLineage 集成所必需的,并提供元数据,使下游处理系统能够跟踪和识别更改事件的来源。 该属性添加了以下头:
|
Debezium 连接器数据库模式历史配置属性
Debezium 提供了一组 schema.history.internal.* 属性来控制连接器如何与模式历史记录主题进行交互。
下表描述了用于配置 Debezium 连接器的 schema.history.internal 属性。
| 属性 | Default (默认值) | 描述 |
|---|---|---|
无默认值 |
连接器存储数据库模式历史的 Kafka 主题的完整名称。 |
|
无默认值 |
连接器用于建立与 Kafka 集群的初始连接的主机/端口对列表。此连接用于检索连接器先前存储的数据库模式历史,以及写入从源数据库读取的每个 DDL 语句。每个对都应指向 Kafka Connect 进程使用的相同 Kafka 集群。 |
|
|
一个整数值,指定连接器在启动/恢复期间轮询持久数据时应等待的最大毫秒数。默认为 100 毫秒。 |
|
|
一个整数值,指定连接器在使用 Kafka 管理客户端获取集群信息时应等待的最大毫秒数。 |
|
|
一个整数值,指定连接器在使用 Kafka 管理客户端创建 Kafka 历史主题时应等待的最大毫秒数。 |
|
|
连接器在连接器恢复因错误而失败之前尝试读取持久历史数据的最大次数。在收到无数据后的最长等待时间为 |
|
|
一个布尔值,指定连接器是应忽略格式错误或未知的数据库语句,还是停止处理以便人工修复问题。安全默认值为 |
|
|
一个布尔值,指定连接器是记录模式或数据库中所有表的模式结构,还是仅记录指定用于捕获的表的模式结构。
|
|
|
一个布尔值,指定连接器是记录实例中所有逻辑数据库的模式结构。
|
直通式 Informix 连接器配置属性
该连接器支持直通式属性,使 Debezium 能够为微调 Apache Kafka 生产者和消费者行为指定自定义配置选项。有关 Kafka 生产者和消费者配置属性的完整范围,请参阅 Kafka 文档。
用于配置生产者和使用者客户端如何与模式历史记录主题交互的直通式属性
Debezium 依赖 Apache Kafka 生产者将模式更改写入数据库模式历史记录主题。同样,它依赖 Kafka 消费者在连接器启动时从数据库模式历史记录主题读取。您可以通过为一组以 schema.history.internal.producer.* 和 schema.history.internal.consumer.* 前缀开头的传递配置属性赋值来定义 Kafka 生产者和消费者客户端的配置。传递的生产者和消费者数据库模式历史记录属性控制一系列行为,例如这些客户端如何与 Kafka 代理建立安全连接,如下例所示:
schema.history.internal.producer.security.protocol=SSL
schema.history.internal.producer.ssl.keystore.location=/var/private/ssl/kafka.server.keystore.jks
schema.history.internal.producer.ssl.keystore.password=test1234
schema.history.internal.producer.ssl.truststore.location=/var/private/ssl/kafka.server.truststore.jks
schema.history.internal.producer.ssl.truststore.password=test1234
schema.history.internal.producer.ssl.key.password=test1234
schema.history.internal.consumer.security.protocol=SSL
schema.history.internal.consumer.ssl.keystore.location=/var/private/ssl/kafka.server.keystore.jks
schema.history.internal.consumer.ssl.keystore.password=test1234
schema.history.internal.consumer.ssl.truststore.location=/var/private/ssl/kafka.server.truststore.jks
schema.history.internal.consumer.ssl.truststore.password=test1234
schema.history.internal.consumer.ssl.key.password=test1234
Debezium 会从属性名称中剥离前缀,然后再将属性传递给 Kafka 客户端。
有关 Kafka 生产者配置属性 和 Kafka 消费者配置属性 的更多信息,请参阅 Apache Kafka 文档。
用于配置 Informix 连接器如何与 Kafka 信号主题交互的直通式属性
Debezium 提供了一组 signal.* 属性来控制连接器如何与 Kafka 信号主题交互。
下表描述了 Kafka signal 属性。
| 属性 | Default (默认值) | 描述 | ||
|---|---|---|---|---|
<topic.prefix>-signal |
连接器监视的用于临时信号的 Kafka 主题的名称。
|
|||
kafka-signal |
Kafka 消费者使用的组 ID 的名称。 |
|||
无默认值 |
连接器用于建立与 Kafka 集群的初始连接的主机和端口对列表。每个对都引用 Debezium Kafka Connect 进程使用的 Kafka 集群。 |
|||
|
一个整数值,指定连接器在轮询信号时等待的最大毫秒数。 |
用于配置信号通道的 Kafka 消费者客户端的直通式属性
Debezium 为信号 Kafka 消费者的传递配置提供了支持。传递信号属性以 signal.consumer.* 前缀开头。例如,连接器会将 signal.consumer.security.protocol=SSL 等属性传递给 Kafka 消费者。
Debezium 在将前缀从属性名称中剥离,然后再将属性传递给 Kafka 信号消费者。
用于配置 Informix 连接器接收器通知通道的直通式属性
下表描述了可用于配置 Debezium sink notification 通道的属性。
| 属性 | Default (默认值) | 描述 |
|---|---|---|
无默认值 |
接收来自 Debezium 的通知的主题名称。当您将 |
监控
Debezium Informix 连接器提供三种类型的指标,除了 Apache Kafka 和 Kafka Connect 提供的 JMX 指标内置支持之外。
Debezium 监控文档 提供了有关如何使用 JMX 公开这些指标的详细信息。
自定义 MBean 名称
Debezium 连接器通过连接器的 MBean 名称公开指标。这些指标特定于每个连接器实例,提供有关连接器快照、流式传输和模式历史记录进程行为的数据。
默认情况下,当您部署正确配置的连接器时,Debezium 会为不同的连接器指标生成唯一的 MBean 名称。要查看连接器进程的指标,请将您的可观察性堆栈配置为监视其 MBean。但这些默认 MBean 名称取决于连接器配置;配置更改可能导致 MBean 名称发生更改。在这种情况下,更改 MBean 名称会破坏连接器实例和 MBean 之间的链接,从而中断监控活动。您必须重新配置可观察性堆栈以使用新的 MBean 名称才能恢复监控。
为了防止因 MBean 名称更改而导致的监控中断,您可以配置自定义指标标签。通过将 custom.metric.tags 属性添加到连接器配置中来配置自定义指标。该属性接受键值对,其中每个键代表 MBean 对象名称的标签,相应的值代表该标签的值。例如:k1=v1,k2=v2。Debezium 将指定的标签附加到连接器的 MBean 名称。
配置连接器的 custom.metric.tags 属性后,您可以配置可观察性堆栈以检索与指定标签关联的指标。然后,可观察性堆栈使用指定的标签而不是可变的 MBean 名称来唯一标识连接器。之后,如果 Debezium 重新定义了其如何构造 MBean 名称,或者连接器配置中的 topic.prefix 发生更改,指标收集将不会中断,因为指标抓取任务使用指定的标签模式来标识连接器。
使用自定义标签的另一个好处是,您可以使用反映数据管道架构的标签,以便以适合您运营需求的方式组织指标。例如,您可以指定带有值的标签来声明连接器活动的类型、应用程序上下文或数据源,例如 db1-streaming-for-application-abc。如果您指定多个键值对,所有指定的对都将附加到连接器的 MBean 名称。
以下示例说明了标签如何修改默认 MBean 名称。
默认情况下,Informix 连接器使用以下 MBean 名称进行流式传输指标
debezium.informix:type=connector-metrics,context=streaming,server=<topic.prefix>
如果您将 custom.metric.tags 的值设置为 database=salesdb-streaming,table=inventory,Debezium 将生成以下自定义 MBean 名称:
debezium.informix:type=connector-metrics,context=streaming,server=<topic.prefix>,database=salesdb-streaming,table=inventory
快照指标
MBean 是 debezium.informix:type=connector-metrics,context=snapshot,server=<topic.prefix>。
除非快照操作正在活动中,或者自上次连接器启动以来发生过快照,否则快照指标不会暴露。
下表列出了可用的快照指标。
| Attributes | Type | 描述 |
|---|---|---|
|
连接器已读取的最后一个快照事件。 |
|
|
自连接器读取和处理最近事件以来经过的毫秒数。 |
|
|
记录连接器在快照操作期间识别为错误的更改事件的数量。每次连接器在初始、增量或临时快照期间遇到无法处理的事件时,都会递增此指标。事件可能因格式错误、与模式不兼容或在转换期间遇到失败而无法处理。指标值在连接器任务的整个生命周期内保持不变。如果快照被中断,并且连接器任务重新启动,则指标计数将重置为 |
|
|
自上次启动或重置以来,此连接器已看到的事件总数。 |
|
|
已被连接器配置的包含/排除列表过滤规则过滤的事件数量。 |
|
|
由连接器捕获的表列表。 |
|
|
用于在快照程序和主 Kafka Connect 循环之间传递事件的队列的长度。 |
|
|
用于在快照程序和主 Kafka Connect 循环之间传递事件的队列的可用容量。 |
|
|
包含在快照中的表总数。 |
|
|
快照尚未复制的表数。 |
|
|
快照是否已启动。 |
|
|
快照是否已暂停。 |
|
|
快照是否被中止。 |
|
|
快照是否已完成。 |
|
|
快照是否被跳过。 |
|
|
快照到目前为止所花费的总秒数,即使未完成。也包括快照暂停的时间。 |
|
|
快照暂停的总秒数。如果快照被暂停了多次,则暂停时间将累加。 |
|
|
包含快照中每个表扫描的行数的映射。表在处理过程中被增量地添加到 Map 中。每扫描 10,000 行和完成一个表时更新。 |
|
|
队列的最大缓冲区(以字节为单位)。如果 |
|
|
队列中记录的当前字节卷。 |
当执行增量快照时,连接器还提供以下附加快照指标:
| Attributes | Type | 描述 |
|---|---|---|
|
当前快照块的标识符。 |
|
|
定义当前块的主键集的下限。 |
|
|
定义当前块的主键集的上限。 |
|
|
当前快照表的组成键集(主键)的下限。 |
|
|
当前快照表的组成键集(主键)的上限。 |
流式传输指标
MBean 是 debezium.informix:type=connector-metrics,context=streaming,server=<topic.prefix>。
下表列出了可用的流式传输指标。
| Attributes | Type | 描述 |
|---|---|---|
|
连接器已读取的最后一个流式传输事件。 |
|
|
自连接器读取和处理最近事件以来经过的毫秒数。 |
|
|
记录连接器在流式传输期间识别为错误的更改事件的数量。每次连接器在流式传输会话期间遇到无法处理的事件时,都会递增此指标。事件可能因格式错误、与模式不兼容或在转换期间遇到失败而无法处理。指标值在连接器任务的整个生命周期内保持不变。连接器重启后,指标计数将重置为 |
|
|
自上次连接器启动或重置以来,源数据库报告的总数据更改事件数。代表 Debezium 需要处理的数据更改工作负载。 |
|
|
自上次启动或重置指标以来,连接器处理的总创建事件数。 |
|
|
自上次启动或重置指标以来,连接器处理的总更新事件数。 |
|
|
自上次启动或重置指标以来,连接器处理的总删除事件数。 |
|
|
已被连接器配置的包含/排除列表过滤规则过滤的事件数量。 |
|
|
由连接器捕获的表列表。 |
|
|
用于在流式传输器和主 Kafka Connect 循环之间传递事件的队列的长度。 |
|
|
用于在流式传输器和主 Kafka Connect 循环之间传递事件的队列的剩余容量。 |
|
|
表示连接器当前是否连接到数据库服务器的标志。 |
|
|
上次更改事件的时间戳与连接器处理它之间的时间差(以毫秒为单位)。这些值将包含数据库服务器和连接器运行所在机器之间时钟的任何差异。 |
|
|
已提交的处理过的事务数。 |
|
|
收到的最后一个事件的坐标。 |
|
|
已处理的最后一个事务的事务标识符。 |
|
|
队列的最大缓冲区(以字节为单位)。如果 |
|
|
队列中记录的当前字节卷。 |