linux 最大文件打开数nofile及nr_open、file-max说明

本文为研究http://www.2cto.com/os/201510/446342.html博文结论

1./etc/security/limits.conf中指定的nofile的值,nofile有上限,不是无穷大。nofile由内核参数nr_open定义的.

“在2.6.25内核之前有个宏定义,定义了这个值的最大值,为1024*1024,正好是100万,而在2.6.25内核及其之后,这个值是可以通过/proc/sys/fs/nr_open来设置。”

2.使用cat /proc/sys/fs/nr_open 查看nr_open值,可通过修改/ect/sysct.conf 修改fs.nr_open值,sysctl -p生效

3.fix_max linux内核定义的最大file handles(文件句柄数).nr_open定义是单进程最大file-handles,file-handles(即文件句柄)

 

file-max:
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
 
 
nr_open:
This denotes the maximum number of file-handles a process can
allocate. Default value is 1024*1024 (1048576) which should be
enough for most machines. Actual limit depends on RLIMIT_NOFILE
resource limit.

4.file-handles与fd

 

在UNIX/LINUX中我们接触更多是file discriptor(FD,即文件描述符),通过百度搜索,似乎file-handle在windows中是一个类似file discrptor的东东,但是我们讨论的是linux,再google一下,我们可以精确到c语言中这两个概念的区别,据他们的讨论file-handle应该是一个高层的对象,使用fopen,fread等函数来调用,而FD是底层的一个对象,可以通过open,read等函数来调用。

 

 

 

  • 0
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值