MegaCli工具介绍
MegaCli 是一款管理维护硬件 RAID 软件,可以通过它来了解当前 raid 卡的所有信息,包括 raid 卡的型号,raid 的阵列类型,raid 上各磁盘状态等等。
通常,我们对硬盘当前的状态不太好确定,一般通过机房人员巡检来完成,有没有通过软件的方式来检查确定这个问题呢。MegaCli就可以做到,一般通过MegaCli 的 Media Error Count: 0 Other Error Count: 0 这两个数值来确定阵列中磁盘是否有问题;Media Error Count 表示磁盘有可能错误,可能是磁盘有坏道,这个值不为 0 值得注意,数值越大,危险系数越高。Other Error Count 表示磁盘可能存在松动,可能需要再重新插入。MegaCli 可以对阵列中所有的磁盘进行检测,我们可以通过脚本的方式来检测相关参数,从而通知管理人员。
下载MegaCli管理工具
MegaCli工具可以从各个服务器的官方下载或者LSI网站上进行下载,一般来说,工具是通用的。
下载地址: ftp://download2.boulder.ibm.com/ecc/sar/CMA/XSA/ibm_utl_sraidmr_megacli-8.00.48_linux_32-64.zip
安装MegaCLi
1 | $ unzip ibm_utl_sraidmr_megacli-8.00.48_linux_32-64.zip |
使用命令和参数
1.常用命令1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16$ /opt/MegaRAID/MegaCli/MegaCli64 -LDInfo -Lall -aALL [查raid级别]
$ /opt/MegaRAID/MegaCli/MegaCli64 -AdpAllInfo -aAll [查raid卡信息]
$ /opt/MegaRAID/MegaCli/MegaCli64 -PDList -aAll [查看硬盘信息]
$ /opt/MegaRAID/MegaCli/MegaCli64 -AdpBbuCmd -aAll [查看电池信息]
$ /opt/MegaRAID/MegaCli/MegaCli64 -FwTermLog -Dsply -aAll [查看raid卡日志]
$ /opt/MegaRAID/MegaCli/MegaCli64 -adpCount [显示适配器个数]
$ /opt/MegaRAID/MegaCli/MegaCli64 -AdpGetTime -aAll [显示适配器时间]
$ /opt/MegaRAID/MegaCli/MegaCli64 -AdpAllInfo -aAll [显示所有适配器信息]
$ /opt/MegaRAID/MegaCli/MegaCli64 -LDInfo -LAll -aALl [显示所有逻辑磁盘组信息]
$ /opt/MegaRAID/MegaCli/MegaCli64 -PDList -aALl [显示所有的物理信息]
$ /opt/MegaRAID/MegaCli/MegaCli64 -AdpBbuCmd -GetBbuStatus -aAll | grep 'Charger Status' [查看充电状态]
$ /opt/MegaRAID/MegaCli/MegaCli64 -AdpBbuCmd -GetBbuStatus -aAll [显示BBU状态信息]
$ /opt/MegaRAID/MegaCli/MegaCli64 -AdpBbuCmd -GetBbuCapacityInfo -aALl [显示BBU容量信息]
$ /opt/MegaRAID/MegaCli/MegaCli64 -AdpBbuCmd -GetBbuDesignInfo -aAll [显示BBU设计参数]
$ /opt/MegaRAID/MegaCli/MegaCli64 -AdpBbuCmd -GetBbuProperties -aAll [显示当前BBU属性]
$ /opt/MegaRAID/MegaCli/MegaCli64 -cfgdsply -aAll [显示raid卡型号,raid设置,disk相关信息]
2.磁带状态的变化,从拔盘,到插盘的过程中1
2
3Device |Normal|Damage|Rebuild|Normal
Virtual Drive |Optimal|Degraded|Degraded|Optimal
Physical Drive |Online|Failed –> Unconfigured|Rebuild|Online
3.查看磁盘缓存策略1
2
3
4
5
6
7
8
9$ /opt/MegaRAID/MegaCli/MegaCli64 -LDGetProp -Cache -L0 -a0
or
$ /opt/MegaRAID/MegaCli/MegaCli64 -LdGetProp -Cache -L1 -a0
or
$ /opt/MegaRAID/MegaCli/MegaCli64 -LDGetProp -Cache -LALL -a0
or
$ /opt/MegaRAID/MegaCli/MegaCli64 -LDGetProp -Cache -LALL -aALL
or
$ /opt/MegaRAID/MegaCli/MegaCli64 -LDGetProp -DskCache -LALL -aALL
4.设置磁盘缓存策略1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16缓存策略解释:
WT (Write through)
WB (Write back)
NORA (No read ahead)
RA (Read ahead)
ADRA (Adaptive read ahead)
Cached
Direct
例如:
$ /opt/MegaRAID/MegaCli/MegaCli64 -LDSetProp WT|WB|NORA|RA|ADRA -L0 -a0
or
$ /opt/MegaRAID/MegaCli/MegaCli64 -LDSetProp -Cached|-Direct -L0 -a0
or
enable / disable disk cache
$ /opt/MegaRAID/MegaCli/MegaCli64 -LDSetProp -EnDskCache|-DisDskCache -L0 -a0
5.创建一个 raid5 阵列,由物理盘 2,3,4构成,该阵列的热备盘是物理盘 5。1
$ /opt/MegaRAID/MegaCli/MegaCli64 -CfgLdAdd -r5 [1:2,1:3,1:4] WB Direct -Hsp[1:5] -a0
6.创建阵列,不指定热备1
$ /opt/MegaRAID/MegaCli/MegaCli64 -CfgLdAdd -r5 [1:2,1:3,1:4] WB Direct -a0
7.删除阵列1
$ /opt/MegaRAID/MegaCli/MegaCli64 -CfgLdDel -L1 -a0
8.在线添加磁盘1
$ /opt/MegaRAID/MegaCli/MegaCli64 -LDRecon -Start -r5 -Add -PhysDrv[1:4] -L1 -a0
9.阵列创建完后,会有一个初始化同步块的过程,可以看看其进度1
2
3$ /opt/MegaRAID/MegaCli/MegaCli64 -LDInit -ShowProg -LALL -aALL
或者以动态可视化文字界面显示
$ /opt/MegaRAID/MegaCli/MegaCli64 -LDInit -PropDsply -LALL -aALL
10.查看阵列后台初始化进度1
2
3$ /opt/MegaRAID/MegaCli/MegaCli64 -LDBI -ShowProg -LALL -aALL
或者以动态可视化文字界面显示
$ /opt/MegaRAID/MegaCli/MegaCli64 -LDBI -ProgDsply -LALL -aALL
11.指定第5块盘1
$ /opt/MegaRAID/MegaCli/MegaCli64 -PDHSP -Set [-EnclAffinity] [-nonRevertible] -PhysDrv[1:5] -a0
12.指定为某个阵列的专用热备1
$ /opt/MegaRAID/MegaCli/MegaCli64 -PDHSP -Set [-Dedicated [-Array1]] [-EnclAffinity] [-nonRevertible] -PhysDrv[1:5] -a0
13.删除全局热备1
$ /opt/MegaRAID/MegaCli/MegaCli64 -PDHSP -Rmv -PhysDrv[1:5] -a0
14.将某块物理盘下线/上线1
2$ /opt/MegaRAID/MegaCli/MegaCli64 -PDOffline -PhysDrv [1:4] -a0
$ /opt/MegaRAID/MegaCli/MegaCli64 -PDOnline -PhysDrv [1:4] -a0
15.将某块物理盘重建进度1
2$ /opt/MegaRAID/MegaCli/MegaCli64 -PDRbld -ShowProg -PhysDrv [1:5] -a0
$ /opt/MegaRAID/MegaCli/MegaCli64 -PDRbld -ProgDsply -PhysDrv [1:5] -a0