linux文件描述符限制如何工作? [英] How do linux file descriptor limits work?

查看:91
本文介绍了linux文件描述符限制如何工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人告诉我,我的服务器拒绝在特定端口接受客户端网络连接可能是由于缺少文件描述符所致.我查找了所有内容并在此处阅读: http://www.netadmintools.com/art295.html

I was told that my server refused to accept client network connections at a specific port could be due to the lack of file descriptors. I looked up what this is all about and read about it here: http://www.netadmintools.com/art295.html

所以我测试了我的系统,我得到了:

So I tested my system and I got this:

cat /proc/sys/fs/file-nr
1088    0   331287

这是什么意思?我的限制很高,但是我有0个可用的文件描述符?为什么?如何为我的服务器解决此问题?

What does this mean? My limit is quite high yet I have 0 available file descriptors? why? How do I solve this for my server?

即使我关闭服务器后,第二列实际上仍为0,甚至在引导后也始终为0!

The second column actually stays at 0 even after I shutdown my server, it even stays at 0 even right after a boot!

推荐答案

您想改用/proc/sys/fs/file-max

You want to look at /proc/sys/fs/file-max instead

来自最近的linux/Documentation/sysctl/fs.txt:

From recent linux/Documentation/sysctl/fs.txt:

file-max& file-nr:

file-max & file-nr:

内核动态分配文件句柄,但到目前为止 不会再释放它们.

The kernel allocates file handles dynamically, but as yet it doesn't free them again.

file-max中的值表示最大文件数- 处理Linux内核将分配的内容.当你有很多 有关文件句柄用尽的错误消息,您可能 要增加此限制.

The value in file-max denotes the maximum number of file- handles that the Linux kernel will allocate. When you get lots of error messages about running out of file handles, you might want to increase this limit.

从历史上看,file-nr中的三个值表示 已分配文件句柄,已分配但未使用的文件数 句柄,以及最大文件句柄数.始终为Linux 2.6 报告0作为空闲文件句柄的数量-这不是一个 错误,仅表示分配的文件句柄数 与使用的文件句柄数量完全匹配.

Historically, the three values in file-nr denoted the number of allocated file handles, the number of allocated but unused file handles, and the maximum number of file handles. Linux 2.6 always reports 0 as the number of free file handles -- this is not an error, it just means that the number of allocated file handles exactly matches the number of used file handles.

尝试分配的文件描述符比file-max多 用printk报告,查找"VFS:文件最大限制 达到".

Attempts to allocate more file descriptors than file-max are reported with printk, look for "VFS: file-max limit reached".

潜在的错误可能不是系统用尽了全局文件描述符,而仅仅是您的进程.问题似乎可能是 select的最大大小限制.

the underlying error is probably not the system running out of global filedescriptors, but just your process. It seems likely that the the problem is the maximum size limit of select.

这篇关于linux文件描述符限制如何工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆