Linux Too many open files

查看系统资源限制信息:

sudo -s -u root -H id

sudo -s lsof | awk '{ print $2 " " $1; }' | sort -rn | uniq -c | sort -rn | head -20

sudo -s ulimit -Sn

sudo -s ulimit -Hn

sudo cat /proc/sys/fs/file-max

sudo -s cat /etc/security/limits.conf

最后当我们尝试$ cat /proc/<processId>/limits; 我们注意到“打开文件数”仍显示为4096,这是旧值; 虽然对于root来说它显示了更高的值。

最后,我们可以通过修改 /etc/default/tomcat7 [或与您的进程相对应的任何其他文件]并添加以下行来解决此问题:

ulimit -Hn 10000
ulimit -Sn 10000

无需重启系统; 只需重新启动进程,然后检查 cat /proc/<processId>/limits

在ubuntu 16.04下,tomcat的最大文件数受systemd限制,并自动设置为4096.您可以通过运行更改此值

systemctl edit tomcat7

添加以下行:

[Service]
LimitNOFILE=8192

或者你可以自己创建配置:

mkdir /etc/systemd/system/tomcat7.service.d/
nano /etc/systemd/system/tomcat7.service.d/override.conf

之后重新加载tomcat:

服务tomcat7重启

并仔细检查是否正确设置了限制

ps ax | grep tomcat
cat /proc/<processId>/limits

1. 使用以下行修改/etc/systemd/user.conf和/etc/systemd/system.conf(这将负责图形登录):
DefaultLimitNOFILE=65535

2. 使用以下行修改/etc/security/limits.conf(这将负责非GUI登录):
* hard nofile 65535
* soft nofile 65535
root hard nofile 65535
root soft nofile 65535

3. 可选操作,编辑 /etc/pam.d/common-session和/etc/pam.d/common-session-noninteractive 文件并添加以下行到最后:
session required pam_limits.so

4. 重新启动计算机以使更改生效。

No need to change anything in the /etc/security/limits.conf file, it is ignored if you are using systemd.

(reproducing a modified answer to another question on the network...)

An alternative for those who prefer not to edit the default /etc/systemd/system.conf and /etc/systemd/user/conf files:

  1. create a new file /etc/systemd/system.conf.d/limits.conf with these contents:

    [Manager]
    DefaultLimitNOFILE=65535
  2. run systemctl daemon-reexec as root

  3. logout and login again

  4. check your new limit with ulimit -n.

Refer to the systemd-system.conf manpage for details.

System.IO.IOException: Too Many Open Files (Mono .NET on Ubuntu)

sudo ps -waux | grep mono | grep -v grep | awk '{print $2}' | xargs kill -9

export MONO_MANAGED_WATCHER=disabled

================ End

Linux Too many open files的更多相关文章

  1. 【原】The Linux Command Line - Manipulation Files And Directories

    cp - Copy Files and directories mv - move/rename files and directories mkdir - create directories rm ...

  2. Linux Compile Multiple C++ Files

    Compile Two Files: $ CC -c Main.cc Sales_item.cc # by default generates a.exe # some compilers gener ...

  3. linux find string in files

    http://blog.csdn.net/duguduchong/article/details/7716908 查找目录下的所有文件中是否含有某个字符串 find .|xargs grep -ri ...

  4. linux too many open files 问题总结

    问题描述: kubernetes 集群使用promtail收集日志,发现一段时间有些机器日志收集不到查看promtail日志出现以下报错: error="filetarget.fsnotif ...

  5. linux too many open files报错

    修改方法:vi /etc/security/limits.conf  增加一行,如下: *       -       nofile          65535 修改vi /etc/ssh/sshd ...

  6. linux修改open files数

    概要 linux系统默认open files数目为1024, 有时应用程序会报Too many open files的错误,是因为open files 数目不够.这就需要修改ulimit和file-m ...

  7. [转载]linux修改open files数

    概要:linux系统默认open files数目为1024, 有时应用程序会报Too many open files的错误,是因为open files 数目不够.这就需要修改ulimit和file-m ...

  8. Linux服务器报错too many open files错误解决方案

    1.本质解决方案按照oracle的安装脚本中以下几项文件进行相应配置: cp /etc/security/limits.conf /etc/security/limits.conf.bak echo ...

  9. linux -目录结构

    摘自:http://www.comptechdoc.org/os/linux/usersguide/linux_ugfilestruct.html 这个目录结构介绍是我目前看到介绍最全的,有时间在翻译 ...

随机推荐

  1. 中间件 | kafka简介、使用场景、设计原理、主要配置及集群搭建

    开源Java学习 公众号 一.入门 1.简介 Kafka is a distributed,partitioned,replicated commit logservice.它提供了类似于JMS的特性 ...

  2. Android系统服务 —— WMS与AMS

    “可以毫不夸张的说,Android的framework层主要是由WMS.AMS还有View所构成,这三个模块穿插交互在整个framework中,掌握了它们之间的关系和每一个逻辑步骤,你对framewo ...

  3. SpringCloud(六)之 网关概念、Zuul项目搭建-(利用Zuul 实现鉴权和限流实战)

    一.网关概念 1.什么是路由网关 网关是系统的唯一对外的入口,介于客户端和服务器端之间的中间层,处理非业务功能 提供路由请求.鉴权.监控.缓存.限流等功能.它将"1对N"问题转换成 ...

  4. JVM学习笔记之认识JDK(一)

    1. HotSpot VM: HotSpot VM是Sun JDK和OpenJDK中所带的虚拟机,也是目前使用范围最广的Java虚拟机. 什么是HotSpot VM & 深入理解Java虚拟机 ...

  5. 小D课堂 - 新版本微服务springcloud+Docker教程_5-08 断路器监控仪表参数

    笔记 8.断路器监控仪表参数讲解和模拟熔断     简介:讲解 断路器监控仪表盘参数和模拟熔断 1.sse  server-send-event推送到前端 资料:https://github.com/ ...

  6. java+目录上传

    我们平时经常做的是上传文件,上传文件夹与上传文件类似,但也有一些不同之处,这次做了上传文件夹就记录下以备后用. 首先我们需要了解的是上传文件三要素: 1.表单提交方式:post (get方式提交有大小 ...

  7. webshell劫持工具【全站劫持】

    演示视频下载地址:https://share.weiyun.com/53hPGYj 需要联系QQ:1743685523 ---------------------------------------- ...

  8. 【AMAD】django-social-auth -- 让django使用社交网络oauth鉴权变得极为轻松!

    简介 个人评分 简介 django-social-auth1集成的Oauth API包括: Google OpenID Google Oauth Google Oauth2 Yahoo OpenID ...

  9. Linux操作系统原理笔记

    在Linux操作系统内核内部,进程是通过一个链表,而且是一个双向链表来管理的. 进程描述符:每一个进程都有其描述符,每一个描述符彼此之间都有关联性的.   双向链表:   一个进程内部可能包含多个线程 ...

  10. 第五周课程总结&试验报告(三)

    第五周课程总结&试验报告(三) 实验三 String类的应用 实验目的 掌握类String类的使用: 学会使用JDK帮助文档: 实验内容 ###1.已知字符串:"this is a ...