宝塔服务器面板,一键全能部署及管理,送你10850元礼包,点我领取

一、  下载MegaCli

下载地址:ftp://download2.boulder.ibm.com/ecc/sar/CMA/XSA/ibm_utl_sraidmr_megacli-8.00.48_linux_32-64.zip

或https://docs.broadcom.com/docs-and-downloads/raid-controllers/raid-controllers-common-files/8-07-06_MegaCLI.zip

在线下载:

wget ftp://download2.boulder.ibm.com/ecc/sar/CMA/XSA/ibm_utl_sraidmr_megacli-8.00.48_linux_32-64.zip

wget这个工具没有的话就需要安装

# yum install wget -y

二、  安装

解压zip安装包

# unzip ibm_utl_sraidmr_megacli-8.00.48_linux_32-64.zip

切换到安装包目录

# cd linux/

使用rpm安装

# rpm -ivh Lib_Utils-1.00-09.noarch.rpmMegaCli-8.00.48-1.i386.rpm

查看文件安装在哪

# rpm -ql MegaCli-8.00.48-1.i386

MegaCli使用手册

可以做个软链接  —-相当于windous里面的快捷方式

# ln -s /opt/MegaRAID/MegaCli/MegaCli64 /bin/MegaCli64

# ln -s /opt/MegaRAID/MegaCli/MegaCli64 /sbin/MegaCli64

三、  使用命令及参数   使用参数可以不用区分大小写

查看帮助:

# MegaCli64 -h  

MegaCli使用手册

1.查看RAID控制器的数量:—–raid卡管理要用到

# MegaCli64 -adpCount  图中看出RAID控制器的数量为1

MegaCli使用手册

2.查看所有raid卡详细信息

# MegaCli64 -AdpAllInfo -aALL

 MegaCli使用手册

3.查看连接RAID卡的全部硬盘详细信息

# MegaCli64 -PDList -aALL    —-其中ALL意思是所有的控制器,此处也可以用0表示

# MegaCli64 -PDList -aN N可以根据Adapter #0来确定

N表示raid卡控制器编号,0表示第一块raid卡;ALL表示所有的raid

MegaCli使用手册

Adapter#0   —–raid卡控制器编号

EnclosureDevice ID: 252   —–外壳设备ID,也就是raid卡的ID号

SlotNumber: 4    ——槽号

Enclosureposition: 0   ——外壳位置

DeviceId: 49  —–设备ID

SequenceNumber: 2   —–序号

Media Error Count: 0  —–介质错误计数

Other Error Count: 0  —–其它错误计数

Predictive Failure Count: 0 —–预测故障计数

Last Predictive Failure Event Seq Number: 0

PD Type:SATA   —–磁盘接口类型

Raw Size:3.638 TB [0x1d1c0beb0 Sectors]   —–磁盘原始大小

NonCoerced Size: 3.637 TB [0x1d1b0beb0 Sectors]  —–磁盘标准大小

CoercedSize: 3.637 TB [0x1d1b00000 Sectors]  ——磁盘最大可用大小

Firmware state: Unconfigured(good),Spun down   —–固件状态:未配置(好的),未连接

SASAddress(0): 0x4433221107000000

ConnectedPort Number: 3(path0)   ——连接端口号

InquiryData:            Z1ZBBJWWST4000NM0033-9ZM170                     SN06    —–硬盘的序列号、型号、固件版本

FDECapable: Not Capable

FDEEnable: Disable

Secured:Unsecured

Locked:Unlocked

Needs EKMAttention: No

ForeignState: None

DeviceSpeed: 6.0Gb/s

LinkSpeed: 6.0Gb/s

MediaType: Hard Disk Device

Drive:  Not Certified

DriveTemperature : N/A   —-设备温度

需要特别关注这几个指标:Media Error / Other Error / Predictive Failure Count / LastPredictive Failure Event Seq Number

 

4.查看E  S:  —–获得磁盘的ID编号,E表示Enclosure Device,S表示Slot Number

由于磁盘信息较多,所有可以根据自己的需要来过滤得到自己想要的信息

# MegaCli64 -PDList -aAll| grep -Ei”(Enclosure Device|Slot Number|Raw Size|Firmware state)”  —粗过滤

grep是过滤的意思

-E参数是使用扩展正则表达式来过滤

-i参数是不区分大小写来过滤

Enclosure Device过滤出raid卡的ID;Slot Number过滤出磁盘的槽号;RawSize过滤出磁盘的大小;Firmware state过滤出磁盘的状态。

MegaCli使用手册

# MegaCli64 -PDList -aALL|grep -Ei “(EnclosureDevice|Slot Number|PD Type|Raw Size|Inquiry Data|Firmware state|ForeignState)”   —-精过滤

MegaCli使用手册

Enclosure Device过滤出raid卡的ID;Slot Number过滤出磁盘的槽号;Raw Size过滤出磁盘的大小;Inquiry Data 过滤出磁盘的序列号、型号固件版本;Firmware state过滤出磁盘的状态;

 

5.创建raid 

MegaCli64 -CfgLdAdd -r(0|1|5) [E:S, E:S, …] -aN

N表示raid卡编号,0表示第一块raid卡;ALL表示所有的raid卡

创建raid5      固件状态会由Unconfigured变成Online

# MegaCli64 -CfgLdAdd -r5 [252:4,252:5,252:6] WT -a0

解析:创建一个raid5,由252:4,252:5,252:6这3块磁盘组成,WT为设置的缓存类型。

注:如果不设置缓存类型,则raid的缓存类型为默认的缓存类型

MegaCli使用手册

创建raid10

MegaCli64 -CfgSpanAdd -r10 -Array0[E:S;E:S] -Array1[E:S;E:S]-Array*[E:S;E:S] -a0

# MegaCli64 -CfgSpanAdd -r10 -Array0[252:4,252:5] -Array1[252:6,252:7]WT-a0

解析:创建一个raid10,252:4;252:5做raid1组成Array0;252:6;252:7做raid1组成Array1,最后由Array0和Array1做raid0。

MegaCli使用手册

 

6.查看raid级别

# MegaCli64 -LdPdInfo -aALL —–查看raid级别及raid由哪些磁盘组成。

# MegaCli64 -LDInfo -Lall -aALL

MegaCli使用手册

Adapter 0– Virtual Drive Information:

VirtualDrive: 0 (Target Id: 0)   —-设备VD号

Name                :

RAIDLevel          : Primary-5, Secondary-0,RAID Level Qualifier-3  —-raid级别

Size                : 7.276 TB   —–逻辑磁盘大小

State               : Optimal   —–状态:最佳

StripSize          : 256 KB   —–簇的大小

Number OfDrives    : 3  

SpanDepth          : 1

DefaultCache Policy: WriteThrough, ReadAhead, Direct, No Write Cache if Bad BBU   —-默认缓存策略

CurrentCache Policy: WriteThrough, ReadAhead, Direct, No Write Cache if Bad BBU  —–当前缓存策略

AccessPolicy       : Read/Write    —–存取策略

DiskCache Policy   : Disk’s Default    —–磁盘缓存策略

EncryptionType     : None

BadBlocks Exist: No

 

RAID Level对应关系:RAID级别一般通过 Primary 字段值来判断

还需要结合Span Depth的值来判断值为1表示为 RAID-1,不为1表示 RAID-10; 还有一种情况:Primary-1, Secondary-3, RAID LevelQualifier-0 也是表示 RAID-10;

RAIDLevel : Primary-0, Secondary-0, RAID Level Qualifier-0    对应RAID 0

RAIDLevel : Primary-1, Secondary-0, RAID Level Qualifier-0    对应RAID 1

RAIDLevel : Primary-5, Secondary-0, RAID Level Qualifier-3    对应RAID 5

RAIDLevel : Primary-1, Secondary-3, RAID Level Qualifier-0    对应RAID 10

MegaCli使用手册

 

7.删除raid:

通过查看raid级别获得Virtual Drive编号

删除某个raid

MegaCli64 -CfgLdDel -LX -a0

X是第几个阵列(VD号:Virtual Drive: X);0表示第一个阵列。

MegaCli使用手册

删除第一个raid卡上的所有raid(慎用)

MegaCli64 -CfgClr -a0

清除raid信息:清除所有的raid(慎用)

MegaCli使用手册

 

8.查看 RAID 卡 Rebuild 参数:重建在IO资源使用中的百分比,默认为30%

# MegaCli64 -AdpAllinfo -aALL |grep -i rebuild

MegaCli使用手册

9.设置 RAID 卡 Rebuild 比例为60%:调整重建在IO资源使用中的百分比为60%

此项可以根据客户要求来设定

# MegaCli64 -AdpSetProp { RebuildRate -60} -aALL

MegaCli使用手册

 

10.查看电池信息:配置电池才能看到详细信息

没有电池或电池故障会出现以下报错

MegaCli使用手册

# MegaCli64 -AdpBbuCmd -aALL

MegaCli使用手册

BatteryType:CVPM03   —–电池型号

Voltage:9464 mV   —–电压

Current:0 mA    —–电流

Temperature:35 C   —–电池温度

 

BBUFirmware Status:

 

  Charging Status              : None   —–充电状态:未充电

  Voltage                                 : OK

  Temperature                             : OK

  Learn Cycle Requested                       : No

  Learn Cycle Active                      : No

  Learn Cycle Status                      : OK

  Learn Cycle Timeout                     : No

  I2c Errors Detected                     : No   —-检测错误:无

  Battery Pack Missing                    : No

  Battery Replacement required            : No

  Remaining Capacity Low                  : No

  Periodic Learn Required                 : No

  Transparent Learn                       : No

  No space to cache offload               : No

  Pack is about to fail & should bereplaced : No

  Cache Offload premium feature required  : No

  Module microcode update required        : No

 

Batterystate:

 

GasGuageStatus:

  Fully Discharged        : Yes  —-完全放电

  Fully Charged           : Yes   —-完全充电

  Discharging             : Yes

  Initialized             : Yes   —-初始化

  Remaining Time Alarm    : No

  Remaining Capacity Alarm: Yes

  Discharge Terminated    : Yes

  Over Temperature        : No

  Charging Terminated     : Yes  —-充电终止:是

  Over Charged            : No    —-负载充电:无

  Pack energy             : 249 J    —–容量包大小

  Capacitance             : 110    —–电流容量

  Remaining reservespace : 0

 

11.设置全局热备盘

MegaCli64 -PDHSP -set -PhysDrv[E:S] -a0

# MegaCli64 -PDHSP -set -PhysDrv[252:7] -a0

MegaCli使用手册

删除全局热备盘

MegaCli64 -PDHSP -Rmv -PhysDrv[E:S] -a0

# MegaCli64 -PDHSP -Rmv -PhysDrv[252:7] -a0

MegaCli使用手册

 

12.将物理盘下线和上线

# MegaCli64 -PDOffline/PDOnline -PhysDrv [E:S] -a0

下线(failed状态的盘可以下线)

# MegaCli64 -PDOffline -PhysDrv[252:7] -a0

MegaCli使用手册

上线

# MegaCli64 -PDOnline -PhysDrv[252:6] -a0

MegaCli使用手册

 

13.在线添加磁盘

# MegaCli64 -LDRecon -Start -r5 -Add -PhysDrv[252:7] -L0-a0

MegaCli使用手册

查看扩容的进度

# MegaCli64 -LDRecon -progdsply -L0 –a0

MegaCli使用手册

 

14. 查看RAID卡缓存策略

# MegaCli64 -LDinfo -Lall -aAll|grep -i “CachePolicy:”

Default Cache Policy: WriteBack, ReadAhead, Direct, NoWrite Cache if Bad BBU

Current Cache Policy: WriteThrough, ReadAheadNone, Cached,No Write Cache if Bad BBU

第一段

WriteBack:写缓存策略

WriteThrough:直接写入磁盘,不适用RAID卡缓存。

第二段

ReadAheadNone:不开启预读

ReadAhead:开启预读,在读操作的时候,预先把后面顺序的数据载入raid卡缓存,在顺序读的环境中能提供很好的性能,但是在随机读的环境中反而降低读的性能(适合文件系统,不适合数据库系统)

ReadAdaptive:自适应预读,在缓存和I/O空闲时选择预读,默认策略。

第三段

Direct:读操作不缓存到RAID卡缓存。

Cached:读操作缓存到RAID卡缓存。

第四段 如果BBU(电池)出现问题是否启用WriteCache

No Write Cache if Bad BBU:如果BBU出现问题不使用WriteCache,从WriteBack自动切换到WriteThrough,默认配置。

Write Cache OK if Bad BBU: 如果BBU出现问题仍启用WriteCache,这种配置是非常不安全的,除非是有UPS或者双电源的情况下。

缓存策略解释:

WT (WriteThrough

WB (WriteBack)

NORA (ReadAheadNone)

RA (ReadAhead)

ADRA (ReadAdaptive)

Cached

Direct

 

修改WriteBack:

# MegaCli64 -LDSetProp -WB -Lall -aAll

MegaCli使用手册

修改WriteThrough:

# MegaCli64 -LDSetProp -WT -Lall -aAll

MegaCli使用手册

修改Cached:

# MegaCli64 -LDSetProp -Cached -Lall -aAll

MegaCli使用手册

修改Direct:

# MegaCli64 -LDSetProp – Direct -Lall -aAll

MegaCli使用手册

 

15. 点亮指定硬盘(定位)

# MegaCli64 -PDLocate -start -physdrv[252:4] -a0

MegaCli使用手册

关闭定位灯

# MegaCli64 -PDLocate -stop -physdrv[252:4] -a0

MegaCli使用手册

16. 固件升级

MegaCli64 -adpfwflash -f x.rom -a0

# MegaCli64 -adpfwflash -f mr3108fw.rom -a0

 

四、  问题处理

1.     Firmwarestate:Unconfigured(good), Spun down解决方法:

重新热拔插指定硬盘,该状态会变成Firmware state:Unconfigured(good), Spun Up

创建raid后磁盘状态也会由Spun down变成SpunUp

2.     Firmware state: Unconfigured(bad)解决办法:

MegaCli64 -PDMakeGood -PhysDrv[E:S] -a0 固件状态会由Unconfigured(bad)变成Unconfigured(good), Spun Up

# MegaCli64 -PDMakeGood -PhysDrv[252:7] -a0

MegaCli使用手册

MegaCli使用手册

3.     Firmware state: failed解决办法:

出现failed状态的硬盘大多已损坏,建议更换(或报修);但可以强制上线。

强制上线步骤如下:

可以先将磁盘下线。 # MegaCli64 -PDOffline-PhysDrv[E:S] -a0

然后再上线。        # MegaCli64 -PDOnline -PhysDrv[E:S] -a0

MegaCli使用手册

4.     以下状态的解决办法:

Foreign State: Foreign

Foreign Secure: Drive is notsecured by a foreign lock key

MegaCli使用手册

办法一:可以清除恢复状态(慎用)

# MegaCli64 -CfgForeign -Clear -a0

办法二:导入配置,恢复虚拟磁盘组

# MegaCli64 -CfgForeign -import -a0

5.     修改策略报错:原因是当前在重建,等重建好就可以了

# MegaCli64 -LDSetProp -Direct -L0 -a0

MegaCli使用手册

MegaCli使用手册

6.     如何定位设备/dev/sd*由哪些磁盘组成并点亮指定硬盘。

# udevadm info -q path -n /dev/sda

MegaCli使用手册

可以看出设备/dev/sda是raid下的Virtual Drive: 0

MegaCli使用手册

然后确定Virtual Drive: 0是由哪些磁盘组成,并点亮磁盘

# MegaCli64 -ldpdinfo -a0|grep -Ei “(VirtualDrive:|RAID Level|^Size|Enclosure Device|Slot Number)”

MegaCli使用手册

上图可以看出Virtual Drive: 0是由[252:4]这个磁盘组成