too many open files

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

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

ulimit -a

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

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

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

  1.  lsof | wc -l
     
  2.  watch "lsof | wc -l"
     

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

  1.  lsof -p pid | wc -l
     
  2.  lsof -p 1234 | wc -l
     

设置open files数值方法

ulimit -n 2048

  1.  fdipzone@ubuntu:~$ ulimit -n 2048
     
  2.  fdipzone@ubuntu:~$ ulimit -a
     
  3.  core file size (blocks, -c) 0
     
  4.  data seg size (kbytes, -d) unlimited
     
  5.  scheduling priority (-e) 20
     
  6.  file size (blocks, -f) unlimited
     
  7.  pending signals (-i) 16382
     
  8.  max locked memory (kbytes, -l) 64
     
  9.  max memory size (kbytes, -m) unlimited
     
  10.  open files (-n) 2048
     
  11.  pipe size (512 bytes, -p) 8
     
  12.  POSIX message queues (bytes, -q) 819200
     
  13.  real-time priority (-r) 0
     
  14.  stack size (kbytes, -s) 8192
     
  15.  cpu time (seconds, -t) unlimited
     
  16.  max user processes (-u) unlimited
     
  17.  virtual memory (kbytes, -v) unlimited
     
  18.  file locks (-x) unlimited
     

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

永久设置方法

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

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

fdipzone soft nofile 8192
fdipzone hard nofile 8192

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

转自:https://blog.csdn.net/fdipzone/article/details/34588803

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

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

    linux 打开文件数 too many open files 解决方法 too many open files 出现这句提示的原因是程序打开的文件/socket连接数量超过系统设定值. 查看每个用户 ...

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

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

  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. Oracle 优化器

    http://blog.csdn.net/it_man/article/details/8185370一.优化器基本知识   Oracle在执行一个SQL之前,首先要分析一下语句的执行计划,然后再按执 ...

  2. JSP简单练习-用Servlet获取表单数据

    // javaBean代码 package servlet; import java.io.*; import javax.servlet.*; import javax.servlet.http.* ...

  3. (LeetCode)两个链表的第一个公共节点

    LeetCode上面的题目例如以下: Write a program to find the node at which the intersection of two singly linked l ...

  4. Codeforces Round #263 (Div. 2) proB

    题目: B. Appleman and Card Game time limit per test 1 second memory limit per test 256 megabytes input ...

  5. php的特殊功能-----不是和其他语言比较

    1.header(); 他不只是重定向,和更改字符集 而是发送表头,如 header('HTTP/1.1 404 Not Found   gfdgd'); 可以发送信息给浏览器,让浏览器显示404错误 ...

  6. Android中BaseAdapter使用基础点

    Android中要填充一些控件(如ListView)经常须要用到Adapter来实现,经常使用的有ArrayAdapter,SimpleAdapter, CursorAdapter,BaseAdapt ...

  7. IOS - unity3d错误Could not produce class with ID

    运行环境 Unity 5.3.5f1 (IL2CPP)编译IOS版本 XCode Version 7.2.1 (7C1002) Mac OS X 10.11.3 (15D21) (Mac mini) ...

  8. map和string的使用方法

    这个是别人写的map使用方法比較好能够看一下 http://www.cnblogs.com/anywei/archive/2011/10/27/2226830.html 怎样向数组中插入内容 http ...

  9. Android中RelativeLayout各个属性及其含义

    android:layout_above="@id/xxx"  --将控件置于给定ID控件之上android:layout_below="@id/xxx"  - ...

  10. CAS实现单点登录理解

    CAS 是 Yale 大学发起的一个企业级的.开源的项目,旨在为 Web 应用系统提供一种可靠的单点登录解决方法(属于 Web SSO ),CAS 开始于 2001 年, 并在 2004 年 12 月 ...