linux 打开文件数 too many open files 解决方法

too many open files

出现这句提示的原因是程序打开的文件/socket连接数量超过系统设定值。

查看每个用户最大允许打开文件数量

ulimit -a
[plain] view plain copy
在CODE上查看代码片派生到我的代码片

fdipzone@ubuntu:~$ ulimit -a  
    core file size          (blocks, -c) 0  
    data seg size           (kbytes, -d) unlimited  
    scheduling priority             (-e) 20  
    file size               (blocks, -f) unlimited  
    pending signals                 (-i) 16382  
    max locked memory       (kbytes, -l) 64  
    max memory size         (kbytes, -m) unlimited  
    open files                      (-n) 1024  
    pipe size            (512 bytes, -p) 8  
    POSIX message queues     (bytes, -q) 819200  
    real-time priority              (-r) 0  
    stack size              (kbytes, -s) 8192  
    cpu time               (seconds, -t) unlimited  
    max user processes              (-u) unlimited  
    virtual memory          (kbytes, -v) unlimited  
    file locks                      (-x) unlimited

其中 open files (-n) 1024 表示每个用户最大允许打开的文件数量是1024

查看当前系统打开的文件数量

[plain] view plain copy
在CODE上查看代码片派生到我的代码片

lsof | wc -l  
    watch "lsof | wc -l"

查看某一进程的打开文件数量

[plain] view plain copy
在CODE上查看代码片派生到我的代码片

lsof -p pid | wc -l  
    lsof -p 1234 | wc -l

设置open files数值方法

ulimit -n 2048

[plain] view plain copy
在CODE上查看代码片派生到我的代码片

fdipzone@ubuntu:~$ ulimit -n 2048  
    fdipzone@ubuntu:~$ ulimit -a  
    core file size          (blocks, -c) 0  
    data seg size           (kbytes, -d) unlimited  
    scheduling priority             (-e) 20  
    file size               (blocks, -f) unlimited  
    pending signals                 (-i) 16382  
    max locked memory       (kbytes, -l) 64  
    max memory size         (kbytes, -m) unlimited  
    open files                      (-n) 2048  
    pipe size            (512 bytes, -p) 8  
    POSIX message queues     (bytes, -q) 819200  
    real-time priority              (-r) 0  
    stack size              (kbytes, -s) 8192  
    cpu time               (seconds, -t) unlimited  
    max user processes              (-u) unlimited  
    virtual memory          (kbytes, -v) unlimited  
    file locks                      (-x) unlimited

这样就可以把当前用户的最大允许打开文件数量设置为2048了,但这种设置方法在重启后会还原为默认值。

永久设置方法

[plain] view plain copy
在CODE上查看代码片派生到我的代码片

vim /etc/security/limits.conf  
    在最后加入  
    * soft nofile 4096  
    * hard nofile 4096

最前的 * 表示所有用户,可根据需要设置某一用户,例如

[plain] view plain copy
在CODE上查看代码片派生到我的代码片

fdipzone soft nofile 8192  
    fdipzone hard nofile 8192

改完后注销一下就能生效。

linux 打开文件数 too many open files 解决方法的更多相关文章

  1. linux 打开文件数too many open files解决方法

    出现这句提示的原因是程序打开的文件/socket连接数量超过系统设定值.查看每个用户最大允许打开的文件数量ulimit -a 其中 open files (-n) 1024 表示每个用户最大允许打开的 ...

  2. (转)linux 打开文件数 too many open files 解决方法

    too many open files 出现这句提示的原因是程序打开的文件/socket连接数量超过系统设定值. 查看每个用户最大允许打开文件数量 ulimit -a fdipzone@ubuntu: ...

  3. 遇到问题----linux-----linux 打开文件数 too many open files 解决方法

    在运行某些命令或者 tomcat等服务器持续运行 一段时间后可能遇到   too many open files. 出现这句提示的原因是程序打开的文件/socket连接数量超过系统设定值. 查看每个用 ...

  4. linux上备份Oracle时EXP-00091的错误解决方法

    unix/linux上备份Oracle时EXP-00091的错误解决方法 unix/linux上备份数据时的错误解决方法 EXP-00091: Exporting questionable stati ...

  5. linux找不到动态链接库 .so文件的解决方法(转自:http://www.cnblogs.com/xudong-bupt/p/3698294.html)

    linux找不到动态链接库 .so文件的解决方法 如果使用自己手动生成的动态链接库.so文件,但是这个.so文件,没有加入库文件搜索路劲中,程序运行时可能会出现找不到动态链接库的情形. 可以通过ldd ...

  6. Linux使用退格键时出现^H ^?解决方法

    Linux使用退格键时出现^H ^?解决方法 在linux下执行脚本不注意输错内容需要删除时总是出现^H ^H不是H键的意思,是backspace.主要是当你的终端backspace有问题的时候才需要 ...

  7. linux找不到动态链接库 .so文件的解决方法

    linux找不到动态链接库 .so文件的解决方法 如果使用自己手动生成的动态链接库.so文件,但是这个.so文件,没有加入库文件搜索路劲中,程序运行时可能会出现找不到动态链接库的情形. 可以通过ldd ...

  8. 误把Linux运行级别设置为6后的解决方法【转】

    本文转载自:http://www.wuji8.com/meta/841011126.html 误把Linux运行级别设置为6后的解决方法     我们知道,Linux有7个运行级别,而运行级别设置为6 ...

  9. 关于Linux服务器磁盘空间占满问题的解决方法

    下面给大家分享一篇关于Linux服务器磁盘占满问题解决方法(/dev/sda3 满了),需要的的朋友参考下吧   下面我们一起来看一篇关于Linux服务器磁盘占满问题解决(/dev/sda3 满了), ...

随机推荐

  1. ED/EP简介

    ED:electronic Deposit,电子存折 EP:electronic Purse,电子钱包 PIN:personal identification number,个人识别码 MAC:Mes ...

  2. 【Longest Valid Parentheses】cpp

    题目: Given a string containing just the characters '(' and ')', find the length of the longest valid ...

  3. ubuntu(Eclipse+JDK) 自动安装脚本

    sudo rm -rf jdk1.8.0_40sudo rm -rf /usr/lib/jvm sudo tar -zxvf jdk-8u40-linux-i586.tar.gzsudo mkdir ...

  4. 为什么匿名内部类参数必须为final类型(转载)

    为什么匿名内部类参数必须为final类型转自于:http://feiyeguohai.iteye.com/blog/1500108 1)  从程序设计语言的理论上:局部内部类(即:定义在方法中的内部类 ...

  5. Codeforces Round #278 (Div. 2)

    题目链接:http://codeforces.com/contest/488 A. Giga Tower Giga Tower is the tallest and deepest building ...

  6. jQuery(Keep for myself)

    jQuery API : http://www.w3cschool.cc/manual/jquery/ 1. jQuery是一个JavaScript函数库. jQuery是一个轻量级的"写的 ...

  7. 二分图匹配(KM算法)n^4 分类: ACM TYPE 2014-10-04 11:36 88人阅读 评论(0) 收藏

    #include <iostream> #include<cstring> #include<cstdio> #include<cmath> #incl ...

  8. vector内存分配

    vector,map 这些容器还是在堆上分配的内存,在析构时是释放空间 vector在提高性能可以先reserve在push_back() reserve:决定capacity,但没有真正的分配内存, ...

  9. Hibernate SQL方言 (hibernate.dialect)

    数据库 hibernate方言 DB2 org.hibernate.dialect.DB2Dialect DB2 AS/400 org.hibernate.dialect.DB2400Dialect ...

  10. js实用功能

    //日期格式转换 Date.prototype.format = function (format) {     /*      * eg:format="yyyy-MM-dd hh:mm: ...