zoukankan      html  css  js  c++  java
  • linux 最大文件打开数nofile及nr_open、file-max说明

    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等函数来调用。

  • 相关阅读:
    Algs4-2.2.1给出原地归并排序merge的排序过程
    Algs4-2.2.2给出自顶向下归并排序的排序过程
    Algs4-2.1.38不同类型的元素
    Algs4-2.1.36不均匀的数据
    Algs4-2.1.37部分有序
    Algs4-2.1.35不均匀的概率分布
    Algs4-2.1.34罕见情况
    升级python到2.7版本pip不可用
    随机验证码
    python文件操作
  • 原文地址:https://www.cnblogs.com/cheyunhua/p/14205863.html
Copyright © 2011-2022 走看看