![/etc/security/limits.conf와 /proc/$PID/limits의 차이점](https://linux55.com/image/129008/%2Fetc%2Fsecurity%2Flimits.conf%EC%99%80%20%2Fproc%2F%24PID%2Flimits%EC%9D%98%20%EC%B0%A8%EC%9D%B4%EC%A0%90.png)
내 구성 /etc/security/limits.conf
은
* soft nofile 60000
* hard nofile 60000
우분투에서 nginx를 실행하고 있습니다. 우분투를 다시 시작하니 ulimit -n
60000 인데
cat /proc/`ps -elf | grep nginx | grep 'master process' | awk '{print $4}'`/limits| grep 'open files'
대답은 1024인데 왜 60000이 아닌가?
답변1
/etc/security/limits.conf
로그인 시 PAM 모듈에서 읽습니다 pam_limits.so
.
그러나 부팅 시 nginx가 시작되면 로그인 프로세스를 거치지 않으므로 PAM은 nginx 프로세스나 해당 상위 항목을 무제한으로 변경할 기회를 얻지 못합니다.
nginx
스크립트에서 시작하는 경우 스크립트에 ulimit 명령을 추가해야 합니다.
ulimit -H -n 60000
ulimit -S -n 60000
.service 파일로 시작된 경우 nginx
다음 줄을 사용하여 파일 섹션에 추가하세요.systemd
systemctl edit nginx.service
[Service]
LimitNOFILE=60000:60000
systemctl edit some.service
원래 서비스 파일은 트리에서 자동으로 가져오고 [/usr]/lib/systemd
수정된 버전은 아래에 배치됩니다 /etc/systemd
. 의 모든 파일은 /etc/systemd
트리에서 동일한 이름을 가진 모든 파일을 덮어씁니다 [/usr]/lib/systemd
.
또한 서비스 구성이 자동으로 다시 로드되므로 systemctl daemon-reload
수동으로 수행할 필요가 없습니다.