典型的,提供大量静态文件访问的web服务器,缓存服务器(如squid), 均要注意这个问题
网上的教程,大约只是简单说明了如何设置ulimit和file-max, 但并没有说清楚这两者之间的差别,让人一头雾水
1. file-max的含义
man proc,可得到file-max的描述:
/proc/sys/fs/file-max
This file defines a system-wide limit on the number of open files for all processes. (See
also setrlimit(2), which can be used by a process to set the per-process limit,
RLIMIT_NOFILE, on the number of files it may open.) If you get lots of error messages
about running out of file handles, try increasing this value:
即file-max是设置
系统所有进程一共可以打开的文件数量
。同时一些程序可以通过setrlimit调用,设置每个进程的限制。如果得到大量使用完文件句柄的错误信息,是应该增加这个值。
也就是说,这项参数是系统级别的。
echo 6553560 > /proc/sys/fs/file-max
或修改 /etc/sysctl.conf, 加入
fs.file-max = 6553560 重启生效
2. ulimit的
Provides control over the resources available to the shell and to processes started by it, on systems that allow such control.
即设置当前shell以及由它启动的进程的资源限制。
显然,对服务器来说,file-max, ulimit都需要设置,否则就可能出现文件描述符用尽的问题,为了让机器在重启之后仍然有效,强烈建立作以下配置,以确保file-max, ulimit的值正确无误:
1. 修改/etc/sysctl.conf, 加入
fs.file-max = 6553560
2.系统默认的ulimit对文件打开数量的限制是1024,修改/etc/security/limits.conf并加入以下配置,永久生效
* soft nofile 65535
* hard nofile 65535
修改完之后,重启即可生效
分享到:
相关推荐
/proc/sys/fs/file-nr 当前kernel的句柄The value in file-max denotes the maximum number
设置Linux打开文件句柄/proc/sys/fs/file-max和ulimit -n的区别表示系统级别的能够打开的文件句柄的数量.是对整个系统的限制,并不是
如果你不进行修改并发量上来的时候会出现“Too Many Open Files”的错误,导致整个HBase不可运行,你可以用ulimit -n 命令进行修改,或者修改/etc/security/limits.conf 和/proc/sys/fs/file-max的参数,具体如何...
ulimit -n 1024 set rlim_fd_cur=1024 Acknowledgments ---------------- The Apache Lucene project is the basis for this software, so the biggest acknoledgment goes to that project. We wish to ...
fs.file-max=65536 net.ipv4.ip_local_port_range=1024 65000 net.core.rmem_default=262144 net.core.wmem_default=262144 net.core.rmem_max=262144 net.core.wmem_max=262144 [root@rac01 ~]# sysctl -p [root@...
/opt/nexus-data \ -p 8081:8081 -p 5000:5000 \ --ulimit nofile=65536 \ --name nexus-repository-oss \ 04n0/nexusrepmanoss:3.30-alpine 如果需要覆盖JVM内存的默认配置,则可以将环境变量JVM_HEAP_MIN和/或JVM_...
baseurl=file:///mnt/ClusterStorage/ enabled=1 gpgcheck=0 挂载光驱到/mnt目录 [root@node1 yum.repos.d]# mount /dev/hdc /mnt mount: block device /dev/hdc is write-protected, mounting read-only [root@...
#如何取定文件与文件集的对应关系,有时想使用某个安装文件, 但没有安装包含该文件的文件集,找到文件集来安装所需文件 首先确认系统中已经安装了“bos.content_list”文件集(fileset), 如果没有安装, 请使用smitty ...
6. ulimit -n 2048 srs_app_config.cpp 增加代码修改 进程可打开的最大文件描述词大一的值,超出此值,将会产生EMFILE错误 rlimit l; getrlimit(RLIMIT_NOFILE,&l); l.rlim_cur = get_max_connections() + 100;...
首先我们可以通过ulimit –a命令来查看系统的一些资源限制情况,如下: # ulimit -a core file size (blocks, -c) 1024 data seg size (kbytes, -d) unlimited scheduling priority (-e) 0 file size (blocks, -f) ...
ulimit -a core file size (blocks, -c) 0 data seg size (kbytes, -d) unlimited scheduling priority (-e) 0 file size (blocks, -f) unlimited pending signals (-i) 7268 max locked memory (kbytes, -l) 64 max...
当open_files_limit没有被配置的时候,比较max_connections*5和ulimit -n的值,哪个大用哪个, # 当open_file_limit被配置的时候,比较open_files_limit和max_connections*5的值,哪个大用哪个. table_open_cache = ...
脚本中加入ulimit -a >> 1.log 打印如下: core file size (blocks, -c) 0 data seg size (kbytes, -d) unlimited scheduling priority (-e) 0 file size (blocks, -f) unlimited pending signals (-i) 127364 max ...