Too many open files - ulimit, /etc/security/limits.conf
ulimit과 관련된 대표적인 에러이다. ulimit은 세션에 대해서만 적용되므로 기타 환경파일을 수정해주어야 한다.
ulimit은 하드웨어값과 소프트웨어값 두 부분을 컨트롤할 수 있다. soft값은 hard값을 초과할 수 없다.
The ulimit provides control over the resources available to the shell and to processes started by it, on systems that allow such control. The -H and -S options specify that the hard or soft limit is set for the given resource.
- A hard limit cannot be increased once it is set
- A soft limit may be increased up to the value of the hard limit.
일차적으로 ulimit -n 10240 으로 수정한다.
디폴드값으로 HARD로 셋팅이 되어있통이고, 리붓 후에도 설정을 유지하려면 /etc/security/limits.conf 에 Hard/Soft 설정 값을 다음과 같이 설정한다.
[root@blog-dbsettest ~]# cat /etc/security/limits.conf
# /etc/security/limits.conf
#
#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 address space (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
# - 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)
#
#<domain> <type> <item> <value>
#
#* soft core 0
#* hard rss 10000
#@student hard nproc 20
#@faculty soft nproc 20
#@faculty hard nproc 50
#ftp hard nproc 0
#@student - maxlogins 4
* hard nofile 10240
* soft nofile 10240
# End of file
#* hard rss 10000
#@student hard nproc 20
#@faculty soft nproc 20
#@faculty hard nproc 50
#ftp hard nproc 0
#@student - maxlogins 4
* hard nofile 10240
* soft nofile 10240
# End of file
열려있는 파일의 갯수는 sysctl -a | grep file-nr 로 확인할 수 있다.
[root@blog-dbsettest ~]# sysctl -a | grep file
fs.file-max = 81920
fs.file-nr = 8955 0 81920
fs.file-max = 81920
fs.file-nr = 8955 0 81920