zoukankan      html  css  js  c++  java
  • 修改linux的最大文件句柄数限制

    from:http://www.2cto.com/os/201308/238169.html 

    修改linux的最大文件句柄数限制

     
     对于一般的应用来说(象Apache、系统进程)1024完全足够使用。但是如何象squid、mysql、java等单进程处理大量请求的应用来说就有点捉襟见肘了。如果单个进程打开的文件句柄数量超过了系统定义的值,就会提到“too many files open”的错误提示。如何知道当前进程打开了多少个文件句柄呢?下面一段小脚本可以帮你查看:
    1
    lsof -n |awk '{print $2}'|sort|uniq -c |sort -nr|more
     
    修改linux的最大文件句柄数限制的方法:
          1)ulimit -n 65535  
                在当前session有效,用户退出或者系统重新后恢复默认值
          2)修改profile文件:在profile文件中添加:ulimit -n 65535 
               只对当个用户有效
          3)修改文件:/etc/security/limits.conf,在文件中添加:(立即生效-当前session中运行ulimit -a命令无法显示)
     
    [html]  
    * soft nofile 32768 #限制单个进程最大文件句柄数(到达此限制时系统报警)  
    * hard nofile 65536 #限制单个进程最大文件句柄数(到达此限制时系统报错)  
          4)修改文件:/etc/sysctl.conf。在文件中添加:
    [html]  
    fs.file-max=655350 #限制整个系统最大文件句柄数  
          运行命令:/sbin/sysctl -p 使配置生效
  • 相关阅读:
    Windows Server 2012 R2 或 2016 无法安装 .Net 3.5.1
    织梦DeDeCms会员登录或退出跳转到首页的修改方法
    use ngCordova in ionic
    Angular2 Todo App
    use traceur in ES6
    Angular2 Use styles in Component
    Angular2 use ng-xx (ng-if)
    Angular2 Router
    Angular2 Http
    1 TypeScript SetUp for Webstorm
  • 原文地址:https://www.cnblogs.com/94cool/p/5287860.html
Copyright © 2011-2022 走看看