配置table.include.list的Debezium嵌入式连接器仍捕获其他表
配置信息
我配置了Debezium嵌入式引擎,预期仅捕获ftpc_fge.record_demo表的变更,配置代码如下:
Configuration config = Configuration.create() .with("name", "demo") .with("connector.class", OracleConnector.class.getName()) .with("database.hostname", "*****") .with("database.port", "1521") .with("database.user", "*****") .with("database.password", "*****") .with("database.server.name", "ftpc-fge-connector") .with("database.dbname", "mesfa") .with("schema.include.list","ftpc_fge") .with("table.include.list", "ftpc_fge.record_demo") .with("log.mining.strategy", "online_catalog") .with("decimal.handling.mode","string") .with("topic.prefix","ftpc-fge-cdc") .with("offset.storage", FileOffsetBackingStore.class.getName()) .with("offset.storage.file.filename","D:\\workspace\\site-portal\\extractor\\debezium-offset\\offset.dat") .with("database.history", "io.debezium.relational.history.FileDatabaseHistory") .with("database.history.file.filename", "D:\\workspace\\site-portal\\extractor\\debezium-offset\\history.dat") .with("schema.history.internal", "io.debezium.storage.file.history.FileSchemaHistory") .with("schema.history.internal.file.filename", "D:\\workspace\\site-portal\\extractor\\debezium-offset\\schemahistory.dat") .with("offset.flush.interval.ms","60000") .build();
问题现象
启动引擎后,控制台输出显示连接器正在捕获所有模式下的表,而非仅指定表:
2024-08-07 18:58:37 [debezium-oracleconnector-ftpc-fge-cdc-change-event-source-coordinator] INFO i.d.r.RelationalSnapshotChangeEventSource - Snapshot step 5 - Reading structure of captured tables
2024-08-07 18:58:37 [debezium-oracleconnector-ftpc-fge-cdc-change-event-source-coordinator] INFO i.d.c.o.OracleSnapshotChangeEventSource - All eligible tables schema should be captured, capturing: [ MESFA.FTPC_ADAYO.AA_FORD_GAP_CHECKLIST, MESFA.FTPC_ADAYO.AA_FORD_GLUE_CHECKLIST, MESFA.FTPC_ADAYO.AA_FORD_MATURINGRECORD, MESFA.FTPC_ADAYO.AA_FORD_SCALE_MAIN, MESFA.FTPC_ADAYO.AA_FORD_SCREW_CHECKLIST, MESFA.FTPC_ADAYO.AA_FOTON_AUTH_CODE, MESFA.FTPC_ADAYO.AA_INCOMMING_MATERIAL, MESFA.FTPC_ADAYO.AA_INV_ASSIST_MATERIAL_TYPE,...
后续引擎确实开始捕获所有表的变更。
环境信息
- Debezium版本:2.7.0.Final
implementation 'io.debezium:debezium-embedded:2.7.0.Final' implementation 'io.debezium:debezium-connector-oracle:2.7.0.Final' - Oracle版本:11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
已尝试操作
- 删除偏移量文件(
offset.dat、history.dat、schemahistory.dat)后重启应用,问题依旧。 - 将
table.include.list替换为table.whitelist,无效。
解决方案
1. 移除database.dbname配置项
Oracle 11g环境下,database.dbname并非Debezium Oracle连接器的必要配置,该参数可能干扰表过滤逻辑。直接删除.with("database.dbname", "mesfa")这一行。
2. 统一标识符大小写
Oracle默认将表名、模式名存储为大写,需确保配置中的名称与数据库实际一致,修改为大写形式:
.with("schema.include.list","FTPC_FGE") .with("table.include.list", "FTPC_FGE.RECORD_DEMO")
3. 彻底清理元数据文件
确保以下三个文件被完全删除后再启动应用,避免历史配置残留:
offset.dathistory.datschemahistory.dat
4. 调整日志挖掘策略
Oracle 11g对online_catalog策略兼容性有限,切换为catalog策略:
.with("log.mining.strategy", "catalog")
5. 限制数据库用户权限
确保Debezium使用的数据库用户仅拥有FTPC_FGE模式的访问权限,避免因权限过大导致连接器扫描到其他模式的表。
内容的提问来源于stack exchange,提问作者春茶煮水

