too many files open in system

too many files open in system

  1. 查看哪个用户或进程占用的文件多
#查看进程打开文件数最多的前5个进程
lsof | awk '{print $2}' | sort | uniq -c | sort -rn | head  -n 5

lsof -n| awk '{print $2}' | sort | uniq -c | sort -rn | head  -n 5  #好像执行的会快一点

[root@wnm ~]# lsof | awk '{print $2}' | sort | uniq -c | sort -rn | head -n 5 
 103204 7496
    139 29471
    116 22525
     58 13509
     49 4612

按进程pid的查看
lsof -p pid | wc -l      

[root@wnm ~]# lsof -p 7496 |wc -l
103204

按用户查看
lsof -u user | wc -l             

[root@wnm ~]# lsof -u mysql|wc -l
103321

还能按端口查看
lsof -i:port 
  1. 发现。。™的果然是mysql 占用的,里面一堆分区表
flush tables ;
把表全关了,问题解决

[root@wnm ~]# lsof | awk '{print $2}' | sort | uniq -c | sort -rn | head -n 5 
    139 29471
    115 7496
    115 22525
     58 13509
     49 4612

  1. 修改 Linux 系统限制
ulimit -n 655350
echo "* soft nofile 655350" >> /etc/security/limits.conf
posted @ 2024-03-12 10:12  Coye  阅读(3)  评论(0编辑  收藏  举报