linux-查看服务器内存使用情况(free top)

free命令:显示系统使用和空闲的内存情况,包括物理内存、交互区内存(swap)和内核缓冲区内存。

[root@ipha-dev71-1 workspace]# free  # kb
              total        used        free      shared  buff/cache   available
Mem:       16251672    13033660      254336       45824     2963676     2630624
Swap:      16777212       31512    16745700
[root@ipha-dev71-1 workspace]# free -m   # MB
              total        used        free      shared  buff/cache   available
Mem:          15870       12728         248          44        2894        2569
Swap:         16383          30       16353
[root@ipha-dev71-1 workspace]# free -h   # -h会自动选择以适合理解的容量单位显示
              total        used        free      shared  buff/cache   available
Mem:            15G         12G        248M         44M        2.8G        2.5G
Swap:           15G         30M         15G

Mem:表示物理内存统计,如果机器剩余内存非常小,一般小于总内存的20%,则判断为系统物理内存不够
Swap: 表示硬盘上交换分区的使用情况,如剩余空间较小,需要留意当前系统内存使用情况及负载,当Swap的used值大于0时,则表示操作系统物理内存不够,已经开始使用硬盘内存了。
第1行数据11G表示物理内存总量;6.5G表示总计分配给缓存(包含buffers与cache)使用的数量,但其中可能部分缓存并未实际使用;
1.3G表示未被分配的内存;shared表示共享内存;4.0G表示系统分配但未被使用的buffers数量;4.7G表示系统分配但未被使用的available数量

top命令:查看系统的实时负载, 包括进程、CPU负载、内存使用等等;

[root@ipha-dev71-1 workspace]# top

top - 20:15:25 up 23 days, 22:27,  2 users,  load average: 0.01, 0.03, 0.05
Tasks: 173 total,   2 running, 171 sleeping,   0 stopped,   0 zombie
%Cpu(s):  0.1 us,  0.1 sy,  0.0 ni, 99.8 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem : 16251672 total,   253612 free, 13034008 used,  2964052 buff/cache
KiB Swap: 16777212 total, 16745700 free,    31512 used.  2630252 avail Mem 

   PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND                                                                                            
 46001 root      20   0 7575660 1.140g  16224 S   0.7  7.4  21:30.36 java                                                                                               
  3616 root      20   0 5552312 151452   4008 S   0.3  0.9  93:50.14 beam.smp                                                                                           
 46490 root      20   0 8365988 2.075g  16164 S   0.3 13.4  11:18.42 java                                                                                               
 48345 root      20   0 8808752 2.448g  20224 S   0.3 15.8  34:00.03 java                                                                                               
 78331 root      20   0 6818552 565924  11448 S   0.3  3.5  14:32.37 java                                                                                               
     1 root      20   0  191288   3312   2124 S   0.0  0.0   0:51.12 systemd                                                                                            
     2 root      20   0       0      0      0 S   0.0  0.0   0:00.33 kthreadd                                                                                           
     3 root      20   0       0      0      0 S   0.0  0.0   0:00.53 ksoftirqd/0                                                                                        
     5 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 kworker/0:0H                                                                                       
     7 root      rt   0       0      0      0 S   0.0  0.0   0:00.08 migration/0                                                                                        
     8 root      20   0       0      0      0 S   0.0  0.0   0:00.00 rcu_bh                                                                                             
     9 root      20   0       0      0      0 S   0.0  0.0   5:57.72 rcu_sched                                                                                          
    10 root      rt   0       0      0      0 S   0.0  0.0   0:04.27 watchdog/0    
11 root rt 0 0 0 0 S 0.0 0.0 0:03.38 watchdog/1 12 root rt 0 0 0 0 S 0.0 0.0 0:02.14 migration/1

猜你喜欢

转载自www.cnblogs.com/wang-mengmeng/p/11332848.html