mac修改open files数目

        原文: https://blog.csdn.net/u011466175/article/details/48002179

      上午在进行压力测试的时候,因为开启线程爬虫太多,所以在tcp连接的时候太多了,故一直出现tcp : too many open files的情况,查了一下,原来是系统开启文件数有限制。

      树霉派上面的同事已经设置好了,然后程序是在自己的mac上运行的,所以还得把自己的open files数目设置一下。

     上网找了好多解决方案,都没有有用的。最后快要放弃的时候找到一个:http://docs.basho.com/riak/latest/ops/tuning/open-files-limit/#Mac-OS-X

      因为自己的mac是Mac OS X Yosemite,里面正好有这个的解决方案,试了一下,可以修改open files数目成功!

      解决方案如下:

      输入命令:launchctl limit

      可以看到类似这样:

maxproc表示的是开启的最大进程数,第一个1064表示的是soft限制,第二个1064表示的是hard限制,即硬件最大的限制数,自己设置的不能高于hard限制。所以 我soft也改成了1064最大的。

maxfiles表示的是开启的最大文件数(句柄),意义同上……

如何设置呢?下面讲重点:

打开或者新建一个文件:/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>65536</string>
          <string>65536</string>
        </array>
      <key>RunAtLoad</key>
        <true/>
      <key>ServiceIPC</key>
        <false/>
    </dict>
  </plist>

保存并重启mac即可设置最大文件数。

 

打开或者新建一个文件:/Library/LaunchDaemons/limit.maxproc.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.maxproc</string>
      <key>ProgramArguments</key>
        <array>
          <string>launchctl</string>
          <string>limit</string>
          <string>maxproc</string>
          <string>2048</string>
          <string>2048</string>
        </array>
      <key>RunAtLoad</key>
        <true />
      <key>ServiceIPC</key>
        <false />
    </dict>
  </plist>

保存并重启mac即可设置最大进程数。 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值