# Elasticsearch on CentOS 7.4.1708, bootstrap.memory\_lock problems when starting on boot, but no problems on manual start

**URL:** <https://discuss.elastic.co/t/elasticsearch-on-centos-7-4-1708-bootstrap-memory-lock-problems-when-starting-on-boot-but-no-problems-on-manual-start/118476>\
**Category:** Elasticsearch\
**Created:** [February 5, 2018, 2:39pm UTC](https://discuss.elastic.co/t/elasticsearch-on-centos-7-4-1708-bootstrap-memory-lock-problems-when-starting-on-boot-but-no-problems-on-manual-start/118476 "2018-02-05T14:39:09Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![digirave](https://avatars.discourse-cdn.com/v4/letter/d/85e7bf/32.png) [@digirave](https://discuss.elastic.co/u/digirave)\
**Post date:** [February 5, 2018, 2:39pm UTC](https://discuss.elastic.co/t/elasticsearch-on-centos-7-4-1708-bootstrap-memory-lock-problems-when-starting-on-boot-but-no-problems-on-manual-start/118476/1 "2018-02-05T14:39:09Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jasontedor](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jasontedor/32/66992_2.png) [@jasontedor](https://discuss.elastic.co/u/jasontedor)\
**Post date:** [February 6, 2018, 2:46am UTC](https://discuss.elastic.co/t/elasticsearch-on-centos-7-4-1708-bootstrap-memory-lock-problems-when-starting-on-boot-but-no-problems-on-manual-start/118476/2 "2018-02-06T02:46:36Z")

</div>

CentOS 7 uses systemd. For this, you must use a different procedure. Please see the [docs](https://www.elastic.co/guide/en/elasticsearch/reference/6.1/setup-configuration-memory.html#bootstrap-memory_lock) for exactly what you must do.

---

<div class="post-metadata">

**Author:** ![digirave](https://avatars.discourse-cdn.com/v4/letter/d/85e7bf/32.png) [@digirave](https://discuss.elastic.co/u/digirave)\
**Post date:** [February 6, 2018, 3:58am UTC](https://discuss.elastic.co/t/elasticsearch-on-centos-7-4-1708-bootstrap-memory-lock-problems-when-starting-on-boot-but-no-problems-on-manual-start/118476/3 "2018-02-06T03:58:42Z")

</div>

Thank you for your reply.

According to  
[https://www.elastic.co/guide/en/elasticsearch/reference/6.1/setting-system-settings.html#systemd](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.

---

<div class="post-metadata">

**Author:** ![jasontedor](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jasontedor/32/66992_2.png) [@jasontedor](https://discuss.elastic.co/u/jasontedor)\
**Post date:** [February 6, 2018, 10:30am UTC](https://discuss.elastic.co/t/elasticsearch-on-centos-7-4-1708-bootstrap-memory-lock-problems-when-starting-on-boot-but-no-problems-on-manual-start/118476/4 "2018-02-06T10:30:13Z")

</div>

You’re welcome.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [March 6, 2018, 10:30am UTC](https://discuss.elastic.co/t/elasticsearch-on-centos-7-4-1708-bootstrap-memory-lock-problems-when-starting-on-boot-but-no-problems-on-manual-start/118476/5 "2018-03-06T10:30:24Z")

</div>

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