기계는 거짓말하지 않는다

Ubuntu Too many open files error (ulimit) 본문

Linux

Ubuntu Too many open files error (ulimit)

KillinTime 2023. 3. 18. 21:16

Too many open files error 또는 비슷한 류의 리소스 한계 오류를 보는 경우가 있다.

이 오류는 파일디스크립터 한계 오류이다.

ulimit를 설정하여 해결할 수 있다.

일시, 임시적인 설정 변경

임시적인 자원 한계를 확인, 설정하는 경우

ulimit command

 

ulimit Man Page - Linux - SS64.com

ulimit User limits - limit the use of system-wide resources. Syntax ulimit [-HS] -a ulimit [-HS] [-bcdefiklmnpqrstuvxPRT] [limit] Key -S Set a soft limit for the given resource. -H Set a hard limit for the given resource. -a All current limits are reported

ss64.com

# 설정된 ulimit 확인
ulimit -a
# open file descriptor 변경
# ex) ulimit -n 4096
ulimit -n [limit]

영구 설정 변경

/etc/security/limits.conf 파일을 수정한다.

계정, 타입, 유형, 한계 순으로 설정하며, 각 항목은 Tab 키를 이용하여 구분한다.

type의 soft는 기본 한계 값이고 hard는 soft 이상의 값에서 더 늘어날 수 있는 최대 값이다.

limits.conf configuration option

 

limits.conf Man Page - Linux - SS64.com

* A username * A groupname, with @group syntax. This should not be confused with netgroups. * The wildcard *, for default entry. * The wildcard %, for maxlogins limit only, can also be used with %group syntax.

ss64.com

root	soft	nofile	4096
root	hard	nofile	4096
Comments