kafka 8 和内存 - Java 运行时环境的内存不足,无法继续
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21448907/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
kafka 8 and memory - There is insufficient memory for the Java Runtime Environment to continue
提问by Tampa
I am using DigiOcean instance with 512 megs of ram, I get the below error with kafka. I am not a java proficient dev. How do I adjust kafka to utilize the small amount of ram. This is a dev sever. I dont want to pay more per hour for a bigger machine.
我正在使用带有 512 兆内存的 DigiOcean 实例,我在使用 kafka 时遇到以下错误。我不是一个精通 Java 的开发人员。如何调整 kafka 以利用少量的 ram。这是一个开发服务器。我不想为更大的机器每小时支付更多费用。
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (malloc) failed to allocate 986513408 bytes for committing reserved memory.
# An error report file with more information is saved as:
# //hs_err_pid6500.log
OpenJDK 64-Bit Server VM warning: INFO: os::commit_memory(0x00000000bad30000, 986513408, 0) failed; error='Cannot allocate memory' (errno=12)
采纳答案by Chris
You can adjust the JVM heap size by editing kafka-server-start.sh
, zookeeper-server-start.sh
and so on:
您可以通过编辑调整JVM堆大小kafka-server-start.sh
,zookeeper-server-start.sh
等等:
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:
该-Xms
参数指定最小堆大小。为了让您的服务器至少启动,请尝试更改它以使用更少的内存。鉴于您只有 512M,您也应该更改最大堆大小 ( -Xmx
):
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.
我不确定默认配置中 kafka 的最小内存要求是什么 - 也许您需要调整 kafka 中的消息大小以使其运行。
回答by haobin zhang
Area: HotSpot / gc
区域:热点/gc
Synopsis
概要
Crashes due to failure to allocate large pages.
On Linux, failures when allocating large pages can lead to crashes. When running JDK 7u51 or later versions, the issue can be recognized in two ways:
Before the crash happens, one or more lines similar to the following example will have been printed to the log:
os::commit_memory(0x00000006b1600000, 352321536, 2097152, 0) failed;
error='Cannot allocate memory' (errno=12); Cannot allocate large pages,
falling back to regular pages
If a file named hs_err is generated, it will contain a line similar to the following example:
Large page allocation failures have occurred 3 times
The problem can be avoided by running with large page support turned off, for example, by passing the "-XX:-UseLargePages" option to the java binary.
回答by Mowzey
For my case, I was previously doing android development having the android studio and a virtual machine running for an entire night I realized this error when I tried to start my apache Kafka server. I restarted my laptop to reset memory and then started Kafka server all over again hope this helps someone out there!..
就我而言,我之前在做 android 开发,让 android studio 和虚拟机运行一整夜,当我尝试启动我的 apache Kafka 服务器时,我意识到了这个错误。我重新启动了我的笔记本电脑以重置内存,然后重新启动 Kafka 服务器希望这可以帮助那里的人!..
回答by Shantam Mittal
In your environment path change the java path to JDK64 instead on JDK32. This solved my issue where i was having 64gb ram and using 32bit Jvm changing the path to JDK64(64bit JVM) solved the issue.
在您的环境路径中,将 java 路径更改为 JDK64 而不是 JDK32。这解决了我有 64gb 内存的问题,并使用 32 位 JVM 将路径更改为 JDK64(64 位 JVM)解决了该问题。
回答by gogog
add environment variable JAVA_OPTS.
添加环境变量 JAVA_OPTS。
In Linux, edit ~/.bashrc file, and better source it.
在 Linux 中,编辑 ~/.bashrc 文件,并更好地获取它。
export JAVA_OPTS="$JAVA_OPTS -Xms128M -Xmx128M"
In widows, add system variable
在寡妇中,添加系统变量
JAVA_OPTS "-Xms128M -Xmx128M"
and then reboot.
然后重新启动。
And if it does not work, many file should be changed, e.x. bin/kafka-server-start.sh,config/server.properties. Decrease number in those files.
如果它不起作用,则应更改许多文件,例如bin/kafka-server-start.sh、config/server.properties。减少这些文件中的数量。