加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

Linux中文件描述符的上限

发布时间:2020-12-14 02:23:48 所属栏目:Linux 来源:网络整理
导读:可以在任何 Linux系统(特别是ubuntu 10.04)中使用的文件描述符的上限是多少? 我使用Ubuntu 10.04(64位),服务器的CPU架构是x86_64,客户端是i686.现在我把我的fd限制提高到了40万. 使用大号的可能的副作用是什么?的文件描述符? 我怎么知道不.任何进程使用的
可以在任何 Linux系统(特别是ubuntu 10.04)中使用的文件描述符的上限是多少?

我使用Ubuntu 10.04(64位),服务器的CPU架构是x86_64,客户端是i686.现在我把我的fd限制提高到了40万.

>使用大号的可能的副作用是什么?的文件描述符?
>我怎么知道不.任何进程使用的文件描述符?

日Thnx

解决方法

你想看看/ proc / sys / fs / file-max.

从最近的linux / Documentation / sysctl / fs.txt:

file-max and file-nr:

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

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.

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.

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的片段:

/*
 * 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_files是fs.file-max的设置.对于每1公斤的公羊,最终大约为100(10%)

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读