使用kafka Connect出现Java heap space的解决方法

最近在学习kafka-connect,在配置source文件中所查询的表数据有364M大小,在运行一个单机连接器测试source时出现如下错误提示:

[2017-10-18 20:12:48,185] INFO Source task WorkerSourceTask{id=Aliyunmysql-source-0} finished initialization and start (org.apache.kafka.connect.runtime.WorkerSourceTask:142)
[2017-10-18 20:13:18,304] INFO Reflections took 61988 ms to scan 565 urls, producing 13142 keys and 86128 values (org.reflections.Reflections:229)
[2017-10-18 20:14:02,787] ERROR Task Aliyunmysql-source-0 threw an uncaught and unrecoverable exception (org.apache.kafka.connect.runtime.WorkerTask:141)
java.lang.OutOfMemoryError: Java heap space

以下是解决方法:

在百度后大多解决内在溢出的方法都不适用与解决该问题,但既然是使用kafka报的错误,应该要在kafka的启动配置文件中去设置,在/bin目录下找到kafka-run-class文件并编辑 

#vim /bin/kafka-run-class

找到 Memory options处,默认设置是256M,将其修改为如下值

# Memory options
if [ -z "$KAFKA_HEAP_OPTS" ]; then
KAFKA_HEAP_OPTS="-Xmx1024M -Xms512M"
fi

保存退出,再运行连接器,不再出现Java heap space错误,解决该问题。

posted @ 2017-10-19 11:42  yyscf  阅读(4559)  评论(0编辑  收藏  举报