2

I am trying to set the max open files on CentOS 7 for elasticsearch. I've read over and over again how to set this but it doesn't seem to be working. As I understand it:

  • limits.conf is irrelevant because elasticsearch user is set to /sbin/nologin and we're starting the daemon with system
  • I need to set LimitNOFILE=65535 in the systemd unit file.

So, I went ahead and did that, here's my unit file, it's provided by the elasticsearch puppet module:

[Unit] Description=Starts and stops a single elasticsearch instance on this system Documentation=http://www.elasticsearch.org [Service] Type=forking EnvironmentFile=/etc/sysconfig/elasticsearch-graylog2 User=elasticsearch Group=elasticsearch PIDFile=/var/run/elasticsearch/elasticsearch-graylog2.pid ExecStart=/usr/share/elasticsearch/bin/elasticsearch -d -p /var/run/elasticsearch/elasticsearch-graylog2.pid -Des.default.path.home=${ES_HOME} -Des.default.path.logs=${LOG_DIR} -Des.default.path.data=${DATA_DIR} -Des.default.path.work=${WORK_DIR} -Des.default.path.conf=${CONF_DIR} # See MAX_OPEN_FILES in sysconfig LimitNOFILE=65535 # See MAX_LOCKED_MEMORY in sysconfig, use "infinity" when MAX_LOCKED_MEMORY=unlimited and using bootstrap.mlockall: true # Shutdown delay in seconds, before process is tried to be killed with KILL (if configured) TimeoutStopSec=20 [Install] WantedBy=multi-user.target 

Note how limitNOFILE is set here. I have also set MAX_OPEN_FILES in my EnvironmentFile:

CONF_DIR=/etc/elasticsearch/graylog2 CONF_FILE=/etc/elasticsearch/graylog2/elasticsearch.yml ES_GROUP=elasticsearch ES_HOME=/usr/share/elasticsearch ES_USER=elasticsearch LOG_DIR=/var/log/elasticsearch/graylog2 MAX_OPEN_FILES=65535 

However, elasticsearch still reports that the max open files are 4096, both from within the app itself, and from with /proc/<pid>/limits

Does anyone know what I'm doing wrong here? I even tried setting this from within limits.conf but as I expected, no luck.

3
  • This smells like the work SELinux to me... Commented Jan 5, 2016 at 18:07
  • SELinux is disabled, first thing I checked. sestatus SELinux status: disabled Commented Jan 5, 2016 at 18:14
  • I have exact the same configs as you and it works fine on mine.. Sorry I can't be much help Commented Jan 5, 2016 at 18:18

2 Answers 2

1

I did this:

/etc/security/limits.d/elasticuser # Default limit for number of open files for elastic user elastic hard nofile 65536 

And included this in systemd like you did

LimitNOFILE=65536 

seems to work fine

-1

User cannot be set to /sbin/nologin, this is the path to its shell. So you need to tune your limits.conf

4
  • That's what I meant, the elasticsearch user has shell /sbin/nologin Commented Jan 5, 2016 at 18:14
  • Type of shell doesn't matter. Anyway you can try the following 1. Find out under which user elasticsearch is running. 2. In user's .bash_profile add 'ulimit -n unlimited' 3. If it works reduce 'unlimited' to reasonable value. Commented Jan 5, 2016 at 18:21
  • 1
    That didn't help, as I expected, because .bash_profile is only executed by a login shell Commented Jan 5, 2016 at 18:31
  • try to add in .bashrc as well Commented Jan 5, 2016 at 18:33

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.