kafka版本号:2.3.0;集群:1台,broker:2个;Mem: 16G
错误信息:
[2021-03-14 04:57:49,831] ERROR Processor got uncaught exception. (kafka.network.Processor)
java.lang.OutOfMemoryError: Direct buffer memory
at java.nio.Bits.reserveMemory(Bits.java:693)
at java.nio.DirectByteBuffer.<init>(DirectByteBuffer.java:123)
at java.nio.ByteBuffer.allocateDirect(ByteBuffer.java:311)
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:380)
at org.apache.kafka.common.network.PlaintextTransportLayer.read(PlaintextTransportLayer.java:103)
at org.apache.kafka.common.network.NetworkReceive.readFrom(NetworkReceive.java:117)
at org.apache.kafka.common.network.KafkaChannel.receive(KafkaChannel.java:424)
at org.apache.kafka.common.network.KafkaChannel.read(KafkaChannel.java:385)
at org.apache.kafka.common.network.Selector.attemptRead(Selector.java:651)
at org.apache.kafka.common.network.Selector.pollSelectionKeys(Selector.java:572)
at org.apache.kafka.common.network.Selector.poll(Selector.java:483)
at kafka.network.Processor.poll(SocketServer.scala:863)
at kafka.network.Processor.run(SocketServer.scala:762)
at java.lang.Thread.run(Thread.java:745)
尝试过在kafka-run-class.sh 脚本内添加 -XX:MaxDirectMemorySize=512M,并逐步增加数值一直到4096M,同时两个broker配置 KAFKA_HEAP_OPTS="-Xmx6G -Xms6G"由1G逐步增加到6G,依然出现此报错。
请博主帮助分析一下!
你先
ps -ef|grep kafka
看看内存修改是否生效了。
之前已经查过,都是生效的
1、首先确保你这台物理机有足够的内存,
-XX:MaxDirectMemorySize= 4096M
这个的,jvm分走后该机器必须还要有4g内存让它分配(堆外内存)。2、你的消息量已经超过了系统瓶颈,kafka在集群互相同步交互消息的时候,受物理的网络和存储的影响,只能通过增加节点来分摊压力。
这样的话,我看能否通过增加节点解决这个问题。谢谢您
你的答案