查看日志:

可能原因:
# Possible reasons:
#   The system is out of physical RAM or swap space
#   In 32 bit mode, the process size limit was hit
可能的解决方案:
# Possible solutions:
#   Reduce memory load on the system
#   Increase physical memory or swap space
#   Check if swap backing store is full
#   Use 64 bit Java on a 64 bit OS
#   Decrease Java heap size (-Xmx/-Xms)
#   Decrease number of Java threads
#   Decrease Java thread stack sizes (-Xss)
#   Set larger code cache with -XX:ReservedCodeCacheSize=
# This output file may be truncated or incomplete.
#
#  Out of Memory Error (os_linux.cpp:2756), pid=17968, tid=140647024301824
#
 
虚拟机参数:内存情况等
VM Arguments:
jvm_args: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.security.egd=file:/dev/./urandom -Xms256m -Xmx512m -Dfile.encoding=UTF-8 -Djdk.tls.ephemeralDHKeySize=2048 -Dignore.endorsed.dirs= -Dcatalina.base=/usr/local/tomcat -Dcatalina.home=/usr/local/tomcat -Djava.io.tmpdir=/usr/local/tomcat/temp 
java_command: org.apache.catalina.startup.Bootstrap stop
Launcher Type: SUN_STANDARD

解决方案:

vi   /kafka_2.12-2.3.0/bin/kafka-server-start.sh

if [ "x$KAFKA_HEAP_OPTS" = "x" ]; then
    export KAFKA_HEAP_OPTS="-Xmx1G -Xms1G"
fi

启动内存设置的是1G,而我的机器最大只有2G内存,还启动了zk,mysql等,所以内存肯定是支持不了启动两个kafka的

所以在这里吧 1G 修改为 128M 或者 256M 即可。

注:改的太小的话,启动也会报错。

[ FATAL ] Fatal error during KafkaServerStable startup. Prepare to shutdown
 java.lang.OutOfMemoryError: Java heap space
        at java.nio.HeapByteBuffer.(HeapByteBuffer.java:57)
        at java.nio.ByteBuffer.allocate(ByteBuffer.java:335)
        at kafka.log.SkimpyOffsetMap.(OffsetMap.scala:42)

..........

这时候把上述配置的内存再改大一些就好了,比如 改为256M或者512M

Logo

Kafka开源项目指南提供详尽教程,助开发者掌握其架构、配置和使用,实现高效数据流管理和实时处理。它高性能、可扩展,适合日志收集和实时数据处理,通过持久化保障数据安全,是企业大数据生态系统的核心。

更多推荐