elasticsearch insufficient memory

When starting elasticsearch on CentOS 7 server, it failed with error. Checking the logs with

journalctl -u elasticsearch

Found following errors

systemd[1]: Starting Elasticsearch...
systemd-entrypoint[2438]: Exception in thread "main" java.lang.RuntimeException: starting java failed with [1]
systemd-entrypoint[2438]: output:
systemd-entrypoint[2438]: #
systemd-entrypoint[2438]: # There is insufficient memory for the Java Runtime Environment to continue.
systemd-entrypoint[2438]: # Native memory allocation (mmap) failed to map 16710107136 bytes for committing reserved memory.
systemd-entrypoint[2438]: # An error report file with more information is saved as:
systemd-entrypoint[2438]: # /var/log/elasticsearch/hs_err_pid2576.log
systemd-entrypoint[2438]: error:
systemd-entrypoint[2438]: OpenJDK 64-Bit Server VM warning: INFO: os::commit_memory(0x00000003dc000000, 16710107136, 0) failed; error='Not enough space' (errno=
systemd-entrypoint[2438]: at org.elasticsearch.tools.launchers.JvmOption.flagsFinal(JvmOption.java:119)
systemd-entrypoint[2438]: at org.elasticsearch.tools.launchers.JvmOption.findFinalOptions(JvmOption.java:81)
systemd-entrypoint[2438]: at org.elasticsearch.tools.launchers.JvmErgonomics.choose(JvmErgonomics.java:38)
systemd-entrypoint[2438]: at org.elasticsearch.tools.launchers.JvmOptionsParser.jvmOptions(JvmOptionsParser.java:135)
systemd-entrypoint[2438]: at org.elasticsearch.tools.launchers.JvmOptionsParser.main(JvmOptionsParser.java:86)
systemd[1]: elasticsearch.service: main process exited, code=exited, status=1/FAILURE
systemd[1]: Failed to start Elasticsearch.
systemd[1]: Unit elasticsearch.service entered failed state.
systemd[1]: elasticsearch.service failed.

To fix it, edit file

/etc/elasticsearch/jvm.options

At end of the file, add

-Xms1g
-Xmx1g

Restart elasticsearch with

systemctl restart elasticsearch

Verify elasticsearch is running with

systemctl restart elasticsearch
curl localhost:9200

See elasticsearch

Need help with Linux Server or WordPress? We can help!

Leave a Reply

Your email address will not be published. Required fields are marked *