在CentOS中如何查看内存使用情况
时间:2019-11-20 08:52:42 来源:igfitidea点击:
如何查看Linux服务器的内存配置?
CentOS如何查看内存使用率?
在CentOS上有很多命令可以查看内存的使用情况:
- free命令
- top或htop命令
- vmstat命令
- dmidecode命令
- /proc/meminfo文件
使用free命令查看Centos内存使用率
使用free命令检查服务器中可用和已使用的物理内存和交换内存的总量
基本语法如下:
# free # free [options] # free -m # free -k # free -t # free -l # free -o # free -s 2 # free -g
输出示例
[root@theitroad ~]# free -g
total used free shared buff/cache available
Mem: 2 0 1 0 0 1
Swap: 2 0 2
可用的命令行选项如下:
-b,-k,-m,-g 以字节, KB, MB, 或者 GB单位显示 -l 显示详细的低内存和高内存统计信息 -o 使用旧格式 (没有 -/+buffers/cache 这行) -t 显示Total行(等于RAM + swap) -s 指定多少秒更新一次 -c 指定更新几次 -V 显示free的版本信息
要查看内存的使用情况,还可以使用top或htop命令
# top
或者
# htop
从/proc/meminfo文件中也可以获取内存的使用信息。
$ cat /proc/meminfo
vmstat命令
执行vmstat命令,如下所示:
# vmstat # vmstat -s
输出示例:
2655132 K total memory
407424 K used memory
323232 K active memory
184800 K inactive memory
1968320 K free memory
1116 K buffer memory
278272 K swap cache
2883580 K total swap
0 K used swap
2883580 K free swap
3994 non-nice user cpu ticks
0 nice user cpu ticks
3223 system cpu ticks
169853 idle cpu ticks
3477 IO-wait cpu ticks
0 IRQ cpu ticks
76 softirq cpu ticks
0 stolen cpu ticks
285201 pages paged in
28400 pages paged out
0 pages swapped in
0 pages swapped out
670240 interrupts
685802 CPU context switches
1608279032 boot time
3049 forks
在CentOS Linux查看内存条的型号信息:
使用dmidecode命令可以查看内存条的硬件信息
在CentOS 6/7 Linux中如何查看内存条的序列号?
Linux如何查看内存条的Part Number
在Linux中如何查看内存条的频率?
# dmidecode --type memory
输出示例
Getting SMBIOS data from sysfs.
SMBIOS 2.6 present.
Handle 0x001B, DMI type 16, 15 bytes
Physical Memory Array
Location: System Board Or Motherboard
Use: System Memory
Error Correction Type: Single-bit ECC
Maximum Capacity: 32 GB
Error Information Handle: Not Provided
Number Of Devices: 2
Handle 0x001C, DMI type 17, 28 bytes
Memory Device
Array Handle: 0x001B
Error Information Handle: Not Provided
Total Width: 64 bits
Data Width: 64 bits
Size: 2048 MB
Form Factor: DIMM
Set: 1
Locator: S1
Bank Locator: DIMM1
Type: DDR3
Type Detail: Synchronous
Speed: 1600 MT/s
Manufacturer: 017A
Serial Number: 86915424
Asset Tag: 1542
Part Number: 78.A2GCJ.AC00C
Rank: Unknown

