MegaCli是一款管理维护硬件RAID软件,可以通过它来了解当前raid卡的所有信息,包括 raid卡的型号,raid的阵列类型,raid 上各磁盘状态,等等。通常,我们对硬盘当前的状态不太好确定,一般通过机房人员巡检来完成,有没有通过软件的方式来检查确定这个问题呢。MegaCli就可以做到,一般通过 MegaCli 的Media Error Count: 0 Other Error Count: 0 这两个数值来确定阵列中磁盘是否有问题;Medai Error Count 表示磁盘可能错误,可能是磁盘有坏道,这个值不为0值得注意,数值越大,危险系数越高,Other Error Count 表示磁盘可能存在松动,可能需要重新再插入。MegaCli 可以对阵列中所有的磁盘进行检测,我们可以通过脚本的方式来检测相关参数,从而通知管理人员。
【Version】:Ver 8.07.10
MegaCli -adpallinfo -a0 | head -10 #查看阵列卡型号
MegaCli -ldgetprop -pspolicy -lall -a0 #查看powersaving状态
MegaCli -fwtermlog -dsply -a0|less #查看硬盘厂商
MegaCli -adpallinfo -a0 | head -10 #raid 卡的微码
MegaCli -LDInfo -Lall -aALL #查raid级别
MegaCli -AdpAllInfo -aALL #查raid卡信息
MegaCli -PDList -aALL #查看硬盘信息
MegaCli -AdpBbuCmd -aAll #查看电池信息
MegaCli -fwtermlog -dsply -a0|grep -i charge #查看电池状态
MegaCli -fwtermlog -dsply -a0 #查看rebuild进度
MegaCsli -CfgForeign -Scan -a0 #扫盘
MegaCli -LDBI -ShowProg -LALL -aALL #查看阵列后台初始化进度
MegaCli -PDRbld -ShowProg -PhysDrv [1:5] -a0 #查看物理磁盘重建进度
MegaCli -FwTermLog -Dsply -aALL #查看raid卡日志
MegaCli -AdpAllInfo -aALL #查raid卡信息
MegaCli -AdpBbuCmd -aAll #查看电池信息
MegaCli -fwtermlog -dsply -a0|grep -i charge #查看电池状态
MegaCli -fwtermlog -dsply -a0 #查看电池充放开始时间
MegaCli -adpCount #显示适配器个数
MegaCli -AdpGetTime –aLL #显示适配器时间
MegaCli -AdpAllInfo -aAll #显示所有适配器信息
MegaCli -LDInfo -LALL -aAll #显示所有逻辑磁盘组信息
MegaCli -PDList -aAll #显示所有的物理信息
MegaCli -AdpBbuCmd -GetBbuStatus -aALL |grep ‘Charger Status #查看充电状
MegaCli -AdpBbuCmd -GetBbuStatus -aALL #显示BBU状态信息
MegaCli -AdpBbuCmd -GetBbuCapacityInfo -aALL #显示BBU容量信息
MegaCli -AdpBbuCmd -GetBbuDesignInfo -aALL #显示BBU设计参数
MegaCli -AdpBbuCmd -GetBbuProperties -aALL #显示当前BBU属性
MegaCli -cfgdsply -aALL #显示Raid卡型号,Raid设置,Disk相关信息
MegaCli -cfgdsply -aALL |grep Policy #查看Cache 策略设置
MegaCli -AdpBbuCmd -GetBbuStatus -aALL |grep ‘Relative State of Charge #查看充电进度百比
1.显示 Rebuid 进度
/opt/MegaRAID/MegaCli/MegaCli64 -PDRbld -ShowProg -physdrv[20: ] -aAL
2.查看 E S
/opt/MegaRAID/MegaCli/MegaCli64 -PDList -aAl -NoL g | rep -Ei "(enclosure|slot)"
3.查看所有硬盘的状态
/opt/MegaRAID/MegaCli/MegaCli64 -PDList -aAl -NoL g
4.查看所有 Virtual Disk 的状态
/opt/MegaRAID/MegaCli/MegaCli64 -LdP Info -aAl –NoL g
RAID Lev l 对应关系:
RAID Lev l : Primary-1, Secondary-0, RAID Lev l Qualif er-0 RAID 1
RAID Lev l : Primary-0, Secondary-0, RAID Lev l Qualif er-0 RAID 0
RAID Lev l : Primary-5, Secondary-0, RAID Lev l Qualif er-3 RAID 5
RAID Lev l : Primary-1, Secondary-3, RAID Lev l Qualif er-0 RAID 10
5.在线做 Raid
/opt/MegaRAID/MegaCli/MegaCli64 -CfgLdA d -r0[ :1 ] WB NORA Direct CachedBadB U
-strpsz64 -a0 -NoL g
/opt/MegaRAID/MegaCli/MegaCli64 -CfgLdA d -r5 [12: ,12:3,12:4,12:5,12:6,12:7] WB Direct -a0
6.点亮指定硬盘(定位)
/opt/MegaRAID/MegaCli/MegaCli64 -PdLocate -star -physdrv[25 :2] -a0
7.清除 Foreign 状态
/opt/MegaRAID/MegaCli/MegaCli64 -CfgForeign -Clear - 0
8.查看 RAID 阵列中掉线的盘
/opt/MegaRAID/MegaCli/MegaCli64 -pdgetmis ng -a0 # # #
9.替换坏掉的模块
/opt/MegaRAID/MegaCli/MegaCli64 -pdreplacemis ng -physdrv[12: 0] -Ar ay5 -row0 -a0
10.手动开启 rebuid
/opt/MegaRAID/MegaCli/MegaCli64 -pdrbld -star -physdrv[12: 0] -a0
11 .查看 Megacli 的 log
/opt/MegaRAID/MegaCli/MegaCli64 -FwTermLog dsply -a0 > adp2.log
12.设置 HotSpare
/opt/MegaRAID/MegaCli/MegaCli64 -pdhsp -set [-Dedicated [-Ar ay2] [-EnclAf in ty]
[-no Rev rtible] -PhysDrv[4:1 ] -a0
/opt/MegaRAID/MegaCli/MegaCli64 -pdhsp -set [-EnclAf in ty] [-no Rev rtible] -PhysDrv[32:1}]
-a0
13.关闭 Rebuild
/opt/MegaRAID/MegaCli/MegaCli64 -AdpAutoRbld -Dsbl -a0
14.设置 rebuild 的速率
/opt/MegaRAID/MegaCli/MegaCli64 -AdpSetProp RebuildRate -30 -a0
= = = = = = = = = = = = = = = = = = = = = = = = = 1. 首先介绍下 Linux 系统本身查看
软件 raid:查看 raid 级别,状态等信息
#cat /proc/mdsta
硬件 raid:查看 raid 的厂商,型号,级别
#dmesg | rep -i ra d
#cat /proc/s i/sc i
2.硬件 raid 最佳的办法是通过已安装的 raid 厂商的管理工具来查看,下面安装 MegaCLI 工具
查看
首先下载 MegaCli,解压缩。#rpm -ivh MegaCli-1.0 24-0.i386.rpm 安装在/opt 下,所以执行
命令都是/opt/MegaRAID/MegaCli/MegaCli64 哦。
命令使用:
#/opt/MegaRAID/MegaCli/MegaCli64 -LDInfo -Lal -aAL 查 raid 级别
#/opt/MegaRAID/MegaCli/MegaCli64-AdpAl Info -aAL 查 raid 卡信息
#/opt/MegaRAID/MegaCli/MegaCli64-PDList -aAL 查看硬盘信息
#/opt/MegaRAID/MegaCli/MegaCli64-AdpBbuCmd -aAl 查看电池信息
#/opt/MegaRAID/MegaCli/MegaCli64-FwTermLog -Dsply -aAL 查看 raid 卡日志
#/opt/MegaRAID/MegaCli/MegaCli64-adpCount 【显示适配器个数】
#/opt/MegaRAID/MegaCli/MegaCli64-AdpGetTime –aAL 【显示适配器时间】
#/opt/MegaRAID/MegaCli/MegaCli64-AdpAl Info -aAl 【显示所有适配器信息】
#/opt/MegaRAID/MegaCli/MegaCli64-LDInfo -LA L -aAl 【显示所有逻辑磁盘组信息】
#/opt/MegaRAID/MegaCli/MegaCli64-PDList -aAl 【显示所有的物理信息】
#/opt/MegaRAID/MegaCli/MegaCli64-AdpBbuCmd -GetBbuSta us -aAL |grep ‘Charge Sta us’
【查看充电状态】
#/opt/MegaRAID/MegaCli/MegaCli64-AdpBbuCmd -GetBbuSta us -aAL 【显示 B U 状态信息】
#/opt/MegaRAID/MegaCli/MegaCli64-AdpBbuCmd -GetBbuCap cityInfo -aAL【显示 B U 容量信
息】
#/opt/MegaRAID/MegaCli/MegaCli64-AdpBbuCmd -GetBbuDesignI fo -aAL 【显示 B U 设计
参数】
#/opt/MegaRAID/MegaCli/MegaCli64-AdpBbuCmd -GetBbuProperties -aAL 【显示当前 B U
属性】
#/opt/MegaRAID/MegaCli/MegaCli64-cfgdsply -aAL 【显示 Raid 卡型号,Raid 设置,Disk 相关信息】
3.磁带状态的变化,从拔盘,到插盘的过程中。
Device |Normal|Dam ge|Rebuild|Normal
Virtual Drive |Optimal|Degrade |Degrade |Optimal
Physical Drive |Onli e|Failed –> Unconfigured|Rebuild|Onli e
4.查看磁盘缓存策略
#/opt/MegaRAID/MegaCli/MegaCli64-LDGetProp -Cache -L0 -a0
or
#/opt/MegaRAID/MegaCli/MegaCli64-LDGetProp -Cache -L1 -a0
or
#/opt/MegaRAID/MegaCli/MegaCli64-LDGetProp -Cache -LA L -a0
ro
#/opt/MegaRAID/MegaCli/MegaCli64-LDGetProp -Cache -LA L -aAL
ro
#/opt/MegaRAID/MegaCli/MegaCli64-LDGetProp -DskCache -LA L -aAL
5.设置磁盘缓存策略
缓存策略解释:
WT (Write hrough
WB (Write back)
NORA (No read head)
RA (Read head)
ADRA (Adaptive r ad head)
Cached
Direct
例子:
#/opt/MegaRAID/MegaCli/MegaCli64-LDSetProp WT|WB|NORA|RA| DRA -L0 -a0
or
#/opt/MegaRAID/MegaCli/MegaCli64-LDSetProp -Cached|-Direct -L0 -a0
or
enable / disable disk ca he
#/opt/MegaRAID/MegaCli/MegaCli64-LDSetProp -EnDskCache|-Dis kCache -L0 -a0
6.创建一个 raid5 阵列,由物理盘 2,3 4 构成,该阵列的热备盘是物理盘 5
#/opt/MegaRAID/MegaCli/MegaCli64-CfgLdA d -r5 [1:2,1:3,1:4] WB Direct -Hsp[1:5] -a0
7.创建阵列,不指定热备
#/opt/MegaRAID/MegaCli/MegaCli64-CfgLdA d -r5 [1:2,1:3,1:4] WB Direct -a0
8.删除阵列
#/opt/MegaRAID/MegaCli/MegaCli64-CfgLdDel -L1 -a0
9.在线添加磁盘
#/opt/MegaRAID/MegaCli/MegaCli64-LDRecon -Star - 5 Ad -PhysDrv[1:4] -L1 -a0
10.阵列创建完后,会有一个初始化同步块的过程,可以看 其进度。
#/opt/MegaRAID/MegaCli/MegaCli64-LDInit -ShowProg -LA L -aAL或者以动态可视化文字界面显示
#/opt/MegaRAID/MegaCli/MegaCli64-LDInit -ProgDsply -LA L -aAL
1 .查看阵列后台初始化进度
#/opt/MegaRAID/MegaCli/MegaCli64-LDBI -ShowProg -LA L -aAL
或者以动态可视化文字界面显示
#/opt/MegaRAID/MegaCli/MegaCli64-LDBI -ProgDsply -LA L -aAL
12.指定第 5 块盘作为全局热备
#/opt/MegaRAID/MegaCli/MegaCli64-PDHSP -Set [-EnclAf in ty] [-no Rev rtible] -PhysDrv[1:5]
-a0
13.指定为某个阵列的专用热备
#/opt/MegaRAID/MegaCli/MegaCli64-PDHSP -Set [-Dedicated [-Ar ay1] [-EnclAf in ty]
[-no Rev rtible] -PhysDrv[1:5] -a0
14.删除全局热备
#/opt/MegaRAID/MegaCli/MegaCli64-PDHSP -Rmv -PhysDrv[1:5] -a0
15.将某块物理盘下线/上线
#/opt/MegaRAID/MegaCli/MegaCli64-PDOf line -PhysDrv [1:4] -a0
#/opt/MegaRAID/MegaCli/MegaCli64-PDOnli e -PhysDrv [1:4] -a0
16.查看物理磁盘重建进度
#/opt/MegaRAID/MegaCli/MegaCli64-PDRbld -ShowProg -PhysDrv [1:5] -a0
或者以动态可视化文字界面显示
#/opt/MegaRAID/MegaCli/MegaCli64 -PDRbld -ProgDsply -PhysDrv [1:5] -a0