LoginSignup
3
3

More than 5 years have passed since last update.

Macでtoo many open filesがでてきたとき

Posted at

前提

  1. MacOS 10.10 Yosemite (10.9以前は対象外)
  2. elsaticsearchをlaunchctlで起動している

事象

elasticsearchがtoo many open filesというエラーを吐いてうんともすんとも言わなくなることがある。

原因

システム上のmaxfilesの数がelasticsearchが推奨する32k〜64kまでの値に設定されていない。

対応

以下のファイルを作成する。
/Library/LaunchDaemons/limit.maxfiles.plist

内容は以下のとおり。
xml:limit.maxfiles.plist
<?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>

macを再起動する。

elasticsearchのAPIでopen_file_descriptorsを確認できます。
$ curl -s http://127.0.0.1:9200/_nodes/stats/process?pretty

あとはelasticsearchのログファイルを見ながらちゃんと処理できるようになってればOKなはずです。

3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3