Linux Increase The Maximum Number Of Open Files / File Descriptors (FD)

Posted 遠離塵世の方舟

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Linux Increase The Maximum Number Of Open Files / File Descriptors (FD)相关的知识,希望对你有一定的参考价值。

How do I increase the maximum number of open files under CentOS Linux? How do I open more file descriptors under Linux?

技术分享

The ulimit command provides control over the resources available to the shell and/or to processes started by it, on systems that allow such control. The maximum number of open file descriptors displayed with following command (login as the root user).

Command To List Number Of Open File Descriptors

Use the following command command to display maximum number of open file descriptors:
cat /proc/sys/fs/file-max
Output:

75000

75000 files normal user can have open in single login session. To see the hard and soft values, issue the command as follows:
# ulimit -Hn
# ulimit -Sn

To see the hard and soft values for httpd or oracle user, issue the command as follows:
# su - username
In this example, su to oracle user, enter:
# su - oracle
$ ulimit -Hn
$ ulimit -Sn

System-wide File Descriptors (FD) Limits

The number of concurrently open file descriptors throughout the system can be changed via /etc/sysctl.conf file under Linux operating systems.

The Number Of Maximum Files Was Reached, How Do I Fix This Problem?

Many application such as Oracle database or Apache web server needs this range quite higher. So you can increase the maximum number of open files by setting a new value in kernel variable /proc/sys/fs/file-max as follows (login as the root):
# sysctl -w fs.file-max=100000
Above command forces the limit to 100000 files. You need to edit /etc/sysctl.conf file and put following line so that after reboot the setting will remain as it is:
# vi /etc/sysctl.conf
Append a config directive as follows:
fs.file-max = 100000
Save and close the file. Users need to log out and log back in again to changes take effect or just type the following command:
# sysctl -p
Verify your settings with command:
# cat /proc/sys/fs/file-max
OR
# sysctl fs.file-max

User Level FD Limits

The above procedure sets system-wide file descriptors (FD) limits. However, you can limit httpd (or any other users) user to specific limits by editing /etc/security/limits.conf file, enter:
# vi /etc/security/limits.conf
Set httpd user soft and hard limits as follows:
httpd soft nofile 4096
httpd hard nofile 10240

Save and close the file. To see limits, enter:
# su - httpd
$ ulimit -Hn
$ ulimit -Sn

A note about RHEL/CentOS/Fedora/Scientific Linux users

Edit /etc/pam.d/login file and add/modify the following line (make sure you get pam_limts.so):

session required pam_limits.so

Save and close the file.

FROM:https://www.cyberciti.biz/faq/linux-increase-the-maximum-number-of-open-files/
































以上是关于Linux Increase The Maximum Number Of Open Files / File Descriptors (FD)的主要内容,如果未能解决你的问题,请参考以下文章

转: Linux磁盘扩容

sklearn 逻辑回归Increase the number of iterations (max_iter) or scale the data as shown in解决方案

记录Nginx错误could not build the server_names_hash you should increase server_names_hash_bucket_size:

Codeforces 999D Equalize the Remainders 数据结构贪心

Prometheus 中的 increase() 有时会使值翻倍:如何避免?

Velocity——#macro 指令