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: # #             # #Where: # can be: #        - an user name #        - a group name, with @group syntax #        - the wildcard *, for default entry #        - the wildcard %, can be also used with %group syntax, #                 for maxlogin limit #        - NOTE: group and wildcard limits are not applied to root. #          To apply a limit to the root user, must be #          the literal username root. # # can have the two values: #        - "soft" for enforcing the soft limits #        - "hard" for enforcing hard limits # # can be one of the following: #        - core - limits the core file size (KB) #        - data - max data size (KB) #        - fsize - maximum filesize (KB) #        - memlock - max locked-in-memory address space (KB) #        - nofile - max number of open files #        - rss - max resident set size (KB) #        - stack - max stack size (KB) #        - cpu - max CPU time (MIN) #        - nproc - max number of processes #        - as - address space limit (KB) #        - maxlogins - max number of logins for this user #        - maxsyslogins - max number of logins on the system #        - priority - the priority to run user process with #        - locks - max number of file locks the user can hold #        - sigpending - max number of pending signals #        - msgqueue - max memory used by POSIX message queues (bytes) #        - nice - max nice priority allowed to raise to values: [-20, 19] #        - rtprio - max realtime priority #        - chroot - change root to directory (Debian-specific) # #                 # #*               soft    core            0 #root            hard    core            100000
 
 
두 번 째 단계: / 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;}
 
 

좋은 웹페이지 즐겨찾기