ElasticSearch(es) commit_memory内存不足error='Not enough space'如何配置?

elasticsearch 默认分配jvm空间大小为2g,如果内存不足则会报以下错误:

error:
OpenJDK 64-Bit Server VM warning: INFO: os::commit_memory(0x00000000c6a00000, 962592768, 0) failed; error='Not enough space' (errno=12)
        at org.elasticsearch.tools.launchers.JvmOption.flagsFinal(JvmOption.java:119)
        at org.elasticsearch.tools.launchers.JvmOption.findFinalOptions(JvmOption.java:81)
        at org.elasticsearch.tools.launchers.JvmErgonomics.choose(JvmErgonomics.java:38)
        at org.elasticsearch.tools.launchers.JvmOptionsParser.jvmOptions(JvmOptionsParser.java:13

解决办法

1. 进入config文件夹开始配置,编辑jvm.options:

vim /usr/local/elasticsearch/config/jvm.options

2. 修改配置适合本机,下面把2g内存调整成256m

默认配置如下:
-Xms2g
-Xmx2g
默认的配置占用内存太多了,调小一些:
-Xms256m
-Xmx256mb

保存并重启es这样就行了!

版权声明:本文为JAVASCHOOL原创文章,未经本站允许不得转载。