简体   繁体   English

为数据库中的多个表配置 debezium 连接器

[英]Configure a debezium connector for multiple tables in a database

I'm trying to configure a Debezium connector for multiple tables in a MySQL database (i'm using debezium 1.4 on a MySQL 8.0).我正在尝试为 MySQL 数据库中的多个表配置 Debezium 连接器(我在 MySQL 8.0 上使用 debezium 1.4)。 My company have a nomenclature pattern to follow when creating topics in kafka, and this pattern does not allow the use of underscores (_), so I had to replace them with hyphens (-)在kafka中创建主题时,我的公司有一个命名模式要遵循,并且这种模式不允许使用下划线(_),所以我不得不用连字符(-)替换它们

So, my topics names are:所以,我的主题名称是:

Topic 1话题一

fjf.db.top-domain.domain.sub-domain.transaction-search.order-status
WHERE
- transaction-search = schema "transaction_search"
- order-status = table "order_status". 
- All changes in that table, must go to that topic.

Topic 2话题二

fjf.db.top-domain.domain.sub-domain.transaction-search.shipping-tracking
WHERE
- transaction-search = schema "transaction_search"
- shipping-tracking = table "shipping_tracking"
- All changes in that table, must go to that topic.

Topic 3话题 3

fjf.db.top-domain.domain.sub-domain.transaction-search.proposal
WHERE
- transaction-search = schema "transaction_search"
- proposal = table "proposal"
- All changes in that table, must go to that topic.

I'm trying to use the transforms "ByLogicalTableRouter", but i can't find a regex solution that solve my case.我正在尝试使用转换“ByLogicalTableRouter”,但我找不到解决我的情况的正则表达式解决方案。

{ "name": "debezium.connector",
 "config":
    { 
"connector.class": "io.debezium.connector.mysql.MySqlConnector",
"tasks.max": "1",
"database.hostname": "myhostname",
"database.port": "3306",
"database.user": "debezium", 
"database.password": "password", 
"database.server.id": "1000", 
"database.server.name": "fjf.db.top-domain.domain.sub-domain.transaction-search",
"schema.include.list": "transaction_search",
"table.include.list": "transaction_search.order_status,transaction_search.shipping_tracking,transaction_search.proposal",
"database.history.kafka.bootstrap.servers": "kafka.intranet:9097",
"database.history.kafka.topic": "fjf.db.top-domain.domain.sub-domain.transaction-search.schema-history",
"snapshot.mode": "schema_only",
"transforms":"RerouteName,RerouteUnderscore",
"transforms.RerouteName.type":"io.debezium.transforms.ByLogicalTableRouter",
"transforms.RerouteName.topic.regex":"(.*)transaction_search(.*)",
"transforms.RerouteName.topic.replacement": "$1$2" 
"transforms.RerouteUnderscore.type":"io.debezium.transforms.ByLogicalTableRouter",
"transforms.RerouteUnderscore.topic.regex":"(.*)_(.*)",
"transforms.RerouteUnderscore.topic.replacement": "$1-$2" 
    }
}
  • In the first transforms,im trying to remove the duplicated schema name in the topic routering.在第一次转换中,我试图删除主题路由中重复的模式名称。
  • In the second transforms, to replace all remains underscores _ for hiphens -在第二个变换中,替换所有剩余的下划线 _ 代表 hiphens -

But with that, I'm getting the error below, which indicates that it is trying to send everything to the same topic但是有了这个,我得到了下面的错误,这表明它正在尝试将所有内容发送到同一个主题

Caused by: org.apache.kafka.connect.errors.SchemaBuilderException: Cannot create field because of field name duplication __dbz__physicalTableIdentifier

How can i make a transform that will forward the events of each table to their respective topic?如何进行转换,将每个表的事件转发到各自的主题?

  1. Removing the schema name删除架构名称

In the first transforms,im trying to remove the duplicated schema name in the topic routering.在第一次转换中,我试图删除主题路由中重复的模式名称。

After transforamtion with your regex you'll have two dots, so you need to fix it:使用正则表达式进行转换后,您将有两个点,因此您需要修复它:

"transforms.RerouteName.topic.regex":"([^.]+)\\.transaction_search\\.([^.]+)",
"transforms.RerouteName.topic.replacement": "$1.$2" 
  1. Replace underscores for hiphens替换下划线

You can try to use ChangeCase SMT from Kafka Connect Common Transformations .您可以尝试使用来自Kafka Connect Common TransformationsChangeCase SMT。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将包含数据的新表包含到现有 Debezium 连接器中 - Include new tables with data to existing Debezium connector 一个 Mysql DB 的多个 debezium 连接器 - Multiple debezium connector for one Mysql DB 在 Debezium Mysql 连接器中将更多表列入白名单的有效方法 - Efficient ways for whitelisting more tables in Debezium Mysql Connector 配置debezium连接器以读取没有任何部分数据的mysql二进制日志 - Configure debezium connector to read mysql binary logs without any partial data 如何配置Debezium Mysql连接器以生成原始密钥而不是struct或json对象? - How to configure Debezium Mysql connector to produce primitive key instead of struct or json object? 基于Kafka Debezium mysql连接器的主题:对于ksql流和表,所有列值都以'null'结尾 - Kafka debezium mysql connector-based topic: For ksql streams and tables, all column values end up 'null' 无法在 GKE 上部署 mysql debezium 连接器 - 用户没有“锁定表”权限 - Unable to deploy mysql debezium connector on GKE - User does not have the 'LOCK TABLES' privileges Debezium - 自定义负载 - MySQL 连接器 - Debezium - Custom Payload - MySQL Connector 无法在 debezium 连接器上生成过滤器 - Failing to generate a filter on debezium connector Debezium 连接器 - 通信链路故障 - Debezium Connector - Communication link failure
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM