gpt4 book ai didi

linux - Linux中文件描述符的上限

转载 作者:IT王子 更新时间:2023-10-29 00:26:59 26 4
gpt4 key购买 nike

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

我使用的是 Ubuntu 10.04(64 位),我的服务器 CPU 架构是 x86_64,客户端是 i686。现在我已经将 fd-limit 增加到 400000。

  • 使用大编号可能产生的副作用是什么?文件描述符?
  • 我怎么知道没有。任何进程使用的文件描述符?

感谢

最佳答案

您想改为查看/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_filesfs.file-max 的设置。这最终是每 1MB 的 ram 大约 100。(10%)

关于linux - Linux中文件描述符的上限,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12970853/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com