簡體   English   中英

kafka 8 和內存 - Java 運行時環境的內存不足,無法繼續

[英]kafka 8 and memory - There is insufficient memory for the Java Runtime Environment to continue

我正在使用帶有 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)

您可以通過編輯kafka-server-start.shzookeeper-server-start.sh等來調整 JVM 堆大小:

export KAFKA_HEAP_OPTS="-Xmx1G -Xms1G"

-Xms參數指定最小堆大小。 為了讓您的服務器至少啟動,請嘗試更改它以使用更少的內存。 鑒於您只有 512M,您也應該更改最大堆大小 ( -Xmx ):

export KAFKA_HEAP_OPTS="-Xmx256M -Xms128M"

我不確定默認配置中 kafka 的最小內存要求是什么 - 也許您需要調整 kafka 中的消息大小以使其運行。

區域:熱點/gc

概要

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.

就我而言,我之前在做 android 開發,讓 android studio 和虛擬機運行一整夜,當我嘗試啟動我的 apache Kafka 服務器時,我意識到了這個錯誤。 我重新啟動了我的筆記本電腦以重置內存,然后重新啟動 Kafka 服務器希望這可以幫助那里的人!..

在您的環境路徑中,將 java 路徑更改為 JDK64 而不是 JDK32。 這解決了我有 64gb 內存的問題,並使用 32 位 JVM 將路徑更改為 JDK64(64 位 JVM)解決了該問題。

添加環境變量 JAVA_OPTS。

在 Linux 中,編輯 ~/.bashrc 文件,並更好地獲取它。

export JAVA_OPTS="$JAVA_OPTS -Xms128M -Xmx128M"

在寡婦中,添加系統變量

JAVA_OPTS "-Xms128M -Xmx128M"

然后重新啟動。

如果它不起作用,則應更改許多文件,例如bin/kafka-server-start.shconfig/server.properties 減少這些文件中的數量。

此處的答案也可用於解決運行 KafkaDocker 容器中的相同問題。

只需將以下 ENV 變量添加到您的 docker-compose 文件(或運行腳本):

KAFKA_HEAP_OPTS: "-Xmx512M -Xms256M"

當然,您應該微調主機資源可用性的值

在 AWS 上遇到了同樣的錯誤。 我想我需要一個 t2.medium 至少讓我的經紀人和動物園管理員工作。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM