在Redhat/CentOS Linux中,如何查看内存的大小

时间:2019-11-20 08:52:48  来源:igfitidea点击:

如何查看Red Hat Enterprise Linux服务器上的内存大小?
在CentOS Linux如何使用命令查看系统的内存大小和内存使用率?

查看/proc/meminfo文件

$ cat /proc/meminfo

输出示例:

MemTotal:        1421696 kB
MemFree:          213280 kB
MemAvailable:     439948 kB
Buffers:               0 kB
Cached:           325404 kB
SwapCached:         2332 kB
Active:           412564 kB
Inactive:         417124 kB
Active(anon):     197340 kB
Inactive(anon):   329208 kB
Active(file):     215224 kB
Inactive(file):    87916 kB
Unevictable:           0 kB
Mlocked:               0 kB
SwapTotal:       2097148 kB
SwapFree:        2082812 kB
Dirty:                 0 kB
Writeback:             0 kB
AnonPages:        501952 kB
Mapped:            56008 kB
Shmem:             22264 kB
Slab:             190256 kB
SReclaimable:     105780 kB
SUnreclaim:        84476 kB
KernelStack:        9776 kB
PageTables:        35488 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:     2807996 kB
Committed_AS:    3999332 kB
VmallocTotal:   34359738367 kB
VmallocUsed:      230676 kB
VmallocChunk:   34359277564 kB
Percpu:            55808 kB
HardwareCorrupted:     0 kB
AnonHugePages:    118784 kB
CmaTotal:              0 kB
CmaFree:               0 kB
HugePages_Total:       0
HugePages_Free:        0
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB
DirectMap4k:      132992 kB
DirectMap2M:     1349632 kB

使用free命令查看内存使用情况

free命令可以显示可用和已经使用的内存量:

$ free -m
$ free -g
$ free -k

输出示例:

              total        used        free      shared  buff/cache   available
Mem:        1421696      777316      213188       22268      431192      439860
Swap:       2097148       14336     2082812

使用top命令查看内存和内存使用量

$ top

输出示例:

KiB Mem :  1421696 total,   212544 free,   777712 used,   431440 buff/cache
KiB Swap:  2097148 total,  2082812 free,    14336 used.   439468 avail Mem 

使用其他命令查看内存的试验情况

vmstat命令可以显示内存统计信息,包括有关进程,页面调度,块IO,陷阱和cpu活动的其他信息。

$ vmstat
$ vmstat -s

使用dmidecode命令可以查看内存硬件的相关信息,包括内存SN号,频率等信息:

# dmidecode --type memory

输出示例:

Handle 0x0085, DMI type 6, 12 bytes
Memory Module Information
        Socket Designation: RAM socket #0
        Bank Connections: None
        Current Speed: Unknown
        Type: EDO DIMM
        Installed Size: 1024 MB (Single-bank Connection)
        Enabled Size: 1024 MB (Single-bank Connection)
        Error Status: OK