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

    修改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 使配置生效
  • 相关阅读:
    RSA
    DES
    MD5
    增删改查
    [转]数据绑定之DataFormatString
    分页通用存储过程(未验证)
    浅谈sql中的in与not in,exists与not exists的区别
    [转]order by 1是什么意思?
    bak骗子公司
    Performance Considerations for Entity Framework 4, 5, and 6
  • 原文地址:https://www.cnblogs.com/94cool/p/5751695.html
Copyright © 2011-2022 走看看