Where to set MAX_LOCKED_MEMORY=unlimited in Elasticsearch 5.0

I run Ubuntu 16.04 in my production environment.

I downloaded Elasticsearch 5.0 from TAR.

According to this post, I can set MAX_LOCKED_MEMORY=unlimited in /etc/default/elasticsearch on Ubuntu 14.04, but there is no such file in that directory. I even created /etc/default/elasticsearch and put MAX_LOCKED_MEMORY=unlimited in that file, but it didn't work.

Where can I set MAX_LOCKED_MEMORY=unlimited in my situation?

1 Like

If you're running from the tar archive, /etc/default/elasticsearch and so on will never have any effect (it's only sourced by the System V init files). Instead, you have to modify /etc/security/limits.conf or create /etc/security/limits.d/elasticsearch.conf and set

<username of user that will be running Elasticsearch> - memlock unlimited

and start a new login shell for this to be picked up.

2 Likes

Thank you for your reply.
Could you tell me how to start a new login shell for the setting to be picked up?
I run systems using systemd, so I ran systemctl daemon-reload after the setup (Please tell me if this is a wrong command.).
But I still get an error like the follows.

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

After I received this error, I set ubuntu soft memlock unlimited and ubuntu hard memlock unlimited in /etc/security/limits.conf and ran systemctl daemon-reload.
But the error doesn't disappear.

Now I looked into this doc in which they say there is another option to disable swapping.
That option is to comment out any lines that contain the word swap in /etc/fstab, but there is no lines with the word in the first place in that file. Does this mean I don't have to do anything and it's configured correctly out of the box?

You said you're using the tar archive, not a package install that would setup systemd for you. Since you're not using systemd, there's no need to run any systemd commands here. To start a new login shell just logout and login again.

Oh, excuse my lack of knowledge.
Yes, I downloaded Elasticsearch from TAR.
After logging out and logging in, it worked.
Thank you.

You're very welcome.

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