技术解析
【前言】
使用 [SAS MegaRAID Linux MegaCLI] 可以在文字模式下很方便的查看目前 RAID 及 HDD 状态。
【作业环境】
CentOS 5.1 (Linux 2.6.18-53.el5)
Dell PowerEdge 1950
Dell RAID Controller PERC 5/i (Raid Card)
scsi0 : LSI Logic SAS based MegaRAID driver
SAS HDD 146 G * 2 (Build RAID-1)
1.01.39_Linux_Cli.zip (MegaCli-1.01.39-0.i386.rpm)
【安装及设定】
下载 1.01.39_Linux_Cli.zip
下载 1.01.39_Linux_Cli.zip
#wget http://www.lsi.com/support/downloads/megaraid/miscellaneous/linux/1.01.39_Linux_Cli.zip
解压缩 1.01.39_Linux_Cli.zip
#unzip 1.01.39_Linux_Cli.zip Archive: 1.01.39_Linux_Cli.zip inflating: MegaCli-1.01.39-0.i386.rpm inflating: 1.01.39_Linux_Cli.txt
安装 MegaCli-1.01.39-0.i386.rpm
#rpm -ivh MegaCli-1.01.39-0.i386.rpm Preparing... ########################################### [100%] 1:MegaCli ########################################### [100%]
名词解释
Virtual Drive (VD):虚拟硬碟,多颗硬碟组合起来的虚拟硬碟简单说就是 RAID
VD State Optimal:RAID 目前状态為正常 (最优)
VD State Degraded:RAID 目前状态為不正常 (退化、降级)
Physical Drive (PD):实体硬碟,简单说就是你实际上有几颗硬碟
PD State Online:实体硬碟目前状态為正常
PD State Fail、Unconfigured:实体硬碟目前状态為不正常 (失败、未设定)
PD State Rebuild:实体硬碟目前状态為重建中
查看 RAID 状态指令
#/opt/MegaRAID/MegaCli/MegaCli -cfgdsply -aALL //查看 Raid Card 型号、Disk 相关资讯 #/opt/MegaRAID/MegaCli/MegaCli -AdpAllInfo -aALL //关於 Raid Card 功能详细内容
测试 RAID Broken 状态
当然要先测试有硬碟死掉时的状态一方面了解 RAID 设定是否正确一方面顺便计算 Rebuild 的时间(因為我直接测只能拔硬碟了所以状态是不是像我写的这样?应该大同小异吧!!),以下是当硬碟损坏时 VD、PD 的状态演变。
Device | Normal | Damage | Rebuild | Normal |
Virtual Drive | Optimal | Degraded | Degraded | Optimal |
Physical Drive | Online | Failed --> Unconfigured | Rebuild | Online |
查看 VD、PD State Shell Script
因為 megacli 指令一堆出来的资讯又很多,虽然每天会寄 Log 来看但若想线上直接观看又不想看一堆有的没的讯息所以就写个简单的 shell scipt 只抓我要看的资讯,有需要就参考看看吧,因為就是抓要看的讯息所以也没什好解释的了。
# cat ~/check_perc5i.sh #!/bin/sh #$Id: check_perc5i.sh, v0.2 2008/4/15 weithenn Exp $ #Check RAID Card PERC 5/i VD and PD State HOSTNAME=`/bin/hostname` CARD=`/opt/MegaRAID/MegaCli/MegaCli -AdpAllInfo -aALL |grep "Product Name" | cut -d ':' -f2` VDSTATE1=`/opt/MegaRAID/MegaCli/MegaCli -cfgdsply -aALL | grep "State"` VDSTATE2=`/opt/MegaRAID/MegaCli/MegaCli -AdpAllInfo -aALL | grep "Degraded"` VDSTATE3=`/opt/MegaRAID/MegaCli/MegaCli -AdpAllInfo -aALL | grep " Offline"` PDSTATE1=`/opt/MegaRAID/MegaCli/MegaCli -cfgdsply -aALL | grep "Online" | wc -l | sed 's/ //'` PDSTATE2=`/opt/MegaRAID/MegaCli/MegaCli -cfgdsply -aALL | grep "Rebuild" | wc -l | sed 's/ //'` PDSTATE3=`/opt/MegaRAID/MegaCli/MegaCli -AdpAllInfo -aALL | grep "Critical Disks"` PDSTATE4=`/opt/MegaRAID/MegaCli/MegaCli -AdpAllInfo -aALL | grep "Failed Disks"` echo "##### Host Informationi #####" echo "Host : $HOSTNAME" echo "Raid Card :$CARD" echo "" echo "##### Virtual Disk State #####" echo "Virtual Disk $VDSTATE1" echo "$VDSTATE2" echo "$VDSTATE3" echo "" echo "##### Physical Disk State #####" echo "Online Disk : $PDSTATE1" echo "Rebuild Disk : $PDSTATE2" echo "$PDSTATE3" echo "$PDSTATE4"
上面的 shell script 再RAID 正常时执行结果如下,可看到 VD 状态為 Optimal,而 PD 状态為 Online Disk 有 2 颗
##### Host Informationi ##### Host : dellbsd.weithenn.idv.tw Raid Card : PERC 5/i Integrated ##### Virtual Disk State ##### Virtual Disk State: Optimal Degraded : 0 Offline : 0 ##### Physical Disk State ##### Online Disk : 2 Rebuild Disk : 0 Critical Disks : 0 Failed Disks : 0
把一颗硬碟拔掉时 shell script 讯息,可看到 VD 状态由 Optimal 变成 Degraded,而 VD Disk 有 1 颗 Degraded
##### Host Informationi ##### Host : dellbsd.weithenn.idv.tw Raid Card : PERC 5/i Integrated ##### Virtual Disk State ##### Virtual Disk State: Degraded Degraded : 1 Offline : 0 ##### Physical Disk State ##### Online Disk : 2 Rebuild Disk : 0 Critical Disks : 0 Failed Disks : 0
今天遇到的状况有一颗 HDD 亮黄灯,可看到 VD 状态还是 Optimal (因為那颗 HDD 还没死,目前是要死不死当中),而 VD 中有 1 颗 Disk 状态為 Critical
##### Host Informationi ##### Host : dellbsd.weithenn.idv.tw Raid Card : PERC 5/i Integrated ##### Virtual Disk State ##### Virtual Disk State: Optimal Degraded : 0 Offline : 0 ##### Physical Disk State ##### Online Disk : 2 Rebuild Disk : 0 Critical Disks : 1 Failed Disks : 0
插入新 HDD 在做 Rebuild 时,Rebuild 完成后 VD 状态会由 Degraded 变回 Optimal,以下状态為正在 Rebuild 中 2 颗 HDD (1 颗正常,1 颗重建中)
##### Host Informationi ##### Host : sogans-1.soga-interactive.com Raid Card : PERC 5/i Integrated ##### Virtual Disk State ##### Virtual Disk State: Degraded Degraded : 1 Offline : 0 ##### Physical Disk State ##### Physical Online : 1 Physical Rebuild : 1 Critical Disks : 0 Failed Disks : 0