使用 Debezium 0.7 从 MySQL 读取,但在初始快照阶段出现刷新超时和 OutOfMemoryError 错误。查看下面的日志,似乎连接器试图一次写入太多消息:
WorkerSourceTask{id=accounts-connector-0} flushing 143706 outstanding messages for offset commit [org.apache.kafka.connect.runtime.WorkerSourceTask]
WorkerSourceTask{id=accounts-connector-0} Committing offsets [org.apache.kafka.connect.runtime.WorkerSourceTask]
Exception in thread "RMI TCP Connection(idle)" java.lang.OutOfMemoryError: Java heap space
WorkerSourceTask{id=accounts-connector-0} Failed to flush, timed out while waiting for producer to flush outstanding 143706 messages [org.apache.kafka.connect.runtime.WorkerSourceTask]
想知道对于大型数据库 (>50GB)的正确设置是什么http://debezium.io/docs/connectors/mysql/#connector-properties 。对于较小的数据库,我没有这个问题。简单地增加超时似乎不是一个好策略。我目前正在使用默认连接器设置。
更新
按照以下建议更改了设置并解决了问题:
OFFSET_FLUSH_TIMEOUT_MS: 60000 # default 5000
OFFSET_FLUSH_INTERVAL_MS: 15000 # default 60000
MAX_BATCH_SIZE: 32768 # default 2048
MAX_QUEUE_SIZE: 131072 # default 8192
HEAP_OPTS: '-Xms2g -Xmx2g' # default '-Xms1g -Xmx1g'