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. ndarray的axis问题

    始终记不住np中axis是对应到哪个,还没系统地去学习下 先暂记两个常用的结果 1.[:,np.newaxis] 与 [np.newaxis, :] 注:这是ndarray才有的分片方法(np重写了[ ...

  2. Ubuntu18.04 server安装步骤

    Ubuntu18.04 server安装步骤 1. select a language default 2.  select your location default 3. configure th ...

  3. arcgis python获得字段唯一值

    arcgis python获得字段唯一值 # Import native arcgisscripting moduleimport arcgisscripting, sys# Create the g ...

  4. vsCode安装todo插件

    使用过IDEA或者WebStrom的阿媛应该都知道他们都有一个TODO功能,方便我们跟踪注释,或者说是我们在项目代码里面所做的标记:但是如果你现在在使用vsCode,你会发现,没有TODO功能,幸好, ...

  5. React Native 常用第三方组件

    React-Native-Elements 一组开发RN的UI工具包(强烈推荐)

  6. Kettle源码学习(一)——把Kettle项目跑起来

    kettle(pentaho data integration),是一款开源的C/S版的ETL工具,最近打算学习一下kettle源码,并自己写一个mini kettle,并改造成基于事件触发的流处理模 ...

  7. 一百二十三:CMS系统之登录功能

    配置文件中加入前台用户的身份标识 form class SigninForm(BaseForm): telephone = StringField(validators=[Regexp(r'1[345 ...

  8. redis 超时失效key 的监听触发使用

    redis自2.8.0之后版本提供Keyspace Notifications功能,允许客户订阅Pub / Sub频道,以便以某种方式接收影响Redis数据集的事件. 可能收到的事件的例子如下: 所有 ...

  9. [CDH] Cloudera's Distribution including Apache Hadoop

    You may choose to install spark, yarn, hive, etc one by one. [Spark] 00 - Install Hadoop & Spark ...

  10. $nextTick的使用

    原文地址 概览 官方文档说明: 用法: 在下次 DOM 更新循环结束之后执行延迟回调.在修改数据之后立即使用这个方法,获取更新后的 DOM. 疑问: DOM 更新循环是指什么? 下次更新循环是什么时候 ...