웹서버/nginx

"too many open files" error

janggos 2024. 2. 10. 18:08

열려 있는 파일이 많을 때 오류 메시지가 나타나면 열린 파일 수를 늘려야 합니다.

절차는 다음과 같습니다.

현재 한도를 확인하고 한도를 늘린 다음 새 한도가 설정되었는지 확인하세요.

첫 번째 단계는 엔진의 프로세스 ID 번호를 결정해야 하는 것입니다.

# ps aux | grep www-data
www-data   30205  0.0  0.8  59916  8580 ?        S<   17:24   0:01 nginx: worker process
root       30229  0.0  0.2   7792  2320 pts/1    S+   17:59   0:00 grep --color=auto www-data

 

# cat /proc/30205/limits
Limit                     Soft Limit           Hard Limit           Units
Max cpu time              unlimited            unlimited            seconds
Max file size             unlimited            unlimited            bytes
Max data size             unlimited            unlimited            bytes
Max stack size            8388608              unlimited            bytes
Max core file size        0                    unlimited            bytes
Max resident set          unlimited            unlimited            bytes
Max processes             3721                 3721                 processes
Max open files            30000                30000                files
Max locked memory         65536                65536                bytes
Max address space         unlimited            unlimited            bytes
Max file locks            unlimited            unlimited            locks
Max pending signals       3721                 3721                 signals
Max msgqueue size         819200               819200               bytes
Max nice priority         0                    0
Max realtime priority     0                    0
Max realtime timeout      unlimited            unlimited            us

 

sudo vi /etc/nginx/nginx.conf

user www-data;
worker_processes auto;
worker_rlimit_nofile 30000; <= 45000 수정
worker_priority -10;
timer_resolution 100ms;
pcre_jit on;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;

 

nginx -t;

systemctl restart nginx;

# ps aux | grep www-data;

 

#ps aux | grep www-data
www-data   30267  0.1  0.8  59916  7944 ?        S<   18:05   0:00 nginx: worker process
root       30270  0.0  0.2   7792  2284 pts/1    S+   18:05   0:00 grep --color=auto www-data

 

# cat /proc/30267/limits
Limit                     Soft Limit           Hard Limit           Units
Max cpu time              unlimited            unlimited            seconds
Max file size             unlimited            unlimited            bytes
Max data size             unlimited            unlimited            bytes
Max stack size            8388608              unlimited            bytes
Max core file size        0                    unlimited            bytes
Max resident set          unlimited            unlimited            bytes
Max processes             3721                 3721                 processes
Max open files            45000                45000                files
Max locked memory         65536                65536                bytes
Max address space         unlimited            unlimited            bytes
Max file locks            unlimited            unlimited            locks
Max pending signals       3721                 3721                 signals
Max msgqueue size         819200               819200               bytes
Max nice priority         0                    0
Max realtime priority     0                    0
Max realtime timeout      unlimited            unlimited            us