服務(wù)器中 ulimit 的配置
系統(tǒng)級別 查看并修改 ulimit
ulimit
ulimit -a
# 命令的輸出信息:
# core file size (blocks, -c) 0
# data seg size (kbytes, -d) unlimited # 一個進程的數(shù)據(jù)段的最大值
# scheduling priority (-e) 0
# file size (blocks, -f) unlimited # Shell創(chuàng)建文件的最大體積, 1block = 512bytes
# pending signals (-i) 1031426 # 最多允許多少個待處理的信號
# max locked memory (kbytes, -l) 64 # 每個進程可以鎖住的物理內(nèi)存的最大值
# max memory size (kbytes, -m) unlimited # 每個進程可以使用的常駐內(nèi)存的最大值
# open files (-n) 65536 # 每個進程可以同時打開的最大文件數(shù), 不能是unlimited
# pipe size (512 bytes, -p) 8 # 管道的最大值, 1block = 512bytes
# POSIX message queues (bytes, -q) 819200 # POSIX的消息隊列的最大值
# real-time priority (-r) 0
# stack size (kbytes, -s) 10240 # 單個進程能夠使用的最大棧大小
# cpu time (seconds, -t) unlimited # 單個進程的最大CPU時間, 也就是可使用CPU的秒數(shù), 到硬極限時, 這個進程就會立即自殺; 到軟極限時, 每秒發(fā)送一次限制超時信號SIGXCPU
# max user processes (-u) 131072 # 單個用戶可同時運行的最大進程數(shù), 不能是unlimited
# virtual memory (kbytes, -v) unlimited # 每個進程可使用的最大虛擬內(nèi)存
# file locks (-x) unlimited # 每個進程能鎖住的最大文件個數(shù)
修改 ulimit
sed -i '/\# End of file/i * soft nofile 65535' /etc/security/limits.conf
sed -i '/\# End of file/i * hard nofile 65535' /etc/security/limits.conf
echo ulimit -SHn 65535 >> /etc/profile
source /etc/profile
查看 nginx ulimit
# ps aux | awk '{print $11}'
# netstat -anlp | grep 80 | awk '{print $7}' | grep nginx
# netstat -anlp | grep nginx | grep 80 | awk '{print $7}' | awk '{split($0,a,"/");print a[1]}'
cat /proc/$(cat /var/run/nginx.pid)/limits
# Limit Soft Limit Hard Limit Units
# Max cpu time unlimited unlimited seconds
# Max file size unlimited unlimited bytes
# Max data size unlimited unlimited bytes
# Max stack size 8388608 unlimited bytes
# Max core file size 0 unlimited bytes
# Max resident set unlimited unlimited bytes
# Max processes 13165 13165 processes
# Max open files 65535 65535 files
# Max locked memory 65536 65536 bytes
# Max address space unlimited unlimited bytes
# Max file locks unlimited unlimited locks
# Max pending signals 13165 13165 signals
# Max msgqueue size 819200 819200 bytes
# Max nice priority 0 0
# Max realtime priority 0 0
# Max realtime timeout unlimited unlimited us
grep 'open files' /proc/$(cat /var/run/nginx.pid)/limits
# Max open files 1024 4096 files
vim /usr/lib/systemd/system/nginx.service
# 在[Service]模塊下添加
# LimitNOFILE=65535
systemctl daemon-reload
systemc restart nginx
grep 'open files' /proc/$(cat /var/run/nginx.pid)/limits
# Max open files 65535 65535 files
# 查看某個進程打開的文件及文件描述符
ll proc/$(cat /var/run/nginx.pid)/fd
ll proc/430315/fd
tail -f /var/log/nginx/access.log
tail -f /var/log/nginx/access.json
tail -f /var/log/nginx/error.log
curl http://t1.wwwfff.top/get_json
curl http://119.29.161.77/get_json
curl http://127.0.0.1/get_text
# https://t1.wwwfff.top/my/wql.html
參考
https://blog.csdn.net/qq_43233213/article/details/104379607
https://zhuanlan.zhihu.com/p/60799795
http://www.rzrgm.cn/grey-wolf/p/13335275.html
浙公網(wǎng)安備 33010602011771號