Linux中文件描述符的上限 [英] Upper limit of file descriptor in Linux

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

问题描述

在任何Linux系统(特别是ubuntu 10.04)中可以使用的文件描述符的上限是多少?

what is the upper limit of file-descriptor that can be used in any Linux system (specifically ubuntu 10.04)?

我正在使用Ubuntu 10.04(64位),我的服务器CPU结构是x86_64,而客户端的CPU体系结构是i686.现在,我已将fd限制提高到了400000.

I am using Ubuntu 10.04 (64-bit) and my CPU architecture for server is x86_64 and for client it is i686. Right now I had increased my fd-limit to 400000.

  • 使用大号可能会产生哪些副作用?文件描述符?
  • 我怎么知道不.任何进程都使用文件描述符吗?

Thnx

推荐答案

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

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

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

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

file-max和file-nr:

file-max and 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".

2.6内核使用经验法则根据系统中的内存量设置file-max. 2.6内核中的fs/file_table.c的摘录:

The 2.6 kernel uses a rule of thumb to set file-max based on the amount of memory in the system. A snippet from fs/file_table.c in the 2.6 kernel:

/*
 * One file with associated inode and dcache is very roughly 1K.
 * Per default don't use more than 10% of our memory for files. 
 */ 

n = (mempages * (PAGE_SIZE / 1024)) / 10;
files_stat.max_files = max_t(unsigned long, n, NR_FILE);

files_stat.max_filesfs.file-max的设置.最终,每1MB内存大约有100.(10%)

The files_stat.max_files is the setting of fs.file-max. This ends up being about 100 for every 1MB of ram.(10%)

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

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