现象

启动kafka报错

INFO: os::commit_memory(0x00000000c0000000, 1073741824, 0) failed; error='Cannot allocate memory' (e

原因

主机可分配内存不足

解决办法

  1. 调整kafka的配置(推荐)
You can adjust the JVM heap size by editing kafka-server-start.sh, zookeeper-server-start.shand so on:

export KAFKA_HEAP_OPTS="-Xmx1G -Xms1G"
The -Xms parameter specifies the minimum heap size. To get your server to at least start up, try changing it to use less memory. Given that you only have 512M, you should change the maximum heap size (-Xmx) too:

export KAFKA_HEAP_OPTS="-Xmx256M -Xms128M"
I'm not sure what the minimal memory requirements of kafka in default config are - maybe you need to adjust the message size in kafka to get it to run.

你可以通过编辑调整JVM堆大小kafka-server-start.sh,zookeeper-server-start.sh等:

export KAFKA_HEAP_OPTS="-Xmx1G -Xms1G"
的-Xms参数指定的最小堆大小。让你的服务器至少开始,试着改变它使用较少的内存。因为你只有512M,你应该改变最大堆大小(-Xmx)太:

export KAFKA_HEAP_OPTS="-Xmx256M -Xms128M"
  1. 使用top/htop等命令,查看占用cpu较大的进程,杀掉重启启动kafka
  2. 关机,机器增加内存资源
Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐