常用命令使用 /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 -PdLocate -start -physdrv[252:2] -a0 [点亮指定硬盘(定位)] /opt/MegaRAID/MegaCli/MegaCli64 -CfgForeign -Clear -a0 [清除Foreign状态] /opt/MegaRAID/MegaCli/MegaCli64 -AdpBbuCmd -GetBbuStatus -aALL |grep 'ChargerStatus' [查看充电状态] /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相关信息] /opt/MegaRAID/MegaCli/MegaCli64 -PDList -aAll -NoLog [查看所有硬盘的状态] /opt/MegaRAID/MegaCli/MegaCli64 -LdPdInfo -aAll -NoLog [查看所有Virtual Disk的状态] 磁带状态的变化,从拔盘,到插盘的过程中。 Device |Normal|Damage|Rebuild|Normal Virtual Drive |Optimal|Degraded|Degraded|Optimal Physical Drive |Online|Failed –> Unconfigured|Rebuild|Online 查看磁盘缓存策略 /opt/MegaRAID/MegaCli/MegaCli64 -LDGetProp -Cache -L0 -a0 /opt/MegaRAID/MegaCli/MegaCli64 -LDGetProp -Cache -L1 -a0 /opt/MegaRAID/MegaCli/MegaCli64 -LDGetProp -Cache -LALL -a0 /opt/MegaRAID/MegaCli/MegaCli64 -LDGetProp -Cache -LALL -aALL /opt/MegaRAID/MegaCli/MegaCli64 -LDGetProp -DskCache -LALL -aALL 设置磁盘缓存策略 缓存策略解释 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 /opt/MegaRAID/MegaCli/MegaCli64 -LDSetProp -Cached|-Direct -L0 -a0 enable / disable disk cache /opt/MegaRAID/MegaCli/MegaCli64 -LDSetProp -EnDskCache|-DisDskCache -L0 -a0 Raid 管理 RAID Level对应关系 Raid信息 Raid级别 RAID Level : Primary-1, Secondary-0, RAID Level Qualifier-0 RAID 1 RAID Level : Primary-0, Secondary-0, RAID Level Qualifier-0 RAID 0 RAID Level : Primary-5, Secondary-0, RAID Level Qualifier-3 RAID 5 RAID Level : Primary-1, Secondary-3, RAID Level Qualifier-0 RAID 10 创建一个 raid5 阵列,由物理盘 2,3,4 构成,该阵列的热备盘是物理盘 5 /opt/MegaRAID/MegaCli/MegaCli64 -CfgLdAdd -r5 [1:2,1:3,1:4] WB Direct -Hsp[1:5] -a0 创建阵列,不指定热备 /opt/MegaRAID/MegaCli/MegaCli64 -CfgLdAdd -r5 [1:2,1:3,1:4] WB Direct -a0 查看RAID阵列中掉线的盘 /opt/MegaRAID/MegaCli/MegaCli64 -pdgetmissing -a0 删除阵列 /opt/MegaRAID/MegaCli/MegaCli64 -CfgLdDel -L1 -a0 替换坏掉的模块 /opt/MegaRAID/MegaCli/MegaCli64 -pdreplacemissing -physdrv[12:10] -Array5 -row0 -a0 在线添加磁盘 /opt/MegaRAID/MegaCli/MegaCli64 -LDRecon -Start -r5 -Add -PhysDrv[1:4] -L1 -a0 阵列创建完后,会有一个初始化同步块的过程,可以看看其进度。 /opt/MegaRAID/MegaCli/MegaCli64 -LDInit -ShowProg -LALL -aALL 或者以动态可视化文字界面显示 /opt/MegaRAID/MegaCli/MegaCli64 -LDInit -ProgDsply -LALL -aALL 查看阵列后台初始化进度 /opt/MegaRAID/MegaCli/MegaCli64 -LDBI -ShowProg -LALL -aALL 或者以动态可视化文字界面显示 /opt/MegaRAID/MegaCli/MegaCli64 -LDBI -ProgDsply -LALL -aALL 指定第 5 块盘作为全局热备 /opt/MegaRAID/MegaCli/MegaCli64 -PDHSP -Set [-EnclAffinity] [-nonRevertible] -PhysDrv[1:5] -a0 指定为某个阵列的专用热备 /opt/MegaRAID/MegaCli/MegaCli64 -PDHSP -Set [-Dedicated [-Array1]] [-EnclAffinity] [-nonRevertible] -PhysDrv[1:5] -a0 删除全局热备 /opt/MegaRAID/MegaCli/MegaCli64 -PDHSP -Rmv -PhysDrv[1:5] -a0 将某块物理盘下线/上线 /opt/MegaRAID/MegaCli/MegaCli64 -PDOffline -PhysDrv [1:4] -a0 /opt/MegaRAID/MegaCli/MegaCli64 -PDOnline -PhysDrv [1:4] -a0 手动开启 rebuid /opt/MegaRAID/MegaCli/MegaCli64 -pdrbld -start -physdrv[12:10] -a0 关闭 rebuild /opt/MegaRAID/MegaCli/MegaCli64 -AdpAutoRbld -Dsbl -a0 设置rebuild的速率 /opt/MegaRAID/MegaCli/MegaCli64 -AdpSetProp RebuildRate -30 -a0 查看物理磁盘重建进度 Rebuild /opt/MegaRAID/MegaCli/MegaCli64 -PDRbld -ShowProg -PhysDrv [1:5] -a0 或者以动态可视化文字界面显示 /opt/MegaRAID/MegaCli/MegaCli64 -PDRbld -ProgDsply -PhysDrv [1:5] -a0 查看 ES /opt/MegaRAID/MegaCli/MegaCli64 -PDList -aAll -NoLog | grep -Ei "(enclosure|slot)" raid 电池设置相关 查看电池状态信息(Display BBU Status Information) MegaCli -AdpBbuCmd -GetBbuStatus -aN|-a0,1,2|-aALL MegaCli -AdpBbuCmd -GetBbuStatus -aALL 查看电池容量(Display BBU Capacity Information) MegaCli -AdpBbuCmd -GetBbuCapacityInfo -aN|-a0,1,2|-aALL MegaCli -AdpBbuCmd -GetBbuCapacityInfo –aALL 查看电池设计参数(Display BBU Design Parameters) MegaCli -AdpBbuCmd -GetBbuDesignInfo -aN|-a0,1,2|-aALL MegaCli -AdpBbuCmd -GetBbuDesignInfo –aALL 查看电池属性(Display Current BBU Properties) MegaCli -AdpBbuCmd -GetBbuProperties -aN|-a0,1,2|-aALL MegaCli -AdpBbuCmd -GetBbuProperties –aALL 设置电池为学习模式为循环模式(Start BBU Learning Cycle) Description Starts the learning cycle on the BBU. No parameter is needed for this option. MegaCli -AdpBbuCmd -BbuLearn -aN|-a0,1,2|-aALL 设置磁盘的缓存模式和访问方式 (Change Virtual Disk Cache and Access Parameters) Description Allows you to change the following virtual disk parameters: -WT (Write through), WB (Write back): Selects write policy. -NORA (No read ahead), RA (Read ahead), ADRA (Adaptive read ahead): Selects read policy. -Cached, -Direct: Selects cache policy. -RW, -RO, Blocked: Selects access policy. -EnDskCache: Enables disk cache. -DisDskCache: Disables disk cache. MegaCli -LDSetProp { WT | WB|NORA |RA | ADRA|-Cached|Direct} | {-RW|RO|Blocked} | {-Name[string]} | {-EnDskCache|DisDskCache} –Lx | -L0,1,2|-Lall -aN|-a0,1,2|-aALL MegaCli -LDSetProp WT -L0 -a0 显示磁盘缓存和访问方式(Display Virtual Disk Cache and Access Parameters) MegaCli -LDGetProp -Cache | -Access | -Name | -DskCache -Lx|-L0,1,2| -Lall -aN|-a0,1,2|-aALL Displays the cache and access policies of the virtual disk(s): -WT (Write through), WB (Write back): Selects write policy. -NORA (No read ahead), RA (Read ahead), ADRA (Adaptive read ahead): Selects read policy. -Cache, -Cached, Direct: Displays cache policy. -Access, -RW, -RO, Blocked: Displays access policy. -DskCache: Displays physical disk cache policy. Megaraid 必知必会 使用 LSI 的 megaraid 可以对 raid 进行有效监控。别的厂商比如 HP,IBM 也有自己的 raid API MegaCli -ldinfo -lall -aall 查询raid级别,磁盘数量,容量,条带大小。 MegaCli -cfgdsply -aALL |grep Policy 查询控制器cache策略 MegaCli -LDSetProp WB -L0 -a0 设置write back功能 MegaCli -LDSetProp CachedBadBBU -L0 -a0 设置即使电池坏了还是保持WB功能 MegaCli -AdpBbuCmd -BbuLearn a0 手动充电 MegaCli -FwTermLog -Dsply -aALL 查询日志 MegaCli -adpCount 显示适配器个数 显示所有适配器信息 MegaCli -AdpAllInfo -aAll Critical Disks : 0 Failed Disks : 0 显示所有逻辑磁盘组信息 MegaCli -LDInfo -LALL -aAll 显示所有的物理信息 MegaCli -PDList -aAll Media Error Count: 0 Other Error Count: 0 查看充电状态 MegaCli -AdpBbuCmd -GetBbuStatus -aALL Learn Cycle Requested : No Fully Charged : Yes 显示BBU(后备电池)状态信息: MegaCli -AdpBbuCmd -GetBbuStatus -aALL 显示BBU容量信息: MegaCli -AdpBbuCmd -GetBbuCapacityInfo -aALL 显示BBU设计参数: MegaCli -AdpBbuCmd -GetBbuDesignInfo -aALL 显示当前BBU属性: MegaCli -AdpBbuCmd -GetBbuProperties -aALL 显示Raid卡型号,Raid设置,Disk相关信息: MegaCli -cfgdsply -aALL 查看Cache 策略设置: MegaCli -cfgdsply -aALL |grep -i Policy Current Cache Policy: WriteBack, ReadAheadNone, Direct, Write Cache OK if Bad BBU 查看充电进度百分比: MegaCli -AdpBbuCmd -GetBbuStatus -aALL ############################### https://segmentfault.com/a/1190000008780600 ######################################## 手动创建 raid ##删除raid root@scaler:~# /opt/MegaRAID/MegaCli/MegaCli64 -CfgLdDel -L2 -A0 ##创建raid root@scaler:~# /opt/MegaRAID/MegaCli/MegaCli64 CfgLDAdd -r5 [41:5,41:6,41:7,41:8,41:9,41:10,41:11,41:12,41:13,41:14] -strpsz128 -A0 raid 卡日志,保存到文件 /opt/MegaRAID/MegaCli/MegaCli64 -AdpEventLog -GetEvents -f raid.envent.log -a0 新加入硬盘,重新插拔硬盘 清除foreign key /opt/MegaRAID/MegaCli/MegaCli64 -CfgForeign -Scan -aALL /opt/MegaRAID/MegaCli/MegaCli64 -CfgForeign -Clear -aALL 如何查看和清除 raid的 cache ##删除,重建raid时可能需要 /opt/MegaRAID/MegaCli/MegaCli64 -GetPreservedCacheList -aALL /opt/MegaRAID/MegaCli/MegaCli64 -DiscardPreservedCache -L7 -aall /opt/MegaRAID/MegaCli/MegaCli64 -PDMakeGood -PhysDrv[8:1] -a0 /opt/MegaRAID/MegaCli/MegaCli64 -CfgForeign -import -a0 常用检查 磁盘erro /opt/MegaRAID/MegaCli/MegaCli64 -pdlist -a0|grep -Ei "enc|Slot Number|Firmware stat|media error |other error" raid一致性检查 禁用一直性 检查 /opt/MegaRAID/MegaCli/MegaCli64 -AdpCcSched -Dsbl -Aall 启用一致性检查, /opt/MegaRAID/MegaCli/MegaCli64 -AdpCcSched -ModeConc -Aall 查看一直性检查 信息 /opt/MegaRAID/MegaCli/MegaCli64 -AdpCcSched -info -Aall 在pdlist 中可以看到 硬盘类型 Media Type: Hard Disk Device,,如果是固态盘,会显示 solid state device PD Type: SAS,,这个应该可以判断是 sata盘 还是sas盘。。 flush raid cache /opt/MegaRAID/MegaCli/MegaCli64 -AdpCacheFlush -Aall 闪烁硬盘 MegaCli -PdLocate -start -physdrv [E:S] -aALL write back 只对写有用。 BBu状态 会影响到 write back 模式 是否开启。 /opt/MegaRAID/MegaCli/MegaCli64 -LDInfo -Lall -Aall 对某一个具体的 logic disk 查看 all 改成 对应0,1, 物理盘,逻辑盘一起看 megacli -LdPdInfo -aALL 关闭raid组的告警 -AdpSetProp AlarmDsbl -aALL /opt/MegaRAID/MegaCli/MegaCli64 ldpdinfo -aall |egrep "Slot |Firmware" /opt/MegaRAID/MegaCli/MegaCli64 -AdpBbuCmd -aAll 检查BBBU 状态,期望 optima root@host185:~# /opt/MegaRAID/MegaCli/MegaCli64 -AdpBbuCmd -aAll |grep -Ei battery 检查cache policy /opt/MegaRAID/MegaCli/MegaCli64 -LDInfo -Lall -Aall Current Cache Policy 期望Current Cache Policy No Write Cache if Bad BBU Disk Cache Policy 期望 disable /opt/MegaRAID/MegaCli/MegaCli64 -LDInfo -Lall -aAll 设置cache ./MegaCli -LDSetProp NOCachedBadBBU -Lall -aALL ./MegaCli -LDSetProp CachedBadBBU -Lall -aALL 检查RAId 初始化进度 /opt/MegaRAID/MegaCli/MegaCli64 -ldinfo -lall -a0 raid 跟换硬盘后,判断状态 1417 /opt/MegaRAID/MegaCli/MegaCli64 -ldinfo -lall -a0|less 1418 /opt/MegaRAID/MegaCli/MegaCli64 -ldpdinfo -a0|less 查看每个物理硬盘状态 1419 /opt/MegaRAID/MegaCli/MegaCli64 -pdlist -a0|egrep "Slot Number|Firmware stat" write through 改成 write back /opt/MegaRAID/MegaCli/MegaCli64 LDSetProp WB -Lall -Aall ##更改1个logic disk /opt/MegaRAID/MegaCli/MegaCli64 -LDSetProp WB -L3 -A0 /opt/MegaRAID/MegaCli/MegaCli64 -LDSetProp WB -L4 -A0 查看电池状态 /opt/MegaRAID/MegaCli/MegaCli64 -AdpBbuCmd -GetBbuStatus -aALL -AdpBbuCmd -GetBbuCapacityInfo -A0 换硬盘 ,查看rebuild进度 /opt/MegaRAID/MegaCli/MegaCli64 -PDRbld -showprog -physDrv [40:7] -a0 关闭 读的cache /opt/MegaRAID/MegaCli/MegaCli64 LDSetProp Direct -Lall -Aall 关闭 disk cache /opt/MegaRAID/MegaCli/MegaCli64 -LDSetProp -DisDskCache -Lall -Aall