[Web] 리눅스 파일 열기 제한 수정
sudo apt-get remove supervisor
sudo apt-get install supervisor File descriptor (FD) 제한 수 확인 수정 방법
- 열수 있는 파일 최대수 변경
- php websocket event hard limit 제한도 풀수 있다.
//==============
* 확인
ulimit -a //전체
ulimit -aH //hard값
ulimit -aS //soft값
ulimit -n //open files
ulimit -u //max user process
//==========
* 프로세스 별로 오픈 된 파일 개수 확인
lsof -p PID | wc -l
//=====================
* 계정 별 FD 제한수 수정 방법
- /etc/security/limits.conf 파일 수정
[user id] soft nofile 2048
[user id] hard nofile 2048 * 파일 제한 늘리기
https://docs.beyondco.de/laravel-websockets/1.0/faq/deploying.html
//============
- 상태보기
ulimit -n
- aws ec2 의 경우 1024 상태
- 제한 수 설정
ulimit -n 30000 // 재부팅하면 무효
파일 수정 - 재부팅 해도 유지 되도록 수정
nano /etc/security/limits.conf
* soft nofile 10000
* hard nofile 10000
root soft nofile 20000
root hard nofile 20000
ubuntu soft nofile 20000
ubuntu hard nofile 20000
www-data soft nofile 20000
www-data hard nofile 20000
//====================
sueprvisor의 열기 가능한 파일 수 늘리기
* supervisor 설정
- 열기 가능한 파일 수 증가 시키기
nano /etc/supervisor/supervisord.conf
[supervisord]
minfds=10240 ; (min. avail startup file descriptors;default 1024)
service supervisor restart
supervisorctl reload
//-------------------------------------
- 에러 발생
supervisorctl reload
error: <class 'socket.error'>, [Errno 2] No such file or directory: file: /usr/lib/python2.7/socket.py line: 228
- 해결 방법
- 원인 : ";" 띄어쓰기 문제
minfds=10240 뒤에 ;을 띄운다
//-------------------------------------
- 에러 발생
supervisorctl error No such file or directory: file: /usr/lib/python3/dist-packages/supervisor/xmlrpc.py
- 발생 원인 : OS 업그레이드 후에 발생시 supervisor를 재설치 한다
sudo apt-get remove supervisor
sudo apt-get install supervisor
//====================================
// 참고
//==========
* 시스템 FD 수정
/proc/sys/fs/file-max
- AWS EC2 는 400200 로 설정되어 있음
/etc/sysctl.conf
- 모두 주석 처리 되어있는 상태
//==========
//참고 만
/etc/security/limits.d 폴더 밑에 파일 생성
$ cat /etc/security/limits.d/laravel-echo.conf
laravel-echo soft nofile 10000
//=============
// 참고
http://blog.naver.com/ryangjm/10170724995