“打开的文件太多"在Mac上执行加特林时 [英] "Too many open files" when executing gatling on Mac

查看:136
本文介绍了“打开的文件太多"在Mac上执行加特林时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Macbook Pro 15'(16 Giga的RAM,4个物理核)的Mac iOS(El Capitan)上的外壳上执行加特林(负载测试工具)时,出现错误打开的文件太多"./p>

我花了几天时间解决此问题,但没有成功:

  • 我在/Library/LaunchDaemons/limit.maxfiles.plist中创建了一个文件,其中包含从网络复制的XML文件内容,没有结果.

  • sudo ulimit -n 15000不起作用.

  • 我创建了一个包含以下内容的文件/etc/sysctl.conf

kern.maxfiles = 20480
kern.maxfilesperproc = 20480

  • 我尝试了命令"sudo launchctl limit maxfiles 20480 20480",没有任何结果.

我认为"/Library/LaunchDaemons/"中的xml文件似乎有一定作用,因为当我更改maxfiles的值时,命令"sudo launchctl limit"会向我显示我在XML文件中输入的值,当使用某个值调用"ulimit -n"时,它接受小于该值的每个值,但是当我调用"ulimit -n"时,结果每次都是相同的"4096".

我看到在Java中,限制为10240,所以我尝试了VM选项(-XX:-MaxFDLimit),没有任何效果.

奇怪的是,当我从Intellij(IDE)执行加特林时,我只能使用10 200个套接字.即使在执行所有组合(ulimit,sysctl,launchctl等)中的所有命令之后,同一件事也会产生不同的效果.

最诚挚的问候

解决方案

只要其他人从google登陆,以下是更改最新版OS X的打开文件限制所需的步骤:

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. 更改新文件的所有者:

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

3. 检查当前设置 launchctl限制maxfiles

4. 加载以下新设置:

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

5. 最后,检查限制是否正确:

launchctl limit maxfiles

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".

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.

  • sudo ulimit -n 15000 doesn't work.

  • I created a file /etc/sysctl.conf with the following content

kern.maxfiles=20480
kern.maxfilesperproc=20480

  • I tried the command "sudo launchctl limit maxfiles 20480 20480" without any result.

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".

I saw that in Java, the limit is 10240, so i tried the VM option (-XX:-MaxFDLimit) without any effect.

On strange thing, when i executed Gatling from Intellij (IDE), i ca go until 10 200 sockets. The same thing, give differents effects, even after executing all commands in all combinaisons (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:

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):

<?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:

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

3. Check current settings launchctl limit maxfiles

4. Load these new settings:

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

5. Finally, check that the limits are correct:

launchctl limit maxfiles

这篇关于“打开的文件太多"在Mac上执行加特林时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆