我在使用Debezium和Kafka Connect复制表时遇到了性能问题。
只有在数据库的初始快照期间才会出现复制速度较慢的情况。我测试的一个表包含340万行,复制花了2个小时才完成。
在这个阶段,整个数据库都被锁定,我无法将数据提交到当时未同步的其他表中。
我的配置(通过curl请求部署Debezium配置):
{
"name": "debezium-connector",
"config": {
"connector.class": "io.debezium.connector.mysql.MySqlConnector",
"tasks.max": "1",
"database.hostname": "redacted",
"database.port": "3306",
"database.user": "redacted",
"database.password": "redacted",
"database.server.id": "54005",
"database.server.name": "redacted",
"database.include.list": "redacted",
"table.include.list": "redacted",
"database.history.consumer.security.protocol":"SSL",
"database.history.producer.security.protocol":"SSL",
"database.history.kafka.bootstrap.servers": "redacted",
"database.history.kafka.topic": "schema-changes.debezium-test",
"snapshot.mode": "when_needed",
"max.queue.size": 81290,
"max.batch.size": 20480
}
}已更改的Kafka Connect配置:
CONNECT_OFFSET_FLUSH_INTERVAL_MS: 10000
CONNECT_OFFSET_FLUSH_TIMEOUT_MS: 60000问题:1-如何在数据库的初始快照过程中提高性能?2-如何在不锁定整个数据库的情况下从数据库复制有限数量的表?
发布于 2020-11-30 13:14:46
如果您可以确保数据库架构在快照过程中不会更改,则可以避免通过https://debezium.io/documentation/reference/1.3/connectors/mysql.html#mysql-property-snapshot-locking-mode锁定数据库
还要检查https://debezium.io/documentation/reference/1.3/connectors/mysql.html#mysql-property-min-row-count-to-stream-results选项,如果正确使用它,可能还会有一些性能变化。
你也可以和max.queue.size一起使用max.batch.size,甚至比你现在拥有的更多。
https://stackoverflow.com/questions/65005683
复制相似问题