當你的服務器在大并發達到極限時,就會報出“too many open files”。
查看線程占句柄數
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) 59367
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) unlimited
open 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) 59367
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
其中:
open files (-n) 1024 代表每個
查看系統打開句柄最大數量
more /proc/sys/fs/file-max
查看打開句柄總數
lsof|awk '{print $2}'|wc -l
根據打開文件句柄的數量降序排列,其中第二列為進程ID:
lsof|awk '{print $2}'|sort|uniq -c|sort -nr|more
根據獲取的進程ID查看進程的詳情
ps -ef |grep
修改linux單進程最大文件連接數
修改linux系統參數。vi /etc/security/limits.conf 添加
* soft nofile 65536
* hard nofile 65536
修改以後保存,注銷當前用戶,重新登錄,執行ulimit -a ,ok ,參數生效了:
————————————————
本文轉自博客「驕陽如火」
,更多精彩资讯请关注tft每日頭條,我们将持续为您更新最新资讯!