【linux 内存占满】linux 内存排查技巧
1、执行 free -h查看内存使用情况(base) [root@HK-AI sinoma]# free -htotal used free shared buff/cache availableMem: 31G 24G 766M 121M 6.2G 6.3GSwap: 15G 0B 15G(base) [root@HK-AI sinoma]#2、内存不足,查看使用top5 内存的进程,命令 :t
·
1、执行 free -h 查看内存使用情况
(base) [root@HK-AI sinoma]# free -h
total used free shared buff/cache available
Mem: 31G 24G 766M 121M 6.2G 6.3G
Swap: 15G 0B 15G
(base) [root@HK-AI sinoma]#
2、内存不足,查看使用top5 内存的进程,命令 :top -d 5
(base) [root@HK-AI sinoma]# top -d 5
top - 14:01:01 up 133 days, 23:36, 2 users, load average: 0.28, 0.31, 0.31
Tasks: 271 total, 1 running, 269 sleeping, 1 stopped, 0 zombie
%Cpu(s): 5.7 us, 1.1 sy, 0.0 ni, 93.2 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
KiB Mem : 32765644 total, 781904 free, 25436940 used, 6546800 buff/cache
KiB Swap: 16515068 total, 16515068 free, 0 used. 6628184 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
62303 root 20 0 1451716 129672 34580 S 26.9 0.4 5181:00 python
50264 root 20 0 25.140g 0.021t 72676 S 2.6 68.4 885:09.28 gunicorn
39928 root 20 0 3357936 260700 71920 S 2.2 0.8 422:02.91 gunicorn
55800 root 20 0 1218432 211736 64816 S 2.2 0.6 126:58.33 gunicorn
39929 root 20 0 3357884 260596 71892 S 2.0 0.8 422:25.18 gunicorn
39930 root 20 0 3357884 260600 71892 S 1.8 0.8 422:04.32 gunicorn
44877 root 20 0 1259376 105180 24668 S 1.2 0.3 2:58.28 gunicorn
70119 root 20 0 1264004 106504 25532 S 1.0 0.3 308:48.43 gunicorn
86168 root 20 0 762268 73000 16920 S 1.0 0.2 286:02.25 gunicorn
10736 root 20 0 784888 73532 16424 S 0.8 0.2 698:23.85 gunicorn
45111 root 20 0 655692 74304 11496 S 0.8 0.2 1250:20 gunicorn
45766 root 20 0 763376 73956 16304 S 0.8 0.2 1:58.73 gunicorn
45768 root 20 0 763764 74080 16304 S 0.8 0.2 1:58.24 gunicorn
48597 root 20 0 761748 72684 16624 S 0.8 0.2 601:45.05 gunicorn
51164 root 20 0 785516 73836 16452 S 0.8 0.2 610:05.30 gunicorn
69875 root 20 0 764040 74412 16248 S 0.8 0.2 232:01.43 gunicorn
77789 root 20 0 761384 71872 16124 S 0.8 0.2 1039:22 gunicorn
78970 root 20 0 761388 71992 16144 S 0.8 0.2 1025:46 gunicorn
83742 root 20 0 785160 73504 16420 S 0.8 0.2 637:08.82 gunicorn
85718 root 20 0 761568 72520 16616 S 0.8 0.2 289:49.45 gunicorn
19462 root 20 0 763652 74016 16232 S 0.6 0.2 9:54.89 gunicorn
45767 root 20 0 763380 73844 16312 S 0.6 0.2 1:58.08 gunicorn
46108 root 20 0 624712 43312 10324 S 0.6 0.1 1:32.70 gunicorn
55609 root 20 0 623584 42476 10204 S 0.6 0.1 451:12.10 gunicorn
90560 root 20 0 761708 72592 16176 S 0.6 0.2 699:16.52 gunicorn
9 root 20 0 0 0 0 S 0.2 0.0 99:47.62 rcu_sched
848 root 20 0 305128 6184 4812 S 0.2 0.0 154:31.00 vmtoolsd
25374 root 20 0 840960 36396 16280 S 0.2 0.1 0:10.53 containerd
39764 root 20 0 933328 109608 32260 S 0.2 0.3 125:28.23 python
51465 root 20 0 157904 2420 1572 R 0.2 0.0 0:00.03 top
62222 root 20 0 755640 74564 16648 S 0.2 0.2 7:55.19 gunicorn
86165 root 20 0 148332 19112 2400 S 0.2 0.1 4:46.62 gunicorn
90557 root 20 0 148216 19116 2404 S 0.2 0.1 11:36.28 gunicorn
1 root 20 0 193528 6472 3940 S 0.0 0.0 4:31.11 systemd
2 root 20 0 0 0 0 S 0.0 0.0 0:02.81 kthreadd
可见进程 50264 和 62303 占用内存最多,其中50264 占用了68.4%的大内存,总共32G,占用了21G左右,明显不对。
解决办法:杀死该进程。
(base) [root@HK-AI ~]# ps -ef|grep 50264
root 50264 50261 2 Sep02 ? 14:45:13 /root/anaconda3/envs/model/bin/python /root/anaconda3/envs/model/bin/gunicorn -b 172.16.1.224:8006 best_raw_feed_main:app -c gunicorn_conf.py -k uvicorn.workers.UvicornWorker --limit-request-line 0
root 51599 51523 0 14:04 pts/0 00:00:00 grep --color=auto 50264
(base) [root@HK-AI ~]# kill -9 50264
(base) [root@HK-AI ~]# free -h
total used free shared buff/cache available
Mem: 31G 3.1G 21G 121M 6.2G 27G
Swap: 15G 0B 15G
内存恢复到27G左右。正常了。
更多推荐
已为社区贡献9条内容
所有评论(0)