우분투 ulimit 설정으로 too many open files 해결 방법

리눅스

리눅스에 설치되어 있는 MySQL을 튜닝하려 보니 MySQL의 open_files_limit 옵션값이 534,538으로 되어있지만 open_files_limit을 증가하라는 시스템의 조언(?)을 분석해보니 리눅스(우분투)의 시스템에 제한이 걸려있네요.

ulimit 설정

root@server:/# 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) 31692
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 31692
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

ulimit -a 명령어로 확인해보니 open files 값이 1024로 되어 있습니다. MySQL에서 open_files_limit 옵션값이 534,538으로 되어 있어도 의미가 없는 것이죠.

root@server:/# ulimit -Hn 4096
root@server:/# ulimit -Sn 1024

open files는 soft open files와 hard open files 값이 나뉘는데 두 값을 모두 변경해서 넉넉하게 설정할수 있습니다. 이 값은 위와 같은 같은 명령어로 확인할수 있습니다.

ulimit 명령어로 open files 값을 늘린 경우 시스템이 재부팅 되면 다시 원상태로 돌아가기 때문에 재부팅시에도 적용될 수 있게 /etc/security/limits.conf 파일을 수정해야 합니다.

#*               soft    core            0
#root            hard    core            100000
#*               hard    rss             10000
#@student        hard    nproc           20
#@faculty        soft    nproc           20
#@faculty        hard    nproc           50
#ftp             hard    nproc           0
#ftp             -       chroot          /ftp
#@student        -       maxlogins       4

에디터로 /etc/security/limits.conf 파일을 열어 우분투의 경우 하단에 위와 같이 주석처리 되어 있는 값이 보이는데 혹시 문제가 될수 있으니 주석처리된 값은 그대로 두고 아래의 값을 추가합니다.

* soft nofile 1024000
* hard nofile 1024000
mysql hard nofile 1024000
mysql soft nofile 1024000

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다

Fill out this field
Fill out this field
유효한 이메일 주소를 입력해주세요.

우분투 컴퓨터 이름 Hostname 변경하는 방법
우분투 컴퓨터 이름 hostname 변경하는 방법
우분투에서 터미널을 열거나 네트워크 공유를 사용해야할 때 표시되는 컴퓨터 이름은 hostname이라고 불리며 hostname을 변경하면 우분투에 표시되는 컴퓨터 이름을 지정할 수…