MegaCli RAID管理工具


MegaCli RAID管理工具

RAID管理工具MegaCli常用命令匯總

在服務器硬件運維領域ipmitool和megacli這兩款硬件維護工具,俗稱業內“倚天劍”和“屠龍刀”,這篇博客就簡單介紹一下Megacli陣列卡管理工具。當然除了megacli,在Linux 系統下還有很多的Raid卡管理工具,如HP 官方為HP 服務器提供的hpacucli、hpssacli、ssacli,還有一些工具如:ARCCONF 、StorCLI 等,大家可以自行查閱。

一. MegaCli簡介

MegaCli是由LSI原廠提供的LSI,MegaCli是一款管理維護硬件RAID的軟件,可以通過它來了解當前raid卡的所有信息,包括 raid卡的型號,raid的陣列類型,raid 上物理磁盤和邏輯盤狀態,等等。通常,我們在操作系統下對硬盤當前的狀態不太好確定,一般通過登錄硬件管理口或機房巡檢發現故障。而MegaCli可以做到在操作系統下查看陣列卡相關信息,一般通過 MegaCli 的Media Error Count: 0 Other Error Count: 0 這兩個數值來確定陣列中磁盤是否有問題;Medai Error Count 表示磁盤可能錯誤,可能是磁盤有壞道,這個值不為0值得注意,數值越大,危險系數越高。Firmware state 表示磁盤狀態,需要重點關注。

二. 下載與安裝

1、 MegCli 下載
官網地址:http://docs.avagotech.com/docs/12351587

2、 MegCli 安裝

# unzip MegaCLI_8-07-06.zip
# rpm -ivh ./Linux/MegaCli-8.07.06-1.noarch.rpm
# rpm -ql MegaCli
 /opt/MegaRAID/MegaCli/MegaCli
 /opt/MegaRAID/MegaCli/MegaCli64
 /opt/MegaRAID/MegaCli/libstorelibir-2.so.13.05-0
# ln -s /opt/MegaRAID/MegaCli/MegaCli64 /bin/MegaCli64

說明:安裝完畢之后MegaCli64所在路徑為/opt/MegaRAID/MegaCli/MegaCli64,需要輸入全路徑才能運行MegaCli64工具,如果嫌麻煩可以做一個軟連接到 /bin//MegaCli64,這樣就可以直接運行了。

三、命令詳解

常用命令總結

/opt/MegaRAID/MegaCli/MegaCli64 -FwTermLog -Dsply -aALL   【查raid卡日志】
/opt/MegaRAID/MegaCli/MegaCli64 -adpCount  【顯示適配器個數】
/opt/MegaRAID/MegaCli/MegaCli64 -AdpAllInfo -aAll 【顯示所有適配器信息】
/opt/MegaRAID/MegaCli/MegaCli64 -LDInfo -LALL -aAll 【顯示所有邏輯磁盤組信息】
/opt/MegaRAID/MegaCli/MegaCli64 -PDList -aAll 【顯示所有的物理信息】
/opt/MegaRAID/MegaCli/MegaCli64 -AdpGetTime –aALL 【顯示適配器時間】
/opt/MegaRAID/MegaCli/MegaCli64 -AdpBbuCmd -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相關信息】

查raid卡信息(生產商、電池信息及所支持的raid級別)

/opt/MegaRAID/MegaCli/MegaCli64 -AdpAllInfo -aALL |grep -E "Product Name|BBU|Memory Size|RAID Level Supported"

查看raid卡日志

/opt/MegaRAID/MegaCli/MegaCli64 -FwTermLog -Dsply -aALL

顯示適配器個數

/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 -NoLog

查看所有Virtual Disk的狀態

/opt/MegaRAID/MegaCli/MegaCli64 -LdPdInfo -aAll -NoLog

查看虛擬化(vd)和物理盤(pd)的信息,比如查看物理硬盤數,是否有硬盤offline或者degraded

/opt/MegaRAID/MegaCli/MegaCli64 -AdpAllInfo -aALL |grep -E "Device Present" -A9

查看硬盤是否online

/opt/MegaRAID/MegaCli/MegaCli64 -PDList -aALL |grep "Firmware state"

查看硬盤是否存在物理錯誤(error不為0,可能會有硬盤故障即將發生)

/opt/MegaRAID/MegaCli/MegaCli64 -PDList -aALL |grep -i error

查看電池信息(電池類型、電池狀態、充電狀態、溫度等)

/opt/MegaRAID/MegaCli/MegaCli64 -AdpBbuCmd -aAll

顯示所有邏輯磁盤組信息(做了幾組raid,raid cache的默認和當前策略,做好raid后的虛擬盤容量)

/opt/MegaRAID/MegaCli/MegaCli64 -LDInfo -LALL -aAll

顯示所有物理盤(物理磁盤個數、大小、是否存在error)

/opt/MegaRAID/MegaCli/MegaCli64 -PDList -aAll

顯示所有物理盤物理錯誤

/opt/MegaRAID/MegaCli/MegaCli64 -PDList -aAll |grep -i error

查看充電狀態

/opt/MegaRAID/MegaCli/MegaCli64 -AdpBbuCmd -GetBbuStatus -aALL |grep 'Charger Status'

顯示BBU狀態信息,比如電池是否,如果issohgood為Yes為正常,No為異常

/opt/MegaRAID/MegaCli/MegaCli64 -AdpBbuCmd -GetBbuStatus -aALL|grep -i issohgood

顯示BBU狀態信息

/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

顯示Raid卡型號,cache大小、Raid設置,cache策略、Disk相關信息

/opt/MegaRAID/MegaCli/MegaCli64 -cfgdsply -aALL |egrep "PDs|VDs|Product Name|Memory|BBU:"

查看磁盤緩存策略(查看vd的)

/opt/MegaRAID/MegaCli/MegaCli64 -LDGetProp -Cache -LALL -aALL

關閉緩存

# megacli -LDSetProp -DisDskCache -L0 -a0

或者(查看pd的)

/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

磁帶狀態的變化,從拔盤,到插盤的過程中:

Device |Normal|Damage|Rebuild|Normal
Virtual Drive |Optimal|Degraded|Degraded|Optimal
Physical Drive |Online|Failed –> Unconfigured|Rebuild|Online

RAID Level對應關系:

RAID Level : Primary-1, Secondary-0, RAID Level Qualifier-0 RAID1
RAID Level : Primary-0, Secondary-0, RAID Level Qualifier-0 RAID0
RAID Level : Primary-5, Secondary-0, RAID Level Qualifier-3 RAID5
RAID Level : Primary-1, Secondary-3, RAID Level Qualifier-0 RAID10

查看物理磁盤重建(Rebuid)進度

/opt/MegaRAID/MegaCli/MegaCli64 -PDRbld -ShowProg -PhysDrv [1:5] -a0

或者以動態可視化文字界面顯示

/opt/MegaRAID/MegaCli/MegaCli64 -PDRbld -ProgDsply -PhysDrv [1:5] -a0

設置rebuild的速率

/opt/MegaRAID/MegaCli/MegaCli64 -AdpSetProp RebuildRate -30 -a0

手動開啟rebuid

/opt/MegaRAID/MegaCli/MegaCli64 -pdrbld -start -physdrv[12:10] -a0

關閉Rebuild

/opt/MegaRAID/MegaCli/MegaCli64 -AdpAutoRbld -Dsbl -a0

查看E S

/opt/MegaRAID/MegaCli/MegaCli64 -PDList -aAll -NoLog | grep -Ei "(enclosure|slot)"

在線做Raid

/opt/MegaRAID/MegaCli/MegaCli64 -CfgLdAdd -r0[0:11] WB NORA Direct CachedBadBBU -strpsz64 -a0 -NoLog
/opt/MegaRAID/MegaCli/MegaCli64 -CfgLdAdd -r5 [12:2,12:3,12:4,12:5,12:6,12:7] WB Direct -a0

點亮指定硬盤(定位)

/opt/MegaRAID/MegaCli/MegaCli64 -PdLocate -start -physdrv[252:2] -a0

清除Foreign狀態

/opt/MegaRAID/MegaCli/MegaCli64 -CfgForeign -Clear -a0

查看RAID陣列中掉線的盤

/opt/MegaRAID/MegaCli/MegaCli64 -pdgetmissing -a0

替換壞掉的模塊

/opt/MegaRAID/MegaCli/MegaCli64 -pdreplacemissing -physdrv[12:10] -Array5 -row0 -a0

查看Megacli的log

/opt/MegaRAID/MegaCli/MegaCli64 -FwTermLog dsply -a0 > adp2.log

設置HotSpare

/opt/MegaRAID/MegaCli/MegaCli64 -pdhsp -set [-Dedicated [-Array2]] [-EnclAffinity] [-nonRevertible] -PhysDrv[4:11] -a0
/opt/MegaRAID/MegaCli/MegaCli64 -pdhsp -set [-EnclAffinity] [-nonRevertible] -PhysDrv[32:1}] -a0

創建一個 raid5 陣列,由物理盤 2,3 4 構成,該陣列的熱備盤是物理盤 5

/opt/MegaRAID/MegaCli/MegaCli64-CfgLdA d -r5 [1:2,1:3,1:4] WB Direct -Hsp[1:5] -a0

創建陣列,不指定熱備

/opt/MegaRAID/MegaCli/MegaCli64-CfgLdA d -r5 [1:2,1:3,1:4] WB Direct -a0

刪除陣列

/opt/MegaRAID/MegaCli/MegaCli64-CfgLdDel -L1 -a0

在線添加磁盤

/opt/MegaRAID/MegaCli/MegaCli64-LDRecon -Star - 5 Ad -PhysDrv[1:4] -L1 -a0

陣列創建完后,會有一個初始化同步塊的過程,可以看 其進度。

/opt/MegaRAID/MegaCli/MegaCli64-LDInit -ShowProg -LA L -aAL或者以動態可視化文字界面顯示
/opt/MegaRAID/MegaCli/MegaCli64-LDInit -ProgDsply -LA L -aAL

查看陣列后台初始化進度

/opt/MegaRAID/MegaCli/MegaCli64 -LDBI -ShowProg -LALL -aAL

或者以動態可視化文字界面顯示

/opt/MegaRAID/MegaCli/MegaCli64 -LDBI -ProgDsply -LALL -aAL

指定第 5 塊盤作為全局熱備

/opt/MegaRAID/MegaCli/MegaCli64-PDHSP -Set [-EnclAf in ty] [-no Rev rtible] -PhysDrv[1:5] -a0

指定為某個陣列的專用熱備

/opt/MegaRAID/MegaCli/MegaCli64-PDHSP -Set [-Dedicated [-Ar ay1] [-EnclAf in ty] [-no Rev rtible] -PhysDrv[1:5] -a0

刪除全局熱備

/opt/MegaRAID/MegaCli/MegaCli64-PDHSP -Rmv -PhysDrv[1:5] -a0

將某塊物理盤下線/上線

/opt/MegaRAID/MegaCli/MegaCli64-PDOf line -PhysDrv [1:4] -a0
/opt/MegaRAID/MegaCli/MegaCli64-PDOnli e -PhysDrv [1:4] -a0

查看當前raid緩存狀態,raid緩存狀態設置為wb的話要注意電池放電事宜,設置電池放電模式為自動學習模式

/opt/MegaRAID/MegaCli/MegaCli64   -ldgetprop  -dskcache -lall  -aall

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

參考:
https://idc.wanyunshuju.com/cym/646.html
http://blog.itpub.net/69926532/viewspace-2647730/https://www.jianshu.com/p/dcfd4bfba207


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM