这发生在 Ubuntu Release 12.04(精确)64 位内核 Linux 3.2.0-25-virtual
我正在尝试增加允许用户打开的文件数。这适用于我的 eclipse java 应用程序,其中 1024 的当前限制是不够的。
根据到目前为止我发现的帖子,我应该能够将行放入
/etc/security/limits.conf 像这样:
soft nofile 4096
hard nofile 4096
Run Code Online (Sandbox Code Playgroud)
增加允许所有用户打开的文件数。
但这对我不起作用,我认为问题与该文件无关。
对于所有用户,默认限制为 1024,无论 /etc/security/limits.conf 中的内容如何(更改该文件后我重新启动)
$ ulimit -n
1024
Run Code Online (Sandbox Code Playgroud)
现在,尽管 /etc/security/limits.conf 中的条目我无法增加:
$ ulimit -n 2048
Run Code Online (Sandbox Code Playgroud)
-bash: ulimit: open files: cannot modify limit: Operation not allowed 奇怪的是我可以向下改变限制,但不能向上改变 - 甚至回到低于原始限制的数字:
$ ulimit -n 800
$ ulimit -n
800
$ ulimit -n 900
-bash: ulimit: open files: cannot modify limit: Operation not permitted
Run Code Online (Sandbox Code Playgroud)
作为 root,我可以将限制更改为任何我想要的,向上或向下。它甚至似乎都不关心 /proc/sys/fs/file-max 中所谓的系统范围限制 …
When I try to tail -f catalina.out
, I get the error:
tail: inotify cannot be used, reverting to polling: Too many open files
Run Code Online (Sandbox Code Playgroud)
I tried the answer in this post: Too many open files - how to find the culprit
lsof | awk '{ print $2; }' | sort -rn | uniq -c | sort -rn | head
Run Code Online (Sandbox Code Playgroud)
When I ran the above command, the output was
17 6115
13 6413
10 6417
10 6415
9 6418
9 6416 …
Run Code Online (Sandbox Code Playgroud) 已经使用的lsof
,如建议打开的文件太多-如何找到罪魁祸首,我发现成千上万的文件是操作系统风格的节目,如因开放unity-2d-
,gnome-do
和nautilus
。前 50 名中只有一个是应用程序风格的程序 (firefox)。
lsof | perl -lane '$x{"$F[0]:$F[1]"}++;
END { print "$x{$_}\t$_" for sort {$x{$a}<=>$x{$b}} keys %x}' | tail -50
lsof: WARNING: can't stat() fuse.gvfs-fuse-daemon file system /var/lib/lightdm/.gvfs
Output information may be incomplete.
216 unity-2d-:26285
216 unity-2d-:31600
216 unity-2d-:2577
239 nautilus:30626
239 nautilus:3777
239 nautilus:31250
239 nautilus:30781
239 nautilus:15101
241 nautilus:26123
241 nautilus:20495
241 nautilus:9627
241 nautilus:31612
241 nautilus:26298
243 nautilus:7672
243 nautilus:603
243 nautilus:21594
243 nautilus:2590
243 nautilus:17574 …
Run Code Online (Sandbox Code Playgroud)