file-max 表示系统级别的能够打开的文件句柄的数量。是对整个系统的限制,并不是针对用户的。
ulimit -n 控制进程级别能够打开的文件句柄的数量。提供对shell及其启动的进程的可用文件句柄的控制。这是进程级别的。
概要:
linux系统默认open files数目为1024, 有时应用程序会报Too many open files的错误,是因为open files 数目不够。这就需要修改ulimit和file-max。特别是提供大量静态文件访问的web服务器,缓存服务器(如squid), 更要注意这个问题。
网上的教程,都只是简单说明要如何设置ulimit和file-max, 但这两者之间的关系差别,并没有仔细说明。
说明:
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是设置 系统所有进程一共可以打开的文件数量
。同时一些程序可以通过s