Debezium自动创建Topic分组功能未生效,求助排查
Debezium Topic Creation Group 配置失效问题排查
我用Confluent管理Debezium连接器实现CDC,尝试通过Debezium提供的topic creation group功能,按表的大小自动创建对应配置的Topic,配置如下:
{ "name": "sample_connector_name", "topic.prefix": "sample_connector_prefix", "database.dbname": "servicedb", "snapshot.mode": "schema_only", "snapshot.locking.mode": "none", "signal.enabled.channels": "source", "signal.data.collection": "servicedb.debezium_signal", "incremental.snapshot.allow.schema.changes": "true", "incremental.snapshot.chunk.size": 1024, "tombstones.on.delete": "true", "database.ssl.mode": "preferred", "poll.interval.ms": "1000", "max.batch.size": "1000", "output.data.format": "AVRO", "topic.creation.enable": "true", "topic.creation.default.partitions": 1, "topic.creation.default.replication.factor": -1, "topic.creation.groups": "small,medium", "topic.creation.small.retention.ms": 432000000, "topic.creation.small.include": "sample_connector_prefix.servicedb.users", "topic.creation.medium.retention.ms": 86400000, "topic.creation.medium.include": "sample_connector_prefix.servicedb.orders,sample_connector_prefix.servicedb.cities", "tasks.max": "1", "status": "RUNNING" }
预期结果
- 属于small组的
sample_connector_prefix.servicedb.users,保留时间为432000000ms(5天); - 属于medium组的
sample_connector_prefix.servicedb.orders和sample_connector_prefix.servicedb.cities,保留时间为86400000ms(1天); - 其余表的Topic使用集群默认保留时间(7天)。
实际问题
Debezium忽略了small和medium组下的所有Topic,仅创建了未列入分组的Topic。
可能的问题原因
1. Topic名称匹配规则错误
Debezium的topic.creation.<group>.include配置要求使用正则表达式,而非精确字符串匹配。你当前写的是完整Topic名,正则匹配逻辑不会生效,导致分组配置被忽略。
修正示例:
- 将
topic.creation.small.include改为:"^sample_connector_prefix\\.servicedb\\.users$" - 将
topic.creation.medium.include改为:"^sample_connector_prefix\\.servicedb\\.(orders|cities)$"
注意:JSON中需要用\\.转义正则里的.,避免被当作通配符解析。
2. Debezium版本不兼容
Topic creation group是Debezium 1.7及以上版本才新增的特性,如果你使用的版本低于1.7,该配置会直接被忽略。检查连接器版本是否符合要求。
3. 预存在的Topic导致配置不生效
如果分组内的Topic在连接器启动前就已经存在,Debezium不会修改现有Topic的配置。需要先删除这些已存在的Topic,再重启连接器让它重新创建并应用分组规则。
4. 配置参数格式问题
- 确认
topic.creation.groups的取值无多余空格(当前配置"small,medium"是正确的); topic.creation.default.replication.factor设为-1表示使用集群默认,但部分Confluent环境可能对该值解析异常,可尝试改为具体数值(比如3)测试。
5. 权限不足
检查Debezium连接器使用的Kafka账号是否具备以下权限:
- 创建Topic的权限;
- 修改Topic配置(如
retention.ms)的权限。
权限不足时,连接器会静默跳过分组内的Topic创建流程。
内容的提问来源于stack exchange,提问作者ljuk
相关产品推荐
相关产品推荐

