Increasing max_file_descriptors OSX

[Solved] [2.4.3] I've set ulimit to 65000, but it keeps on showing up as 10240 when elasticsearch starts up. Is elasticsearch showing the valid max_file_descriptors?

Thanks

edit:
I took @jasontedor advise from below. I set ulimit in bash_profile or bashrc or zshrc. I started ES with this command. ES_JAVA_OPTS="-XX:-MaxFDLimit" ./bin/elasticsearch worked like magic.

This situation is very complicated. :slight_smile:

To get you running quickly:

  • add the following content to /etc/sysctl.conf (create this file if it does not exist):
kern.maxfiles=65536
kern.maxfilesperproc=65536
  • restart
  • set ulimit -n 65536
  • start the Elasticsearch process with the JVM option -XX:-MaxFDLimit (e.g., use ES_JAVA_OPTS=-XX:-MaxFDLimit)
  • verify the file descriptors are correct by sending a request to /_nodes/stats/process?pretty=1

I've written up why this is such a headache previously: https://github.com/elastic/elasticsearch/issues/16813#issuecomment-189541620

1 Like

Set the line

limit maxfiles 65536 65536

in /etc/launchd.conf and restart your Mac.

This does not work since at least Yosemite, maybe sooner. If you want to go the launchd route, you have to create /Library/LaunchDaemons/limit.maxfiles.plist with the following content:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
  <plist version="1.0">
    <dict>
      <key>Label</key>
        <string>limit.maxfiles</string>
      <key>ProgramArguments</key>
        <array>
          <string>launchctl</string>
          <string>limit</string>
          <string>maxfiles</string>
          <string>65536</string>
          <string>65536</string>
        </array>
      <key>RunAtLoad</key>
        <true/>
      <key>ServiceIPC</key>
        <false/>
    </dict>
  </plist>

This still requires a restart, and it still requires starting the JVM with -XX:-MaxFDLimit.

What's funny is that my max file descriptors when from 10240 to 4864, lol. It did change.

edit: This is working for me now! I put the ulimit -n 65536 in my .bash_profile an everything started working. Thanks!

Yeah I reviewed everything I did that you suggested....for some reason my max_file_discriptors when down. I started ES with ES_JAVA_OPTS="-XX:-MaxFDLimit" ./bin/elasticsearch

Was that right?

{
  "cluster_name": "elasticsearch",
  "nodes": {
    "0ZpLUqNERb-V_-_izVkhsA": {
      "timestamp": 1483546091076,
      "name": "Mister X",
      "transport_address": "127.0.0.1:9300",
      "host": "127.0.0.1",
      "ip": [
        "127.0.0.1:9300",
        "NONE"
      ],
      "process": {
        "timestamp": 1483546091076,
        "open_file_descriptors": 273,
        "max_file_descriptors": 4864,
        "cpu": {
          "percent": 3,
          "total_in_millis": 8060
        },
        "mem": {
          "total_virtual_in_bytes": 5321494528
        }
      }
    }
  }
}

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