一、前言
早上醒来打开微信,同事反馈kafka集群从昨天凌晨开始写入频繁失败,赶紧打开电脑查看了kafka集群的机器监控,日志信息,发现其中一个节点的集群负载从昨天凌晨突然掉下来了,和同事反馈的时间点大概一致,于是乎就登录服务器开始干活。
二、排错
1、查看机器监控,看是否能大概定位是哪个节点有异常
技术分享
2、根据机器监控大概定位到其中一个异常节点,登录服务器查看kafka日志,发现有报错日志,并且日志就停留在这个这个时间点:
[2017-06-01 16:59:59,851] ERROR Processor got uncaught exception. (kafka.network.Processor)
java.lang.OutOfMemoryError: Direct buffer memory
at java.nio.Bits.reserveMemory(Bits.java:658)
at java.nio.DirectByteBuffer.
at java.nio.ByteBuffer.allocateDirect(ByteBuffer.java:306)
at sun.nio.ch.Util.getTemporaryDirectBuffer(Util.java:174)
at sun.nio.ch.IOUtil.read(IOUtil.java:195)
at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:379)
at org.apache.kafka.common.network.PlaintextTransportLayer.read(PlaintextTransportLayer.java:108)
at org.apache.kafka.common.network.NetworkReceive.readFromReadableChannel(NetworkReceive.java:97)
at org.apache.kafka.common.network.NetworkReceive.readFrom(NetworkReceive.java:71)
at org.apache.kafka.common.network.KafkaChannel.receive(KafkaChannel.java:160)
at org.apache.kafka.common.network.KafkaChannel.read(KafkaChannel.java:141)
at org.apache.kafka.common.network.Selector.poll(Selector.java:286)
at kafka.network.Processor.run(SocketServer.scala:413)3、查看kafka进程和监听端口情况,发现都正常,尼玛假死了
ps -ef |grep kafka ## 查看kafka的进程
netstat -ntlp |grep 9092 ##9092kafka的监听端口4、既然已经假死了,只能重启了
ps -ef |grep kafka |grep -v grep |awk ‘{print $2}‘ | xargs kill -9
/usr/local/kafka/bin;nohup ./kafka-server-start.sh ../config/server.properties &5、重启后在观察该节点的kafka日志,在一顿index重建之后,上面的报错信息在疯狂的刷,最后谷歌一番,解决了该问题
三、解决方案:
在
/usr/local/kafka/binkafka-run-class.sh
去掉-XX:+DisableExplicitGC
添加-XX:MaxDirectMemorySize=512m在一次重启kafka,问题解决。