Ubuntu 12 ulimit 시스템 최대 파일 개수 설정 열기 (Nginx 에서 Too Many Open Files 오류 해결 방법 알려 주기)
5209 단어 ubuntu
Ubuntu 12 ulimit 시스템 최대 파일 개수 설정 열기 (Nginx 에서 Too Many Open Files 오류 해결 방법 알려 주기)
Too Many Open Files 오류 알림 은 열 린 파일 이 너무 많다 는 것 입 니 다. 해결 방법 도 간단 합 니 다. 저 희 는 nginx 설정 파일 이나 Liux 에서 ulimit 를 참고 하여 크게 설정 하면 문 제 를 해결 할 수 있 습 니 다. 물론 가장 중요 한 것 은 저희 프로그램의 최적화 입 니 다.
기본 명령 이해:
root@ubuntu:~# 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) 31498 max locked memory (kbytes, -l) 64 max memory size (kbytes, -m) unlimitedopen 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) 31498 virtual memory (kbytes, -v) unlimited file locks (-x) unlimited
빨 간 글자 부분 은 파일 수 1024 개 를 여 는 것 입 니 다. 보통 이것 은 너무 작 습 니 다.ulimit - n 으로 도 볼 수 있어 요.
어떻게 설정 합 니까? 공식 적 으로 는 다음 과 같 습 니 다.
첫 번 째 단계: 설정 / etc / security / limits. conf
sudo vim /etc/security/limits.conf
* hard nofile 40960
* soft nofile 40960
40960 은 스스로 설정 할 수 있 습 니 다. 4 열 매개 변수의 설정 은 영 어 를 볼 수 있 습 니 다. 간단하게 말씀 드 리 겠 습 니 다.
첫 번 째 열 은 사용자 일 수도 있 고 그룹 일 수도 있 습 니 다. @ group 과 같은 문법 을 사용 해 야 합 니 다. 예 를 들 어 *% 와 같은 마스크 일 수도 있 습 니 다.
두 번 째 열, 두 가지 값: hard, 하 드 제한, soft, 소프트웨어 제한, 일반적으로 soft 는 hard 보다 작 습 니 다. hard 는 기본 라인 입 니 다. 소프트 경 보 를 초과 해 서 는 안 됩 니 다. hard 수 까지.
세 번 째 열, 목록 참조, 파일 열기 수 는 nofile 입 니 다.
4 열, 수량, 이것 도 너무 크게 설정 할 수 없습니다.
# #Each line describes a limit for a user in the form: # #
두 번 째 단계: / etc / pam. d / su (공식) 또는 / etc / pam. d / common - session (네트워크)
sudo vim /etc/pam.d/su
pam_limits.so
sudo vim /etc/pam.d/common-session
session required pam_limits.so
/ etc / pam. d / su 를 열 면 / etc / pam. d / common - session 파일 이 포함 되 어 있 기 때문에 어떤 파일 을 수정 하 든 가능 할 것 입 니 다.
이것 은 su 라 는 파일 을 수정 하 는 것 이 좋 을 것 같 습 니 다. 주석 을 취소 하면 됩 니 다. 오류 가 발생 하지 않 습 니 다. vim 열기, 위치 추적, x 를 한 번 만 하면 됩 니 다.
정 부 는 두 번 째 단계 에 이 르 러 시스템 을 재 개 했 습 니 다. 세 번 째 단계 가 없 으 면 안 될 것 같 습 니 다. 모두 세 번 째 단계 의 역할 이 아 닌 것 같 습 니 다.!
세 번 째 단계: 설정 / etc / profile
마지막 줄 더하기
ulimit -SHn 40960
재 부팅, ulimit - n 인증, 40960 표시 하면 문제 없습니다.
업데이트: 2012 / 9 / 29:
CentOS 6.3 에 서 는 / etc / security / limits. conf 를 수정 하고 다시 로그 인하 면 됩 니 다.
Ubuntu Server 12.04.1 에서 / etc / security / limits. conf 를 수정 합 니 다. 재 로그 인 재 부팅 은 소 용이 없습니다. / etc / pam. d / common - session, su, 재 로그 인 재 부팅 은 소 용이 없습니다. 굳이 / etc / profile 을 고 쳐 야 합 니까?
보아하니 둘 은 차이 가 있 는 것 같은 데?아니면 내 가 테스트 를 못 해?
nginx. conf 파일 수정
user root;worker_processes 2;#error_log logs/error.log;#error_log logs/error.log notice;#error_log logs/error.log info;#pid logs/nginx.pid;worker_rlimit_nofile 655350;events { worker_connections 36000;}
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Ubuntu 22.04에 캐디 설치 - HostnExtra이 기사에서는 Ubuntu 22.04에 Caddy를 설치하는 방법을 설명합니다. 이 문서는 설치 프로세스를 안내하고 웹 사이트를 호스팅합니다. Caddy 웹 서버는 Go로 작성된 오픈 소스 웹 서버입니다. Ubunt...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.