---查看系统默认的最大文件句柄数,系统默认是1024
# ulimit -n
1024
----查看当前进程打开了多少句柄数
# lsof -n|awk '{print $2}'|sort|uniq -c|sort -nr|more
131 24204
57 24244
57 24231 ........
其中第一列是打开的句柄数,第二列是进程ID。
可以根据ID号来查看进程名。
# ps aef|grep 24204
nginx 24204 24162 99 16:15 ? 00:24:25 /usr/local/nginx/sbin/nginx -s
Linux有硬性限制和软性限制。可以通过ulimit来设定这两个参数。方法如下,以root用户运行以下命令:
# ulimit -HSn 4096
以上命令中,H指定了硬性大小,S指定了软性大小,n表示设定单个进程最大的打开文件句柄数量。个人觉得最好不要超过4096,毕竟打开的文件句柄数越多响应时间肯定会越慢。设定句柄数量后,系统重启后,又会恢复默认值。如果想永久保存下来,可以修改.bash_profile文件,可以修改 /etc/profile 把上面命令加到最后.
------------------------------------------------
lsof -n|awk '{print $2}'|sort|uniq -c|sort -nr|more
lsof: WARNING: can't stat() ext2 file system /noah/baidulinux/V2-0.0.10-opt/etc/mtab (deleted)
Output information may be incomplete.
lsof: WARNING: can't stat() ext2 file system /noah/baidulinux/V2-0.0.10-opt/etc/nsswitch.conf (deleted)
Output information may be incomplete.
lsof: WARNING: can't stat() ext2 file system /noah/baidulinux/V2-0.0.10-opt/etc/sudoers (deleted)
Output information may be incomplete.
3188 10534
3180 2779
522 1670
434 329
423 689
87 21889
59 16754
16 659
15 32311
11 32315
11 32313
11 32312
10 32317
10 32316
9 32314
linux 文件句柄数
猜你喜欢
转载自wangqiaowqo.iteye.com/blog/2338262
今日推荐
周排行