Elasticsearch on CentOS 7.4.1708, bootstrap.memory_lock problems when starting on boot, but no problems on manual start

I am trying to run elasticsearch-5.6.6-1 on startup on CentOS 7.4.1708.
I have no problems with almost the exact setup on CentOS 6.x.
The server has 64 GB of ram with most of it not used.

When I set
bootstrap.memory_lock: true
Elasticsearch does not start up during boot.
The following error is shown in the elasticsearch logs

[2018-02-02T01:41:26,457][WARN ][o.e.b.JNANatives ] Unable to lock JVM Memory: error=12, reason=Cannot allocate memory
[2018-02-02T01:41:26,458][WARN ][o.e.b.JNANatives ] This can result in part of the JVM being swapped out.
[2018-02-02T01:41:26,458][WARN ][o.e.b.JNANatives ] Increase RLIMIT_MEMLOCK, soft limit: 65536, hard limit: 65536
[2018-02-02T01:41:26,458][WARN ][o.e.b.JNANatives ] These can be adjusted by modifying /etc/security/limits.conf, for example:
# allow user 'elasticsearch' mlockall
elasticsearch soft memlock unlimited
elasticsearch hard memlock unlimited

However it will always successfully start up manually, and the appropriate settings in /etc/security/limits.conf are already there.
Also when setting
bootstrap.memory_lock: false
Elasticsearch start on boot properly.

Here is my server information:
[root@testserver elasticsearch]# cat /etc/security/limits.conf
...

  • hard nofile 200000
  • soft nofile 200000
  • soft memlock unlimited
  • hard memlock unlimited
    elasticsearch soft memlock unlimited
    elasticsearch hard memlock unlimited
    ...
    [root@testserver ~]# cat /etc/redhat-release
    CentOS Linux release 7.4.1708 (Core)
    [root@testserver ~]# rpm -qa|grep elastic
    elasticsearch-5.6.6-1.noarch
    [root@testserver ~]# cat /etc/elasticsearch/
    elasticsearch.yml jvm.options log4j2.properties scripts/
    [root@testserver ~]# cat /etc/elasticsearch/jvm.options
    ...
    -Xms26g
    -Xmx26g
    ...
    [root@testserver ~]# free -h
    total used free shared buff/cache available
    Mem: 62G 27G 29G 146M 5.6G 34G
    Swap: 1.0G 0B 1.0G

I think elasticsearch should work on boot properly.
If I did something wrong, I do not understand why the error only occurs during boot and not during manual start up using 'systemctl status elasticsearch.service'

Do you know why I am having errors?

Thank you.

CentOS 7 uses systemd. For this, you must use a different procedure. Please see the docs for exactly what you must do.

Thank you for your reply.

According to
https://www.elastic.co/guide/en/elasticsearch/reference/6.1/setting-system-settings.html#systemd

I did
systemctl edit elasticsearch

added

[Service]
LimitMEMLOCK=infinity

and the problem has been resolved.

You’re welcome.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.