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

Debezium/Kafka Connect无法导出本地MySQL表快照数据

问题根因

核心配置错误:本地Debezium连接器参数填写不符合规则,你将表名写入了仅支持匹配数据库名的database.include.list参数中,该参数不识别库名.表名格式,导致Debezium无法匹配到任何待采集表,最终出现快照0表的问题。
对比两套配置的差异可以直接定位问题:

  • 正常运行的云环境连接器:"database.include.list": "testDB" 仅填写数据库名,符合参数规则
  • 异常的本地连接器:"database.include.list": "testdb.Persons" 填写库.表格式,Debezium找不到名为testdb.Persons的数据库,匹配结果为空
修复方案
  1. 调整本地连接器配置:
    • 将database.include.list的值改为仅保留数据库名:"database.include.list": "testdb"
    • 新增table.include.list参数指定要采集的目标表:"table.include.list": "testdb.Persons"
  2. 删除原有异常连接器,重新提交修正后的配置即可。

修正后的注册curl命令参考:

curl -i -X POST -H "Accept:application/json" \
-H "Content-Type:application/json" localhost:8083/connectors/ \
-d '{ 
  "name": "local-mysql-test-connector", 
  "config": { 
    "connector.class": "io.debezium.connector.mysql.MySqlConnector", 
    "tasks.max": "1", 
    "database.hostname": "host.docker.internal",
    "database.port": "3306", 
    "database.user": "test", 
    "database.password": "test", 
    "database.server.id": "100",
    "database.server.name": "local_mysql", 
    "database.include.list": "testdb",
    "table.include.list": "testdb.Persons",
    "database.history.kafka.bootstrap.servers": "kafka:9092",
    "database.history.kafka.topic": "dbhistory.mysql" 
  } 
}'
补充排查点

如果修正配置后仍存在问题,依次检查以下两项:

  • 确认本地MySQL挂载的custom-config.cnf已开启binlog,binlog格式为ROW,且配置的MySQL server-id与Debezium连接器中填写的database.server.id不重复
  • 确认test用户对testdb.Persons表拥有SELECT权限,之前仅授予了复制相关权限,缺少表读权限也会导致快照无法读取表数据,缺失权限可执行以下SQL补充:
GRANT SELECT ON testdb.Persons TO 'test'@'%';
FLUSH PRIVILEGES;

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.28 06:30:54