You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Debezium Connector无法跟踪本地MySQL数据库变更问题求助

问题诊断与修复方案

你的Debezium连接器无法捕获MySQL数据变更、目标主题无消息,核心原因是配置里存在拼写错误、格式错误和配置冲突,具体问题及修复如下:

1. 致命拼写/格式错误

  • schema.history.internal.kafka.boostrap.servers:boostrap拼写错误,正确应为bootstrap
  • schema.history,internal.kafka.topic:逗号,internal错误,正确应为点号.internal
  • table.include.list:格式不符合要求,Debezium要求该参数值为数据库名.表名,你只写了test_table,需改为mysql_test.test_table

2. 配置冲突问题

你同时配置了两种数据库历史存储方式:

  • 文件存储:debezium.source.database.history及对应文件路径配置
  • Kafka存储:database.history.kafka.topic及database.history.kafka.bootstrap.servers

Debezium仅支持一种历史存储方式,建议保留Kafka存储(更适配集群场景),移除所有文件存储相关配置。

3. 其他潜在风险

  • database.server.id:值为1可能被本地MySQL实例占用(MySQL默认server-id常设为1),建议改为100-1000区间的唯一值,比如101
  • Kafka自动创建主题:确保Kafka集群的auto.create.topics.enable参数设为true,否则连接器无法自动生成数据变更主题

修正后的完整配置

{
    "name": "debezium-local-test-connector",
    "config": {
        "connector.class": "io.debezium.connector.mysql.MySqlConnector",
        "database.hostname": "localhost",
        "database.port": "3306",
        "database.user": "kafka",
        "database.password": "thepassword",
        "database.server.id": "101",
        "topic.prefix": "mysql_test",
        "table.include.list": "mysql_test.test_table",
        "schema.history.internal.kafka.bootstrap.servers": "10.4.90.30:9092",
        "schema.history.internal.kafka.topic": "schemahistory.mysql_test",
        "include.schema.changes": "true",
        "database.connectionTimeZone": "Europe/Rome"
    }
}

额外验证步骤

  1. 检查MySQL binlog状态:确认配置文件(my.cnf/my.ini)中log_bin=ON、binlog_format=ROW,且server-id为非1的唯一值
  2. 确认MySQL用户权限:kafka用户需拥有REPLICATION SLAVE、REPLICATION CLIENT权限,以及mysql_test库和test_table表的读写权限
  3. 重启连接器:删除原有连接器,用修正后的配置重新创建,查看连接器日志是否有报错
  4. 验证主题生成:插入测试数据后,检查Kafka是否生成mysql_test.mysql_test.test_table主题(格式为topic.prefix.数据库名.表名)

内容的提问来源于stack exchange,提问作者grizzo

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.08 20:38:22