# Memory lock not working

**URL:** <https://discuss.elastic.co/t/memory-lock-not-working/70576>\
**Category:** Elasticsearch\
**Created:** [January 4, 2017, 3:45pm UTC](https://discuss.elastic.co/t/memory-lock-not-working/70576 "2017-01-04T15:45:48Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mormaii](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mormaii/32/10790_2.png) [@Mormaii](https://discuss.elastic.co/u/Mormaii)\
**Post date:** [January 4, 2017, 3:45pm UTC](https://discuss.elastic.co/t/memory-lock-not-working/70576/1 "2017-01-04T15:45:48Z")

</div>

I'm running a Fedora 25 ec2 image with elasticsearch 5.1.1

This are my settings:

```
    /etc/elasticsearch/elasticsearch.yml
    bootstrap.memory_lock: true

    /usr/lib/systemd/system/elasticsearch.service
    LimitMEMLOCK=infinity

    /etc/sysconfig/elasticsearch
    MAX_LOCKED_MEMORY=unlimited

    /etc/security/limits.conf
    * soft memlock unlimited
    * hard memlock unlimited

```

even after that I'm still getting:

```
Unable to lock JVM Memory: error=12, reason=Cannot allocate memory
Increase RLIMIT_MEMLOCK, soft limit: 65536, hard limit: unlimited
memory locking requested for elasticsearch process but memory is not locked
```

---

<div class="post-metadata">

**Author:** ![danielmitterdorfer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/danielmitterdorfer/32/110510_2.png) [@danielmitterdorfer](https://discuss.elastic.co/u/danielmitterdorfer)\
**Post date:** [January 5, 2017, 12:48pm UTC](https://discuss.elastic.co/t/memory-lock-not-working/70576/2 "2017-01-05T12:48:27Z")

</div>

Hi @Mormaii,

How did you install Elasticsearch (.zip, .rpm) as the configuration procedure is a little bit different for each option (see [docs](https://www.elastic.co/guide/en/elasticsearch/reference/5.1/setup-configuration-memory.html))?

To me it seems some of the limits are not detected, as the error message says that the soft limit is 65536.

Daniel

---

<div class="post-metadata">

**Author:** ![Mormaii](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mormaii/32/10790_2.png) [@Mormaii](https://discuss.elastic.co/u/Mormaii)\
**Post date:** [January 5, 2017, 1:00pm UTC](https://discuss.elastic.co/t/memory-lock-not-working/70576/3 "2017-01-05T13:00:13Z")

</div>

I installed it via the rpm packages. I don't understand why it doesn't work on fedora. I used it on centos before and had no problem at all.

---

<div class="post-metadata">

**Author:** ![danielmitterdorfer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/danielmitterdorfer/32/110510_2.png) [@danielmitterdorfer](https://discuss.elastic.co/u/danielmitterdorfer)\
**Post date:** [January 5, 2017, 2:05pm UTC](https://discuss.elastic.co/t/memory-lock-not-working/70576/4 "2017-01-05T14:05:58Z")

</div>

Hi @Mormaii,

I tried to reproduce your problem on a fresh install of Fedora but it worked fine for me. Here is what I did:

```auto
sudo dnf install java-1.8.0-openjdk.x86_64
sudo rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch

# add the following contents with sudo vim /etc/yum.repos.d/elasticsearch.repo

[elasticsearch-5.x]
name=Elasticsearch repository for 5.x packages
baseurl=https://artifacts.elastic.co/packages/5.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md

sudo dnf install elasticsearch

# Now change all config files that you've mentioned in your initial post (not reproducing it here again for brevity)

sudo systemctl daemon-reload
sudo systemctl enable elasticsearch.service
sudo systemctl start elasticsearch.service

```

I checked the logs and no warnings showed up. Next I checked via the API:

```auto
curl http://localhost:9200/_nodes?filter_path=**.mlockall\&pretty

```

This produced:

```auto
{
  "nodes" : {
    "-Xe_hH7ZSC6fp6ZF7UkngQ" : {
      "process" : {
        "mlockall" : true
      }
    }
  }
}

```

So it looks like some setting is not picked up in your environment. Did you try to reboot the machine?

Daniel

---

<div class="post-metadata">

**Author:** ![Mormaii](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mormaii/32/10790_2.png) [@Mormaii](https://discuss.elastic.co/u/Mormaii)\
**Post date:** [January 5, 2017, 2:19pm UTC](https://discuss.elastic.co/t/memory-lock-not-working/70576/5 "2017-01-05T14:19:27Z")

</div>

That's really strange. I've tried rebooting the machine and setting the ulimit by hand on the current session too and it works to no avail. If I remove the mlockall it starts up just fine but when I try to enable it then elasticsearch fails.

---

<div class="post-metadata">

**Author:** ![danielmitterdorfer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/danielmitterdorfer/32/110510_2.png) [@danielmitterdorfer](https://discuss.elastic.co/u/danielmitterdorfer)\
**Post date:** [January 5, 2017, 2:29pm UTC](https://discuss.elastic.co/t/memory-lock-not-working/70576/6 "2017-01-05T14:29:24Z")

</div>

Hi @Mormaii,

one more possibility is that your tmp directory is mounted with `noexec` so you can try set a different tmp directory for Elasticsearch by adding this to `config/jvm.options`:

```auto
-Djava.io.tmpdir=/path/to/temp/dir

```

Daniel

---

<div class="post-metadata">

**Author:** ![Mormaii](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mormaii/32/10790_2.png) [@Mormaii](https://discuss.elastic.co/u/Mormaii)\
**Post date:** [January 5, 2017, 2:36pm UTC](https://discuss.elastic.co/t/memory-lock-not-working/70576/7 "2017-01-05T14:36:44Z")

</div>

I tried setting the the tmpdir to the same data/log dir that elasticsearch uses and I still get the same error

```
node validation exception bootstrap checks failed
memory locking requested for elasticsearch process but memory is not locked
```

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [January 5, 2017, 2:38pm UTC](https://discuss.elastic.co/t/memory-lock-not-working/70576/8 "2017-01-05T14:38:09Z")

</div>

Do you work over OpenSSH and `/etc/ssh/sshd_config` contains `UsePAM no`?

---

<div class="post-metadata">

**Author:** ![Mormaii](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mormaii/32/10790_2.png) [@Mormaii](https://discuss.elastic.co/u/Mormaii)\
**Post date:** [January 5, 2017, 2:39pm UTC](https://discuss.elastic.co/t/memory-lock-not-working/70576/9 "2017-01-05T14:39:19Z")

</div>

I work over OpenSSH on an EC2 instance. UsePAM is set to yes.

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [January 5, 2017, 2:41pm UTC](https://discuss.elastic.co/t/memory-lock-not-working/70576/10 "2017-01-05T14:41:25Z")

</div>

So [https://bugzilla.redhat.com/show\_bug.cgi?id=1308423](https://bugzilla.redhat.com/show_bug.cgi?id=1308423) is not of any relevance, I guess.

---

<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:** [January 5, 2017, 2:45pm UTC](https://discuss.elastic.co/t/memory-lock-not-working/70576/11 "2017-01-05T14:45:26Z")

</div>

Have you verified there are no conflicting configurations in any `conf` files in `/etc/security/limits.d/`?

---

<div class="post-metadata">

**Author:** ![Mormaii](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mormaii/32/10790_2.png) [@Mormaii](https://discuss.elastic.co/u/Mormaii)\
**Post date:** [January 5, 2017, 2:46pm UTC](https://discuss.elastic.co/t/memory-lock-not-working/70576/12 "2017-01-05T14:46:28Z")

</div>

There's no files on /etc/security/limits.d/

---

<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:** [February 2, 2017, 2:46pm UTC](https://discuss.elastic.co/t/memory-lock-not-working/70576/13 "2017-02-02T14:46:38Z")

</div>

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