本次由于需要搭建一套环境,但是所需硬件配置不足,需要进行统计采购。那么就需要得知服务器现有配置,所以这次会介绍些常用的命令和工具来查询硬件信息。其实也可以通过像DELL厂商的IDRAC控制台来获取这些信息,但是比较尴尬的是IBM在获取硬盘信息方面支持比较差,仅显示物理磁盘数量,能够获取的信息很少,这时就需要像storcli这种专业工具来收集。本章使用的命令查询需求比较单一,后续会在实际使用中慢慢补充上来。
一、查看服务器对应 IPMI 地址
[root@node-1 ~]# ipmitool lan print
Set in Progress : Set CompleteAuth Type Support : NONE MD2 MD5 PASSWORD Auth Type Enable : Callback : : User : MD2 MD5 PASSWORD : Operator : MD2 MD5 PASSWORD : Admin : MD2 MD5 PASSWORD : OEM : IP Address Source : Static AddressIP Address : 10.100.0.40Subnet Mask : 255.255.255.0MAC Address : 40:f2:e9:da:53:feSNMP Community String : publicIP Header : TTL=0x40 Flags=0x40 Precedence=0x00 TOS=0x10BMC ARP Control : ARP Responses Enabled, Gratuitous ARP DisabledGratituous ARP Intrvl : 2.0 secondsDefault Gateway IP : 10.100.0.1Default Gateway MAC : 00:00:00:00:00:00Backup Gateway IP : 0.0.0.0Backup Gateway MAC : 00:00:00:00:00:00802.1q VLAN ID : Disabled802.1q VLAN Priority : 0RMCP+ Cipher Suites : 1,2,3,4,5,6,7,8,9,10,11,12,13,14Cipher Suite Priv Max : aaaaaaaaaaaaaaX : X=Cipher Suite Unused : c=CALLBACK : u=USER : o=OPERATOR : a=ADMIN : O=OEM
二、查看网卡速率
[root@node-1 ~]# lspci | grep Ethernet #列出每个pci总线上的设备,通过grep过滤可得到网卡设备列表,这里看到总计8个网卡
06:00.0 Ethernet controller: Intel Corporation I350 Gigabit Network Connection (rev 01)06:00.1 Ethernet controller: Intel Corporation I350 Gigabit Network Connection (rev 01)06:00.2 Ethernet controller: Intel Corporation I350 Gigabit Network Connection (rev 01)06:00.3 Ethernet controller: Intel Corporation I350 Gigabit Network Connection (rev 01)11:00.0 Ethernet controller: Broadcom Limited NetXtreme II BCM57810 10 Gigabit Ethernet (rev 10)11:00.1 Ethernet controller: Broadcom Limited NetXtreme II BCM57810 10 Gigabit Ethernet (rev 10)20:00.0 Ethernet controller: Broadcom Limited NetXtreme II BCM57810 10 Gigabit Ethernet (rev 10)20:00.1 Ethernet controller: Broadcom Limited NetXtreme II BCM57810 10 Gigabit Ethernet (rev 10)
[root@node-1 ~]# ethtool eth0 #查看单块网卡的详细信息
Settings for eth0: Supported ports: [ TP ] #TP 代表是千兆网卡 Supported link modes: 10baseT/Half 10baseT/Full 100baseT/Half 100baseT/Full 1000baseT/Full Supported pause frame use: Symmetric Supports auto-negotiation: Yes Advertised link modes: 10baseT/Half 10baseT/Full 100baseT/Half 100baseT/Full 1000baseT/Full Advertised pause frame use: Symmetric Advertised auto-negotiation: Yes Speed: 1000Mb/s Duplex: Full Port: Twisted Pair PHYAD: 1 Transceiver: internal Auto-negotiation: on MDI-X: on (auto) Supports Wake-on: pumbg Wake-on: g Current message level: 0x00000007 (7) drv probe link Link detected: yes
[root@node-1 ~]# ethtool eth1
Settings for eth1: Supported ports: [ FIBRE ] #FIBRE 代表是万兆网卡 Supported link modes: 1000baseT/Full 10000baseT/Full Supported pause frame use: Symmetric Receive-only Supports auto-negotiation: No Advertised link modes: 10000baseT/Full Advertised pause frame use: No Advertised auto-negotiation: No Speed: Unknown! Duplex: Unknown! (255) Port: FIBRE PHYAD: 1 Transceiver: internal Auto-negotiation: off Supports Wake-on: g Wake-on: d Current message level: 0x00000000 (0) Link detected: no
三、查看内存信息
[root@node-1 ~]# cat /proc/meminfo
[root@node-1 ~]# dmidecode -t memory #此命令会列出每条内存的型号、频率等详细信息Handle 0x000A, DMI type 17, 34 bytesMemory Device Array Handle: 0x0009 Error Information Handle: Not Provided Total Width: 72 bits Data Width: 64 bits Size: 8192 MB Form Factor: DIMM Set: 1 Locator: DIMM 1 Bank Locator: Bank 1 Type: DDR3 Type Detail: Registered (Buffered) Speed: 1333 MHz Manufacturer: Samsung Serial Number: 3386DA95 Asset Tag: Unknown Part Number: M393B1K70DH0-YH9 Rank: 2 Configured Clock Speed: 1333 MHz
四、使用 storcli 查看服务器硬件基础信息
[root@node-1 ~]# rpm -ivh storcli-1.18.05-1.noarch.rpm #安装包请见文章末尾
[root@node-1 ~]# /opt/MegaRAID/storcli/storcli64 show all #查询所有信息并show,在system overview下看到controller(缩写ctl)列数字就是controller号,得知node-1这台机器的controller号是0System Overview :===============---------------------------------------------------------------------------Ctl Model Ports PDs DGs DNOpt VDs VNOpt BBU sPR DS EHS ASOs Hlth --------------------------------------------------------------------------- 0 ServeRAIDM5110e 8 7 5 0 5 0 Opt On - Y 3 Opt ---------------------------------------------------------------------------
[root@node-1 ~]# /opt/MegaRAID/storcli/storcli64 /c0 show #显示contrller0的raid卡的版本、功能、状态、以及raid卡下的物理磁、逻辑盘信息,这里我需要看物理磁盘的容量情况,可以在PD LIST部分找到
如果不需要其他信息,和我一样只需要知道物理磁盘信息的话可以使用如下命令
[root@node-1 ~]# /opt/MegaRAID/storcli/storcli64 /c0/eall/sall showController = 0Status = SuccessDescription = Show Drive Information Succeeded.Drive Information :=================-------------------------------------------------------------------------EID:Slt DID State DG Size Intf Med SED PI SeSz Model Sp -------------------------------------------------------------------------252:0 20 Onln 1 278.464 GB SAS HDD N N 512B MK3001GRRB U 252:1 15 Onln 1 278.464 GB SAS HDD N N 512B ST9300603SS F U 252:2 16 Onln 0 557.861 GB SAS HDD N N 512B MBF2600RC U 252:3 17 Onln 0 557.861 GB SAS HDD N N 512B MBF2600RC U 252:4 19 Onln 2 557.861 GB SAS HDD N N 512B MBF2600RC U 252:5 14 Onln 3 557.861 GB SAS HDD N N 512B MBF2600RC U 252:6 18 Onln 4 557.861 GB SAS HDD N N 512B MBF2600RC U -------------------------------------------------------------------------
五、不想安装 storcli 的情况下查看硬盘型号信息
[root@node-1 ~]# cat /proc/scsi/scsi|grep 'Model:' #node-1 是 IBM X3650 M4
Vendor: IBM Model: ServeRAID M5110e Rev: 3.34Vendor: IBM Model: ServeRAID M5110e Rev: 3.34Vendor: IBM Model: ServeRAID M5110e Rev: 3.34Vendor: IBM Model: ServeRAID M5110e Rev: 3.34Vendor: IBM Model: ServeRAID M5110e Rev: 3.34Vendor: IBM SATA Model: DEVICE 81Y3682 Rev: D001
[root@node-5 ~]# cat /proc/scsi/scsi|grep 'Model:' #node-5 是 DELL R720,ST1000NM0023就是硬盘的型号
Vendor: SEAGATE Model: ST1000NM0023 Rev: GS0DVendor: SEAGATE Model: ST1000NM0023 Rev: GS0DVendor: SEAGATE Model: ST1000NM0023 Rev: GS0FVendor: SEAGATE Model: ST1000NM0023 Rev: GS0D
这种方式在硬盘做 raid 后不便于查看,例如下面查看我另一台服务器所看到到的,显示只有一块磁盘设备
[root@node-1 ~]# cat /proc/scsi/scsi|grep 'Model:'Vendor: DELL Model: PERC H710 Rev: 3.13Vendor: TSSTcorp Model: DVD-ROM SN-108FB Rev: D150
接下来通过 lsblk 查看设备情况,发现这块盘总容量2.7T(我这里使用的盘是1T的SAS盘,可以倒推出是4块1T盘组成的raid5)正好对应上我在IDRAC界面中看到的四块物理磁盘
[root@node-1 ~]# lsblkNAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTsda 8:0 0 2.7T 0 disk ├─sda1 8:1 0 24M 0 part ├─sda2 8:2 0 200M 0 part ├─sda3 8:3 0 250M 0 part /boot├─sda4 8:4 0 1.4T 0 part │ ├─os-root 253:0 0 1.4T 0 lvm /│ └─os-swap 253:1 0 32G 0 lvm [SWAP]└─sda5 8:5 0 1.3T 0 part └─mongo-mongodb 253:2 0 1.3T 0 lvm /var/lib/mongosr0 11:0 1 1024M 0 rom
storcli安装包各平台百度网盘链接地址(可在官网下载 https://www.broadcom.com/site-search?q=storcli)
链接:https://pan.baidu.com/s/19liM1WMaY7XoNIHLrX1dKg 提取码:pu7n续:在检查过程中发现IBM服务器上有两块disk告警,联系维保需要提供FRU号,但是人又不在现场没办法拔盘拍照。所以需要通过storcli来查询盘对应FRU号。
六、查询硬盘FRU号
[root@node-2 ~]# /opt/MegaRAID/storcli/storcli64 -PDList -aAll | grep FRU #如果想查看具体信息可以去掉过滤条件
IBM FRU/CRU: 42D0638 IBM FRU/CRU: 49Y2023 IBM FRU/CRU: 49Y2004 IBM FRU/CRU: 49Y2023 IBM FRU/CRU: 49Y2004 IBM FRU/CRU: 49Y2023
从上可以看到有两对重复的FRU号,怀疑可能是组成raid,那么就要通过storcli查看下硬盘raid情况
(1)查看逻辑磁盘
[root@node-2 ~]# /opt/MegaRAID/storcli/storcli64 /c0/vall show #这里看到有5块逻辑磁盘,通过 /c0 show 命令查看物理磁盘发现有6块,继续向下查看硬盘 raid 情况。Controller = 0Status = SuccessDescription = NoneVirtual Drives :==============----------------------------------------------------------------------DG/VD TYPE State Access Consist Cache Cac sCC Size Name ----------------------------------------------------------------------0/0 RAID1 Optl RW Yes RWBD - ON 557.861 GB 1/1 RAID0 Optl RW Yes RWBD - ON 557.861 GB 2/2 RAID0 Optl RW Yes RWBD - ON 557.861 GB 3/3 RAID0 Optl RW Yes RWBD - ON 557.861 GB 4/4 RAID0 Optl RW Yes RWBD - ON 278.464 GB GenericR0_4----------------------------------------------------------------------Cac=CacheCade|Rec=Recovery|OfLn=OffLine|Pdgd=Partially Degraded|dgrd=DegradedOptl=Optimal|RO=Read Only|RW=Read Write|HD=Hidden|TRANS=TransportReady|B=Blocked|Consist=ConsistentR=Read Ahead Always|NR=No Read Ahead|WB=WriteBack|AWB=Always WriteBack|WT=WriteThrough|C=Cached IO|D=Direct IO|sCC=ScheduledCheck Consistency
(2)查看逻辑磁盘大小、raid结构
[root@node-2 ~]# /opt/MegaRAID/storcli/storcli64 /c0/v0 show #可以看到 TYPE 为 RAID1,两块 600G 盘做的 RAID1,正好能够对上6块物理磁盘Controller = 0Status = SuccessDescription = NoneVirtual Drives :==============---------------------------------------------------------------DG/VD TYPE State Access Consist Cache Cac sCC Size Name---------------------------------------------------------------0/0 RAID1 Optl RW Yes RWBD - ON 557.861 GB ---------------------------------------------------------------Cac=CacheCade|Rec=Recovery|OfLn=OffLine|Pdgd=Partially Degraded|dgrd=DegradedOptl=Optimal|RO=Read Only|RW=Read Write|HD=Hidden|TRANS=TransportReady|B=Blocked|Consist=ConsistentR=Read Ahead Always|NR=No Read Ahead|WB=WriteBack|AWB=Always WriteBack|WT=WriteThrough|C=Cached IO|D=Direct IO|sCC=ScheduledCheck Consistency
[root@node-2 ~]# /opt/MegaRAID/storcli/storcli64 /c0/v1 show #可以看到 TYPE 为 RAID0
Controller = 0Status = SuccessDescription = NoneVirtual Drives :==============---------------------------------------------------------------DG/VD TYPE State Access Consist Cache Cac sCC Size Name---------------------------------------------------------------1/1 RAID0 Optl RW Yes RWBD - ON 557.861 GB ---------------------------------------------------------------Cac=CacheCade|Rec=Recovery|OfLn=OffLine|Pdgd=Partially Degraded|dgrd=DegradedOptl=Optimal|RO=Read Only|RW=Read Write|HD=Hidden|TRANS=TransportReady|B=Blocked|Consist=ConsistentR=Read Ahead Always|NR=No Read Ahead|WB=WriteBack|AWB=Always WriteBack|WT=WriteThrough|C=Cached IO|D=Direct IO|sCC=ScheduledCheck Consistency
依次查看 /c0/v0……4,结果为 v0 raid1 其余四个逻辑磁盘均为 raid0