我有一个使用 Debezium 的项目,主要基于 this example ,然后连接到 Apache Pulsar。
我更改了一些配置。该文件现在如下所示:
database.history=io.debezium.relational.history.MemoryDatabaseHistory
connector.class=io.debezium.connector.mysql.MySqlConnector
offset.storage=org.apache.kafka.connect.storage.FileOffsetBackingStore
offset.storage.file.filename=offset.dat
offset.flush.interval.ms=5000
name=mysql-dbz-connector
database.hostname={ip}
database.port=3308
database.user={user}
database.password={pass}
database.dbname=database
database.server.name=test
table.whitelist=database.history_table,database.project_table
snapshot.mode=schema_only
schemas.enable=false
include.schema.changes=false
pulsar.topic=persistent://public/default/{0}
pulsar.broker.address=pulsar://{ip}:6650
database.history=io.debezium.relational.history.MemoryDatabaseHistory
正如您所理解的,我想做的是监视数据库中的 history_table
和 project_table
修改,然后将有效负载写入 Apache Pulsar。
我的问题如下。无论我使用什么快照模式,当写入偏移量时,我都无法重新启动 Debezium,而不会在下一次数据库更新时出现错误。
Encountered change event for table database.history_table whose schema isn't known to this connector
只有现有 offset.dat
文件才会发生这种情况。我认为这是因为 offset.dat 文件中的架构为空。以这个为例:
¨Ìsrjava.util.HashMap⁄¡√`—F
loadFactorI thresholdxp?@wur[B¨Û¯T‡xpG{"schema":null,"payload":["mysql-dbz-connector",{"server":"test"}]}uq~U{"ts_sec":1563802215,"file":"database-bin.000005","pos":79574,"server_id":1,"event":1}x
我首先怀疑我用来使 JSON 更简洁的 schemas.enable=false
或 include.schema.changes=false
参数,但它们的值并不不要更改 offset.dat
文件中的任何内容。
最佳答案
问题出在database.history=io.debezium.relational.history.MemoryDatabaseHistory
行。历史记录将无法重新启动。您应该使用 FileDatabaseHistory 而不是它。
关于database - Debezium 错误,此连接器不知道架构,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57147584/