增加最大打开文件数的其他方法?

增加最大打开文件数的其他方法?

我有一个应用程序不断给出以下错误。

tail: inotify cannot be used, reverting to polling: Too many open files

我已经遵循了在网络搜索中找到的所有建议,并且已经用我所知道的所有方法更改了打开文件描述符的数量。我还重新启动了服务器。可能还有什么阻碍我的进程打开更多文件?

一些有用的数据:

# lsof | wc -l
8347
$ lsof -u <username> | wc -l
7533
$ cat /proc/sys/fs/file-max
98349
$ cat /etc/security/limits.conf
...
<username>       soft    nofile      32768
<username>       hard    nofile      65536
...
$ ulimit -Hn
65536
$ ulimit -Sn
32768

答案1

打开终端并输入

sysctl fs.inotify.max_user_watches

检查当前限制。如果你想修改它,请以 root 身份在终端中输入

vim /etc/sysctl.conf

然后在最后添加以下行

fs.inotify.max_user_watches = XXXXXX

在 XXXXXX 中输入您想要的值。

如果您仍遇到任何问题,请告诉我。

相关内容