【问题标题】:kafka 8 and memory - There is insufficient memory for the Java Runtime Environment to continuekafka 8 和内存 - 内存不足,Java 运行时环境无法继续
【发布时间】:2014-02-22 07:23:54
【问题描述】:

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

【问题讨论】:

    标签: java apache-kafka


    【解决方案1】:

    可以通过编辑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 中的消息大小以使其运行。

    【讨论】:

      【解决方案2】:

      区域:热点/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.
      

      【讨论】:

        【解决方案3】:

        就我而言,我之前在进行 android 开发,让 android studio 和一个虚拟机运行了一整夜,当我尝试启动我的 apache Kafka 服务器时,我意识到了这个错误。 我重新启动笔记本电脑以重置内存,然后重新启动 Kafka 服务器,希望这对那里的人有所帮助!..

        【讨论】:

          【解决方案4】:

          在您的环境路径中,将 java 路径更改为 JDK64,而不是 JDK32。这解决了我的问题,我有 64gb 内存并使用 32bit Jvm 更改 JDK64(64bit JVM)的路径解决了这个问题。

          【讨论】:

            【解决方案5】:

            添加环境变量 JAVA_OPTS。

            在 Linux 中,编辑 ~/.bashrc 文件,并更好地获取它。

            export JAVA_OPTS="$JAVA_OPTS -Xms128M -Xmx128M"
            

            在寡妇中,添加系统变量

            JAVA_OPTS "-Xms128M -Xmx128M"
            

            然后重启。

            如果它不起作用,则应更改许多文件,例如bin/kafka-server-start.shconfig/server.properties。减少这些文件中的数量。

            【讨论】:

              【解决方案6】:

              here 的回答也可用于解决 运行 Kafka 的 Docker 容器中的相同问题。

              只需将以下 ENV 变量添加到您的 docker-compose 文件(或运行脚本):

              KAFKA_HEAP_OPTS: "-Xmx512M -Xms256M"
              

              当然,您应该微调主机资源可用性的值

              【讨论】:

                【解决方案7】:

                在 AWS 上遇到了同样的错误。我想我至少需要一个 t2.medium 才能让我的经纪人和动物园管理员工作。

                【讨论】:

                  猜你喜欢
                  • 2019-02-19
                  • 1970-01-01
                  • 2017-08-13
                  • 2020-09-03
                  • 2018-02-11
                  • 2018-05-20
                  • 1970-01-01
                  • 2022-10-06
                  • 2013-10-07
                  相关资源
                  最近更新 更多