各位搞运维的童鞋们,一定经历过服务器要扩容内存,但是需要打各种电话确认服务器的硬件情况,等等等等……
苦恼。。。。。。
忙活半天,原来在linux下是可以直接读取硬件参数来判断的


Linux 查看内存的插槽数,已经使用多少插槽。每条内存多大,已使用内存多大
# dmidecode|grep -P -A5 "Memory\s+Device"|grep Size|grep -v Range
Size: 8192 MB
Size: 8192 MB
Size: 8192 MB
Size: No Module Installed
Size: No Module Installed
Size: No Module Installed
Size: 8192 MB
Size: 8192 MB
Size: 8192 MB
Size: No Module Installed
Size: No Module Installed
Size: No Module Installed
看,是不是很明了,已经插上的内存,和总共的内存插槽!

那现在想知道服务器最大能支持的内存,也就是单插糟最大支持多大的内存条
查看内存支持的最大内存容量
 # dmidecode|grep -P 'Maximum\s+Capacity'
Maximum Capacity: 192 GB 
好方便啊,原来linux的基础才是最最最重要的!

那剩下的就是确认内存的类型了
查看内存的频率
# dmidecode|grep -A16 "Memory Device"
Memory Device
Array Handle: 0x1000
Error Information Handle: Not Provided
Total Width: 72 bits
Data Width: 64 bits
Size: 8192 MB
Form Factor: DIMM
Set: 1
Locator: DIMM_A1
Bank Locator: Not Specified
Type: DDR3
Type Detail: Synchronous Registered (Buffered)
Speed: 1333 MHz
Manufacturer: 00AD00B380AD
Serial Number: 1F8511F2
Asset Tag: 01122063
Part Number: HMT31GR7CFR4A-H9
--
Memory Device
Array Handle: 0x1000
Error Information Handle: Not Provided
Total Width: 72 bits
Data Width: 64 bits
Size: 8192 MB
Form Factor: DIMM
Set: 1
Locator: DIMM_A2
Bank Locator: Not Specified
Type: DDR3
Type Detail: Synchronous Registered (Buffered)
Speed: 1333 MHz
Manufacturer: 00AD00B380AD
Serial Number: 20450574
Asset Tag: 01122063
Part Number: HMT31GR7CFR4A-H9
--
Memory Device
Array Handle: 0x1000
Error Information Handle: Not Provided
Total Width: 72 bits
Data Width: 64 bits
Size: 8192 MB
Form Factor: DIMM
Set: 2
Locator: DIMM_A3
Bank Locator: Not Specified
Type: DDR3
Type Detail: Synchronous Registered (Buffered)
Speed: 1333 MHz
Manufacturer: 00AD00B380AD
Serial Number: 1F351229
Asset Tag: 01122063
Part Number: HMT31GR7CFR4A-H9
--
Memory Device
Array Handle: 0x1000
Error Information Handle: Not Provided
Total Width: 72 bits
Data Width: 64 bits
Size: No Module Installed
Form Factor: DIMM
Set: 2
Locator: DIMM_A4
Bank Locator: Not Specified
Type: DDR3
Type Detail: Synchronous
Speed: Unknown
Manufacturer:
Serial Number:
Asset Tag:
Part Number:
--
每个插槽的内存条类型信息全面展示
但一般我们只需要知道内存条的频率就可以了
# dmidecode|grep -A16 "Memory Device"|grep 'Speed'
Speed: 1333 MHz
Speed: 1333 MHz
Speed: 1333 MHz
Speed: Unknown
Speed: Unknown
Speed: Unknown
Speed: 1333 MHz
Speed: 1333 MHz
Speed: 1333 MHz
Speed: Unknown
Speed: Unknown
Speed: Unknown

以上为个人需要在网络上查找的,也充分认识到个人在Linux基础的匮乏。。。。。惭愧!!!!