如何增加允许在Linux上打开的文件数?

On my system:

在我的系统上:

$ ulimit -n
1024

Some tools like GATK are aggressive in creating temporary files by creating more than 1000 files under /tmp/. This will cause the program to fail.

某些GATK之类的工具通过在/ tmp /下创建1000多个文件来积极创建临时文件。 这将导致程序失败。

How to increase the number of files allowed to be opened on Linux?

如何增加Linux上允许打开的文件数?

To increase the max number of open files to 10240, add these 2 lines to /etc/security/limits.conf:

要将打开文件的最大数量增加到10240,请将这两行添加到/etc/security/limits.conf

*                hard   nofile           10240
*                soft   nofile           10240

The users may need to re-login to see the limits changed by:

用户可能需要重新登录才能查看更改的限制:

ulimit -n

You can also set more limits:

您还可以设置更多限制:

#Each line describes a limit for a user in the form:
#
#<domain>        <type>  <item>  <value>
#
#Where:
#<domain> can be:
#        - an user name
#        - a group name, with @group syntax
#        - the wildcard *, for default entry
#        - the wildcard %, can be also used with %group syntax,
#                 for maxlogin limit
#
#<type> can have the two values:
#        - "soft" for enforcing the soft limits
#        - "hard" for enforcing hard limits
#
#<item> can be one of the following:
#        - core - limits the core file size (KB)
#        - data - max data size (KB)
#        - fsize - maximum filesize (KB)
#        - memlock - max locked-in-memory addressspace (KB)
#        - nofile - max number of open files
#        - rss - max resident set size (KB)
#        - stack - max stack size (KB)
#        - cpu - max CPU time (MIN)
#        - nproc - max number of processes
#        - as - address space limit (KB)
#        - maxlogins - max number of logins for this user
#        - maxsyslogins - max number of logins on the system
#        - priority - the priority to run user process with
#        - locks - max number of file locks the user can hold
#        - sigpending - max number of pending signals
#        - msgqueue - max memory used by POSIX message queues (bytes)
#        - nice - max nice priority allowed to raise to values: [-20, 19]
#        - rtprio - max realtime priority
Answered by Eric Z Ma.
埃里克·马(Eric Z Ma)回答。

翻译自: https://www.systutorials.com/how-to-increase-the-number-of-files-allowed-to-be-opened-on-linux/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Linux系统中,每个进程都有一个文件描述符表,用于跟踪它打开文件文件描述符是一个非负整,它在打开文件时由内核分配。 Linux对进程打开文件设置了限制,这个限制被称为文件描述符限制或打开文件限制。这个限制控制了一个进程能够同时打开文件量。 文件描述符限制通常由操作系统的配置文件中的参控制。我们可以通过 ulimit 命令来查看和修改这些限制。 默认情况下,一个进程可以打开1024个文件。但是,这个限制是可以根据系统的需求进行修改的。一般来说,增加文件描述符限制可能会消耗更多的系统资源。 如果一个进程需要打开更多的文件,可以通过修改操作系统配置文件增加文件描述符限制。比如,在/etc/security/limits.conf文件中,可以通过添加如下行来增加文件描述符限制: * soft nofile 4096 * hard nofile 8192 这将允许所有用户的进程打开文件上限分别为4096和8192。 需要注意的是,文件描述符限制是针对每个进程的,而不是整个系统。这意味着,每个进程都可以独立地设置自己的文件描述符限制,并且不会影响其他进程。 Linux进程的文件描述符限制对于保护系统的稳定性和安全性非常重要。通过合理设置文件描述符限制,可以防止一个进程占用过多的系统资源,从而避免系统崩溃或资源竞争的问题。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值