简体   繁体   English

在Mac上执行gatling时“打开文件太多”

[英]“Too many open files” when executing gatling on Mac

When executing gatling (load test tools) from shell on Mac iOS (El Capitan) on my Macbook Pro 15 ' (16 Giga of RAM, 4 physical cores), i've the error "Too many open files". 在我的Macbook Pro 15'(16千兆RAM,4个物理内核)上从Mac iOS(El Capitan)上的shell执行gatling(加载测试工具)时,我的错误是“打开的文件过多”。

I spend days to fix this problem, without any success : 我花了几天时间来解决这个问题,没有任何成功:

  • I created a file in /Library/LaunchDaemons/limit.maxfiles.plist with a XML file content copied from the web, no result. 我在/Library/LaunchDaemons/limit.maxfiles.plist中创建了一个文件,其中包含从Web复制的XML文件内容,没有结果。

  • sudo ulimit -n 15000 doesn't work. sudo ulimit -n 15000不起作用。

  • I created a file /etc/sysctl.conf with the following content 我使用以下内容创建了一个文件/etc/sysctl.conf

kern.maxfiles=20480 kern.maxfiles = 20480
kern.maxfilesperproc=20480 kern.maxfilesperproc = 20480

  • I tried the command "sudo launchctl limit maxfiles 20480 20480" without any result. 我没有任何结果尝试了命令“sudo launchctl limit maxfiles 20480 20480”。

I think that the xml file in "/Library/LaunchDaemons/" seem have some effect, because when i change the value of the maxfiles, the command "sudo launchctl limit" display to me the value i entered in the XML file, and when calling "ulimit -n" with some value, it accept every values less than this value, but when i call "ulimit -n", the result is everytime the same "4096". 我认为“/ Library / LaunchDaemons /”中的xml文件似乎有一些效果,因为当我更改maxfiles的值时,命令“sudo launchctl limit”向我显示我在XML文件中输入的值,以及使用某个值调用“ulimit -n”,它接受小于该值的每个值,但是当我调用“ulimit -n”时,结果是每次都是相同的“4096”。

I saw that in Java, the limit is 10240, so i tried the VM option (-XX:-MaxFDLimit) without any effect. 我在Java中看到,限制是10240,所以我尝试了VM选项(-XX:-MaxFDLimit)而没有任何影响。

On strange thing, when i executed Gatling from Intellij (IDE), i ca go until 10 200 sockets. 奇怪的是,当我从Intellij(IDE)执行Gatling时,我可以直到10 200个套接字。 The same thing, give differents effects, even after executing all commands in all combinaisons (ulimit, sysctl, launchctl, ...). 同样的事情,即使在所有组合中执行所有命令(ulimit,sysctl,launchctl,...)之后,也会产生不同的效果。

Best regards 最好的祝福

Just in case any one else lands here from google, here are the steps required to change the open files limit on the latest versions of OS X: 万一其他任何人从谷歌到这里,这里是更改最新版本的OS X上的打开文件限制所需的步骤:

1. In /Library/LaunchDaemons create a file named limit.maxfiles.plist and paste the following in (feel free to change the two numbers (which are the soft and hard limits, respectively): 1./Library/LaunchDaemons创建一个名为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>64000</string>
      <string>524288</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
    <key>ServiceIPC</key>
    <false/>
  </dict>
</plist> 

2. Change the owner of your new file: 2.更改新文件的所有者:

sudo chown root:wheel /Library/LaunchDaemons/limit.maxfiles.plist

3. Check current settings launchctl limit maxfiles 3.检查当前设置launchctl limit maxfiles

4. Load these new settings: 4.加载以下新设置:

sudo launchctl load -w /Library/LaunchDaemons/limit.maxfiles.plist

5. Finally, check that the limits are correct: 5.最后,检查限制是否正确:

launchctl limit maxfiles

I found the answer to my question. 我找到了问题的答案。

Ulimit and Shell Ulimit和壳牌

My problem with gatling come from the fact that i can't execute the ulimit with my user (permission denied), and "sudo ulimit" has not effect to the current shell for my user. 我的gatling问题来自于我无法用我的用户执行ulimit(权限被拒绝),而“sudo ulimit”对我的用户的当前shell没有影响。 So, my solution is to 所以,我的解决方案是

Execute my gatling stress test under a root user (sudo -s). 在root用户(sudo -s)下执行我的gatling压力测试。 Add a line "ulimit -n 23000" in the /etc/profile file. 在/ etc / profile文件中添加一行“ulimit -n 23000”。

Intellij 的IntelliJ

For intellij, the answer is to modify the vmoptions of intellij in the Info.plist file to add in the VMOptions key at the end of the file the " -XX:-MaxFDLimit ". 对于intellij,答案是修改Info.plist文件中intellij的vmoptions,以在文件末尾的VMOptions键中添加“ -XX:-MaxFDLimit ”。

Changing the file bin/idea.vmoptions has no effect. 更改文件bin / idea.vmoptions无效。

Global value of maxfiles should be changed by adding a file "limit.maxfiles.plist" in the /Library/LaunchDaemons directory. 应通过在/ Library / LaunchDaemons目录中添加文件“limit.maxfiles.plist”来更改maxfiles的全局值。

<?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>66111</string>
          <string>66111</string>
        </array>
      <key>RunAtLoad</key>
        <true/>
      <key>ServiceIPC</key>
        <false/>
    </dict>
  </plist>

Thank you 谢谢

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM