根据系统中的/dev/sdn查询属于物理机上的slot几号盘位

一、先安装megaCLI

先下载软件:https://docs.broadcom.com/docs-and-downloads/raid-controllers/raid-controllers-common-files/8-07-10_MegaCLI_Linux.zip

或者直接wget到服务器上,进行解析安装

unzip 8-07-10_MegaCLI_Linux.zip
cd 8.07.10_MegaCLI_Linux/Linux\ MegaCLI\ 8.07.10/
rpm -ivh MegaCli-8.07.10-1.noarch.rpm

二、比如要查询/dev/sdn1对应要更换磁盘的slot 几号盘位

# df -h |grep sdn
/dev/sdn1                   3.7T  2.1T  1.6T  57% /data8
# ll /dev/disk/by-id | grep sdn1          # 查询设备的wwn号
lrwxrwxrwx 1 root root 10 Dec  5 20:50 ata-ST4000NM0035-1V4107_ZC17H1Q6-part1 -> ../../sdn1
lrwxrwxrwx 1 root root 10 Dec  5 20:50 scsi-SATA_ST4000NM0035-1V_ZC17H1Q6-part1 -> ../../sdn1
lrwxrwxrwx 1 root root 10 Dec  5 20:50 wwn-0x5000c500b21acfcd-part1 -> ../../sdn1
# /opt/MegaRAID/MegaCli/MegaCli64 PDList -aAll -NoLog | grep -C 5 5000c500b21acfcd

Enclosure Device ID: 0
Slot Number: 9
Enclosure position: 1
Device Id: 10
WWN: 5000c500b21acfcd
Sequence Number: 6
Media Error Count: 0
Other Error Count: 52
Predictive Failure Count: 0
Last Predictive Failure Event Seq Number: 0

grep -A 显示匹配指定内容及之后的n行

grep -B  显示匹配指定内容及之前的n行

grep -C  显示匹配指定内容及其前后各n行

查到硬盘位置为slot 9然后再去更换对应的磁盘既可。

卸载故障硬盘
/opt/MegaRAID/MegaCli/MegaCli64 -PDOffline -PhysDrv[0:13] -a0
 
# /opt/MegaRAID/MegaCli/MegaCli64 PDList -aAll -NoLog # 用此命令查看 上面命令中 0
和 13 以及 -a0 的对应关系: Adapter #0 Enclosure Device ID: 0 Slot Number: 13

  MegaCli64 -PdLocate {[-start] | -stop} -physdrv[E0:S0,E1:S1,...] -aN|-a0,1,2|-aALL

点亮指定硬盘(定位,让磁盘闪灯)
/opt/MegaRAID/MegaCli/MegaCli64 -PdLocate -start -physdrv[0:13] -a0
 
注:磁盘换完后关闭指定硬盘指示灯
/opt/MegaRAID/MegaCli/MegaCli64 -PdLocate -stop -physdrv[0:13] -a0

 

posted @ 2021-12-10 15:09  林中龙虾  阅读(524)  评论(0编辑  收藏  举报