在Linux上查詢物理機資訊-不用去拆機器了
- 2020 年 3 月 14 日
- 筆記
目錄
最近需要因為公司需要,需要查詢公司物理機的資訊,整個整理下來,總結了這麼一篇文章,歡迎大家補充。
在 Linux 系統獲取物理機器的資訊:
我們可以通過 lshw 或者 dmidecode 來獲取伺服器對應的物理機資訊。
我們這裡還是推薦使用 dmidecode 來獲取。
安裝 dmidecode
yum install -y dmidecode 一、查看系統資訊(包含機器型號)
1.1 查看機型和品牌
[root@djx ~]# dmidecode --type system # dmidecode 3.1 Getting SMBIOS data from sysfs. SMBIOS 3.2.0 present. # SMBIOS implementations newer than version 3.1.1 are not # fully supported by this version of dmidecode. Handle 0x0100, DMI type 1, 27 bytes System Information Manufacturer: Dell Inc. # 機器品牌 Product Name: PowerEdge R740 # 機器型號 Version: Not Specified Serial Number: FW89BX2 UUID: 4c4c4534-0057-3810-8019-c6c04f425832 Wake-up Type: Power Switch SKU Number: SKU=NotProvided;ModelName=PowerEdge R740 Family: PowerEdge #直接獲取機型和品牌 dmidecode --type system |grep -E 'Manufacturer|Product Name' #lshw|head #可以獲取物理機機器型號和 二、查看CPU 資訊
2.1 查看CPU 型號
也可以使用
cat /proc/cpuinfo |grep "model name"|head -1
[root@djx ~]# dmidecode --type processor # dmidecode 3.1 Getting SMBIOS data from sysfs. SMBIOS 3.2.0 present. # SMBIOS implementations newer than version 3.1.1 are not # fully supported by this version of dmidecode. Handle 0x0400, DMI type 4, 48 bytes Processor Information Socket Designation: CPU1 Type: Central Processor Family: Xeon Manufacturer: Intel ID: 57 06 04 00 FF F5 EB BF Signature: Type 0, Family 6, Model 85, Stepping 7 Flags: FPU (Floating-point unit on-chip) VME (Virtual mode extension) DE (Debugging extension) PSE (Page size extension) TSC (Time stamp counter) MSR (Model specific registers) PAE (Physical address extension) MCE (Machine check exception) CX8 (CMPXCHG8 instruction supported) APIC (On-chip APIC hardware supported) SEP (Fast system call) MTRR (Memory type range registers) PGE (Page global enable) MCA (Machine check architecture) CMOV (Conditional move instruction supported) PAT (Page attribute table) PSE-36 (36-bit page size extension) CLFSH (CLFLUSH instruction supported) DS (Debug store) ACPI (ACPI supported) MMX (MMX technology supported) FXSR (FXSAVE and FXSTOR instructions supported) SSE (Streaming SIMD extensions) SSE2 (Streaming SIMD extensions 2) SS (Self-snoop) HTT (Multi-threading) TM (Thermal monitor supported) PBE (Pending break enabled) Version: Intel(R) Xeon(R) Silver 4208 CPU @ 2.10GHz # CPU 型號 Voltage: 1.8 V External Clock: 9600 MHz Max Speed: 4000 MHz Current Speed: 2100 MHz Status: Populated, Enabled Upgrade: Socket LGA2011 L1 Cache Handle: 0x0700 L2 Cache Handle: 0x0701 L3 Cache Handle: 0x0702 Serial Number: Not Specified Asset Tag: Not Specified Part Number: Not Specified Core Count: 8 Core Enabled: 8 Thread Count: 16 Characteristics: 64-bit capable Multi-Core Hardware Thread Execute Protection Enhanced Virtualization Power/Performance Control Handle 0x0401, DMI type 4, 48 bytes Processor Information Socket Designation: CPU2 Type: Central Processor Family: Unknown Manufacturer: Not Specified ID: 00 00 00 00 00 00 00 00 Version: Not Specified Voltage: Unknown External Clock: Unknown Max Speed: 4000 MHz Current Speed: Unknown Status: Unpopulated Upgrade: Socket LGA2011 L1 Cache Handle: Not Provided L2 Cache Handle: Not Provided L3 Cache Handle: Not Provided Serial Number: Not Specified Asset Tag: Not Specified Part Number: Not Specified Characteristics: None # dmidecode --type processor |grep 'Version' 2.2 查看CPU的物理數量
cat /proc/cpuinfo |grep "physical id"|sort|uniq|wc -l 2.3 查看 CPU核心數量(非邏輯CPU)
grep "cpu cores" /proc/cpuinfo | uniq | awk -F ":" "{print $2}" 2.4 查看 CPU數量(邏輯)
cat /proc/cpuinfo |grep 'processor'|wc -l 2.5 查看CPU的支援的最大記憶體
我這個沒有找到,可以從 cpu 型號進行查詢。 直接百度搜索該CPU資訊,然後查看該 cpu 的參數。 三、查詢主板資訊
3.1 查詢主板型號
[root@djx ~]# dmidecode --type baseboard|head # dmidecode 3.1 Getting SMBIOS data from sysfs. SMBIOS 3.2.0 present. # SMBIOS implementations newer than version 3.1.1 are not # fully supported by this version of dmidecode. Handle 0x0200, DMI type 2, 8 bytes Base Board Information Manufacturer: Dell Inc. # 主板品牌 Product Name: 014X06 # 生產號 3.2 查看主板可以支援的最大記憶體
dmidecode |grep "Maximum Capacity" / dmidecode --type memory |head 四、查詢磁碟相關的東西
4.1 磁碟大小
fdisk -l 4.2 磁碟塊數
fdisk -l # 這個也不精確,建議直接去物理機上面看,我們下面提供戴爾伺服器如何查詢的方法。 4.3 是否啟用raid
lspci |grep -i raid # 這個不精確 建議安裝特定的軟體(不同機器不一樣)進行查看 4.4 查看當前的 raid版本
要根據官方的文檔去安裝驅動進行查詢。 五、查詢記憶體條資訊
5.1 當前記憶體單條大小
dmidecode --type memory |grep "Size" 當前多少根記憶體條
dmidecode --type memory |grep "Size"|grep 'MB'|wc -l 當前記憶體條型號
dmidecode --type memory |grep "Part Number" 可以擴展記憶體條數目
dmidecode --type memory |grep "Number Of Devices" # 這個數據也是僅僅供參考,因為 部分伺服器,單物理CPU 是可以插8根記憶體條,然後2個物理CPU是可以插12根記憶體條的,這個需要查看伺服器的官方文檔。 可以擴展記憶體總大小
dmidecode |grep "Maximum Capacity" # 這個值也不是很准,跟記憶體條的類型與插入的記憶體條有關。 建議查詢官方文檔 六、 擴展
6.1 擴展資訊
戴爾如何獲取服務碼:機器前面顯示器的字元串(7位)/或者快速服務程式碼。
惠普如何獲取服務碼: 機器上的SN 碼 。HP 查詢是否過保網站: https://support.hpe.com/hpsc/wc/public/home
戴爾監控物理設備一般使用的是 IDRAC (遠程)及 OMSA 、 SAE
記憶體條類型區分
記憶體條類型分為 LRDIMM、RDIMM、UDIMM,一般來說LRDIMM 的記憶體條容量更大些。同一個機型,我們建議使用相同類型的記憶體條。一般只只有顆CPU的話,只能支援一半的記憶體條數。如何查詢記憶體條的安裝方法以及伺服器支援的最大記憶體。我們一般從官方文檔查詢, 一般位於官方文檔中的用戶手冊,技術規格-記憶體規格 ,安裝方法為 安裝文檔裡面記憶體內容
6.2 戴爾伺服器查詢是否使用了 raid
需要安裝 PERC,官方文檔。 從戴爾支援站點下載Linux PERCCLI實用程式。選擇您的系統,然後按類別SAS RAID或通過使用關鍵字PERCCLI篩選驅動程式和下載
# 查看是否使用了raid,raid幾 perccli /c0/v0 show all # 查看物理磁碟數 perccli /c0/eall/sall show

