在
Linux上运行的服务器应用程序通常需要大量的打开文件处理程序,例如.
HBase ulimit,Hadoop epoll limit
此Wiki条目应作为Linux文件限制配置的纪录片.
>什么是软限制与硬限制?
>如何控制硬限制?
>如何控制软限制?
>内核fs.file-max和用户ulimit -n是否相关?
请描述您的配置有效的Linux发行版,因为各个供应商以不同的方式配置内容.
根据lstvan回复更新:
对于希望自动执行此操作的人,至少在ubuntu服务器上,您可以将其放入计算机安装脚本中:
echo 'fs.file-max = 65000' > /etc/sysctl.d/60-file-max.conf echo '* soft nofile 65000' > /etc/security/limits.d/60-nofile-limit.conf echo '* hard nofile 65000' >> /etc/security/limits.d/60-nofile-limit.conf echo 'root soft nofile 65000' >> /etc/security/limits.d/60-nofile-limit.conf echo 'root hard nofile 65000' >> /etc/security/limits.d/60-nofile-limit.conf
解决方法
您的操作系统设置了主机上任何正在运行的应用程序可以打开的文件数量限制.您可以通过修改2个配置文件轻松扩展基本值1024(通常为1024):
# vi /etc/sysctl.conf fs.file-max = 32000 # vi /etc/security/limits.conf youruser soft nofile 10000 youruser hard nofile 30000
硬和软的限制:
man 5 limits.conf
hard for enforcing hard resource limits. These limits are set by the superuser and enforced by the Kernel. The user cannot raise his requirement of system resources above such values. soft for enforcing soft resource limits. These limits are ones that the user can move up or down within the permitted range by any pre-exisiting hard limits. The values specified with this token can be thought of as default values,for normal system usage.
HTH