Java堆空间-内存不足错误-具有SASL_SSL的Kafka Broker

时间:2019-10-14 11:13:35

标签: java ssl apache-kafka out-of-memory sasl

当我在带有PLAIN_TEXT端口9092的Kafka代理中使用以下“ / usr / bin / kafka-delete-records”命令时,该命令可以正常工作,但是当我使用SASL_SSL端口9094时,该命令将引发以下错误。有谁知道将Kafka代理端口9094与SASL_SSL结合使用的解决方案?

$ssh **** ****@<IP address> /usr/bin/kafka-delete-records --bootstrap-server localhost:9094 --offset-json-file /kafka/records.json`

[2019-10-14 04:15:49,891] ERROR Uncaught exception in thread 'kafka-admin-client-thread | adminclient-1': (org.apache.kafka.common.utils.KafkaThread)

java.lang.OutOfMemoryError: Java heap space
    at java.nio.HeapByteBuffer.<init>(HeapByteBuffer.java:57)
    at java.nio.ByteBuffer.allocate(ByteBuffer.java:335)
    at org.apache.kafka.common.memory.MemoryPool$1.tryAllocate(MemoryPool.java:30)
    at org.apache.kafka.common.network.NetworkReceive.readFrom(NetworkReceive.java:112)
    at org.apache.kafka.common.network.KafkaChannel.receive(KafkaChannel.java:390)
    at org.apache.kafka.common.network.KafkaChannel.read(KafkaChannel.java:351)
    at org.apache.kafka.common.network.Selector.attemptRead(Selector.java:609)
    at org.apache.kafka.common.network.Selector.pollSelectionKeys(Selector.java:541)
    at org.apache.kafka.common.network.Selector.poll(Selector.java:467)
    at org.apache.kafka.clients.NetworkClient.poll(NetworkClient.java:535)
    at org.apache.kafka.clients.admin.KafkaAdminClient$AdminClientRunnable.run(KafkaAdminClient.java:1125)
    at java.lang.Thread.run(Thread.java:748)
Executing records delete operation
Records delete operation completed:

注意:-Xmx为8GB,服务器的总内存为16GB

请在下面检查当前的堆值:

$ ps -ef | grep kafka
cp-kafka 11419     1  3 10:07 ?        00:05:27 java -Xms8g -Xmx8g  -XX:MaxGCPauseMillis=20 -XX:InitiatingHeapOccupancyPercent=35  ........ io.confluent.support.metrics.SupportedKafka /etc/kafka/server.properties

1 个答案:

答案 0 :(得分:2)

OOM异常很可能只是一个红色鲱鱼,请参见JIRA KAFKA-4493。因此,真正的问题是您的客户端无法正确建立的SASL-SSL连接。在客户端上启用SSL调试,然后从那里进行操作:

$ export KAFKA_OPTS="-Djavax.net.debug=handshake"
$ /usr/bin/kafka-delete-records ...