megacli通过盘符定位物理盘_柴少鹏的官方网站
一、Megacli介紹
工作中偶爾會用到MegaCli這個工具,之前的博文里面也提到過這個工具,這里對于用法詳細的記錄一下。
通過LSI公司提供的MegaCli工具,
可以實現對RAID卡和硬盤的監控。
2013年12月: Avago公司以66億美元收購LSI,2015年5月: Avago公司以370億美元收購博通,因為MegaCLI 工具原來是LSI的,所以現在官方的下載地址也發生了變化。
1.1、下載與安裝
線上使用的工具一定要確保來源的安全,盡量官網下載,雖然可能在找的時候稍微有點麻煩。如果有些技巧的話,可能會稍快,下面說兩種方式。
第一個下載方式:
第二種下載方式:
好了安裝包已經下載下來了,這個zip包里面有不同系統的目錄,我們找到Linux目錄。
# rpm -ivh Linux/MegaCli-8.07.14-1.noarch.rpm ?#安裝一下軟件
# rpm -qa|grep MegaCli ?#查看包已經安裝成功
MegaCli-8.07.14-1.noarch
# /opt/MegaRAID/MegaCli/MegaCli64 -help ?#可以查看版本以及相關的命令使用說明。默認命令裝在了:/opt/MegaRAID/MegaCli/MegaCli64這里
#/opt/MegaRAID/MegaCli/MegaCli64 ?-cfgdsply -aALL|grep 'Product Name' ?#通過命令可以看出我們的RAID卡的型號為:PERC H730 Mini
Product Name: PERC H730 Mini
二、MegaCli命令羅列
#/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 -LDInfo -LALL -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相關信息
博文來自:www.51niux.com
三、常用命令詳解
3.1 查看磁盤是否有問題:
#/opt/MegaRAID/MegaCli/MegaCli64 -PDList -aALL|grep Error
#這是查看所有磁盤信息的命令,然后grep錯誤信息,看下面過濾出來的信息,這是我一個R720的機器,有個磁盤有問題準備要更換呢。Media?Error?Count:?0?Other?Error?Count:?0?這兩個數值來確定陣列中磁盤是否有問題;Medai?Error?Count?表示磁盤可能錯誤,可能是磁盤有壞道,這個值不為0值得注意,數值越大,危險系數越高,Other?Error?Count?表示磁盤可能存在松動,可能需要重新再插入。Media?Error?Count:?0
Other?Error?Count:?1
Media?Error?Count:?98139
Other?Error?Count:?26672
Media?Error?Count:?0
Other?Error?Count:?0
Media?Error?Count:?0
Other?Error?Count:?0
Media?Error?Count:?0
Other?Error?Count:?0
Media?Error?Count:?0
Other?Error?Count:?0
Media?Error?Count:?0
Other?Error?Count:?0
Media?Error?Count:?4
Other?Error?Count:?68
Media?Error?Count:?0
Other?Error?Count:?1
Media?Error?Count:?0
Other?Error?Count:?0
Media?Error?Count:?2872
Other?Error?Count:?20
Media?Error?Count:?0
Other?Error?Count:?0
#當然實際生產環境中,如果想長期的檢查磁盤是否可能要出問題了,還是建議去/var/log/message里面去檢測信息,因為用MegaCli這種方式檢測硬盤,當然硬盤出問題了可以報出來,但是就算你換了硬盤,再次檢測會發現計數器還是沒有清零,這是因為raid緩存的問題,但是這個問題需要重啟服務器才能解決,所以說用這種方式做一個常規性的監控方式的話,這個問題還是要考慮進來的。
3.2 查看磁盤的緩存策略
#/opt/MegaRAID/MegaCli/MegaCli64 -LDGetProp -Cache -L0 -a0 ? ?#我這是DELLR730XD的服務器
Adapter 0-VD 0(target id: 0): Cache Policy:WriteBack, ReadAhead, Direct, No Write Cache if bad BBU
#L0表示磁盤組0,?a0表示適配器號
#/opt/MegaRAID/MegaCli/MegaCli64 -LDInfo -LAll -aAll|grep 'Target'Virtual?Drive:?0?(Target?Id:?0)
Virtual?Drive:?1?(Target?Id:?1)
Virtual?Drive:?2?(Target?Id:?2)
Virtual?Drive:?3?(Target?Id:?3)
Virtual?Drive:?4?(Target?Id:?4)
Virtual?Drive:?5?(Target?Id:?5)
Virtual?Drive:?6?(Target?Id:?6)
Virtual?Drive:?7?(Target?Id:?7)
Virtual?Drive:?8?(Target?Id:?8)
Virtual?Drive:?9?(Target?Id:?9)
Virtual?Drive:?10?(Target?Id:?10)
Virtual?Drive:?11?(Target?Id:?11)
#下面是查看適配器的命令:
#/opt/MegaRAID/MegaCli/MegaCli64 -PDList -aALL|grep AdapterAdapter?#0
#結果為0,第一塊raid卡適配器就為0,一般服務器就一個raid適配器,所以一般都是a0。
#/opt/MegaRAID/MegaCli/MegaCli64 -LDGetProp -Cache -LALL -aALL ?# 查看所有磁盤的緩存策略 ,我這是十二塊硬盤Adapter?0-VD?0(target?id:?0):?Cache?Policy:WriteBack,?ReadAhead,?Direct,?No?Write?Cache?if?bad?BBU
Adapter?0-VD?1(target?id:?1):?Cache?Policy:WriteBack,?ReadAhead,?Direct,?No?Write?Cache?if?bad?BBU
Adapter?0-VD?2(target?id:?2):?Cache?Policy:WriteBack,?ReadAhead,?Direct,?No?Write?Cache?if?bad?BBU
Adapter?0-VD?3(target?id:?3):?Cache?Policy:WriteBack,?ReadAhead,?Direct,?No?Write?Cache?if?bad?BBU
Adapter?0-VD?4(target?id:?4):?Cache?Policy:WriteBack,?ReadAhead,?Direct,?No?Write?Cache?if?bad?BBU
Adapter?0-VD?5(target?id:?5):?Cache?Policy:WriteBack,?ReadAhead,?Direct,?No?Write?Cache?if?bad?BBU
Adapter?0-VD?6(target?id:?6):?Cache?Policy:WriteBack,?ReadAhead,?Direct,?No?Write?Cache?if?bad?BBU
Adapter?0-VD?7(target?id:?7):?Cache?Policy:WriteBack,?ReadAhead,?Direct,?No?Write?Cache?if?bad?BBU
Adapter?0-VD?8(target?id:?8):?Cache?Policy:WriteBack,?ReadAhead,?Direct,?No?Write?Cache?if?bad?BBU
Adapter?0-VD?9(target?id:?9):?Cache?Policy:WriteBack,?ReadAhead,?Direct,?No?Write?Cache?if?bad?BBU
Adapter?0-VD?10(target?id:?10):?Cache?Policy:WriteBack,?ReadAhead,?Direct,?No?Write?Cache?if?bad?BBU
Adapter?0-VD?11(target?id:?11):?Cache?Policy:WriteBack,?ReadAhead,?Direct,?No?Write?Cache?if?bad?BBU
#/opt/MegaRAID/MegaCli/MegaCli64 -LDGetProp -Cache -L0 -a0 ? ? ?#不同型號的服務器默認緩存策略也是不一樣的,我這是dell FX2的服務器Adapter?0-VD?0(target?id:?0):?Cache?Policy:WriteThrough,?ReadAheadNone,?Direct,?No?Write?Cache?if?bad?BBU
#輸出內容表示的意思:Adapter 0-VD 0(target id: 0): ?為磁盤適配器號,0代表第一個,Cache Policy:后面是緩存策略
一:WriteBack與WriteThrough
1.WriteBack:進行寫操作時,將數據寫入RAID卡緩存,并直接返回,RAID卡控制器將在系統負載低或者Cache滿了的情況下把數據寫?入 硬盤。該設置會大大提升RAID卡寫性能,絕大多數的情況下會降低系統IO負載。?數據的可靠性由BBU(Battery?Backup?Unit)電池 進行保證
2.WriteThrough:?數據寫操作不使用緩存,數據直接寫入磁盤。RAID卡寫性能下降,在大多數情況下該設置會造成系統IO負載上升;
二:ReadAheadNone,ReadAdaptive,ReadAhead.
ReadAheadNone:?不開啟預讀。這是默認的設置
ReadAhead:?在讀操作時,預先把后面順序的數據加載入Cache,在順序讀取時,能提高性能,相反會降低隨機讀的性能。
ReadAdaptive:?自適應預讀,當Cache?memory和IO空閑時,采取順序預讀,平衡了連續讀性能及隨機讀的性能,需要消耗一定的計算能力。
三、WT(Writethrough),WB(Writeback),NORA(Noreadahead),RA(Readahead),ADRA(Adaptivereadahead),Cached,Direct
Write Policy(寫入策略) 將高速緩存方法設置為回寫或通過寫。
* 在Write-through(通過寫)高速緩存中,當磁盤子系統已接收到一個事務中的所有數據時,該控制器將數據傳輸完成信號發送給主機。
* 在Write-back(回寫)高速緩存中,當控制器高速緩存已接收到某個事務中的所有數據時,該控制器將數據傳輸完成信號發送給主機。
Read-ahead(預讀)啟用邏輯驅動器的SCSI預讀功能。 可將此參數設為No-Read-Ahead(非預讀)、Read-ahead(預讀)或Adaptive(自適應)。 默認設置為Adaptive(自適應)。
* No-Read-Ahead(非預讀)指定控制器在當前邏輯驅動器中不使用預讀方式。
* Read-ahead(預讀)在讀操作時,預先把后面順序的數據加載入Cache,在順序讀取時,能提高性能,相反會降低隨機讀的性能。
* Adaptive(自適應)指定如果最近兩次的磁盤訪問出現在連續的扇區內,則控制器開始采用Read-ahead(預讀)。 如果所有的讀取請求都是隨機的,則該算法回復到No-Read-Ahead(非預讀),但仍要判斷所有的讀取請求是否有按順序操作的可能。當Cache memory和IO空閑時,采取順序預讀,平衡了連續讀性能及隨機讀的性能,需要消耗一定的計算能力。
Cache Policy(高速緩存策略) 適合在特定邏輯驅動器上讀取。 它并不影響Read ahead(預讀)高速緩存。* Cached I/O(高速緩存I/O)指定所有讀取數據在高速緩存存儲器中緩存。* Direct I/O(直接I/O)指定讀取數據不在高速緩存存儲器中緩存。 此為默認設置。 它不會代替高速緩存策略設置。數據被同時傳送到高速緩存和主機。 如果再次讀取同一數據塊,則從高速緩存存儲器讀取
四、Write Cache OK if Bad BBU和 No Write Cache if Bad BBU
No Write Cache if Bad BBU: 如果BBU出問題,則關閉Write
Cache。由WriteBack自動切換到WriteThrough模式。如果沒有特殊要求,強烈建議采用該設置,以確保數據的安全。
Write Cache OK if Bad BBU: 如果BBU出問題,依然啟用Write Cache.
這是不推薦的設置,BBU出問題將無法保證斷電情況下數據的正常,如果此時依然采用WriteBack模式,遇到斷電將發生數據丟失。除非有UPS作額外保證,不然不推薦采用這個設置。
博文來自:www.51niux.com
3.3 RAID卡策略的更改
修改WriteBack:
/opt/MegaRAID/MegaCli/MegaCli64 -LDSetProp -WB -Lall -aAll
修改WriteThrough:
/opt/MegaRAID/MegaCli/MegaCli64 -LDSetProp -WT -Lall -aAll
修改No Write Cache if Bad BBU:
/opt/MegaRAID/MegaCli/MegaCli64 -LDSetProp -NoCachedBadBBU -Lall -aAll
修改Write Cache OK if Bad BBU:
/opt/MegaRAID/MegaCli/MegaCli64 -LDSetProp -CachedBadBBU -Lall -aAll
或者其他:
/opt/MegaRAID/MegaCli/MegaCli64?-LDSetProp WT|WB|NORA|RA|ADRA?-L0?-a0
/opt/MegaRAID/MegaCli/MegaCli64?-LDSetProp?-Cached|-Direct?-L0?-a0
3.4 在線創建raid陣列,刪除陣列,查看進度
創建一個raid5陣列,由物理盤號為,3,4,5構成,該陣列的熱備盤是物理盤號6:
/opt/MegaRAID/MegaCli/MegaCli64?-CfgLdAdd?-r5?[32:3,32:4,32:5]?WB Direct?-Hsp[32:6]?-a0
#r5代表的就是raid5,[32:5]里面32代表的是Enclosure Device ID,5代表的是Slot Number,WB和Direct緩存策略前面提到了,Hsp[32:6] 指定第七塊物理硬盤為熱備盤,a0表示陳列卡號。
在線更換raid0硬盤,原硬盤損壞。如盤號為5的硬盤損壞之前做了raid0,現在更換之后需要對新硬盤做raid0:
/opt/MegaRAID/MegaCli/MegaCli64? -DiscardPreservedCache -L5 -a0
#如果全是單盤raid0的話,清空磁盤組5的一般是第六塊物理硬盤的raid緩存,不然就要重啟服務器生效,L5是通過MegaCli64 -LDInfo -Lall -aALL得到的raid組對應的ID號,如Virtual Drive: 5 (Target Id: 5),ID號是從0開始的。
#/opt/MegaRAID/MegaCli/MegaCli64?-CfgLdAdd -r0 [32:5] -a0 #將盤號為5的硬盤做成raid0模式,其他參數使用默認。
清空所有的緩存:(一般不要這么干)
#/opt/MegaRAID/MegaCli/MegaCli64 -DiscardPreservedCache -Lall -a0 -NoLOG
陣列創建完后,會有一個初始化同步塊的過程,可以看看其進度:
#/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
查看某個物理磁盤重建進度:
#/opt/MegaRAID/MegaCli/MegaCli64?-PDRbld?-ShowProg?-PhysDrv?[32:5]?-a0
以動態可視化文字界面顯示:
#/opt/MegaRAID/MegaCli/MegaCli64?-PDRbld?-ProgDsply?-PhysDrv?[32:5]?-a0
刪除raid陣列:
#/opt/MegaRAID/MegaCli/MegaCli64?-CfgLdDel?-L5?-a0 ?#刪除陣列
3.5 其他的一些raid操作
指定第 5 塊盤作為全局熱備#/opt/MegaRAID/MegaCli/MegaCli64?-PDHSP?-Set?[-EnclAffinity]?[-nonRevertible]?-PhysDrv[32:5]?-a0
指定為某個陣列的專用熱備#/opt/MegaRAID/MegaCli/MegaCli64?-PDHSP?-Set?[-Dedicated?[-Array1]]?[-EnclAffinity]?[-nonRevertible]?-PhysDrv[32:5]?-a0
刪除全局熱備#/opt/MegaRAID/MegaCli/MegaCli64?-PDHSP?-Rmv?-PhysDrv[32:5]?-a0
將某塊物理盤下線/上線#/opt/MegaRAID/MegaCli/MegaCli64?-PDOffline?-PhysDrv?[32:4]?-a0#/opt/MegaRAID/MegaCli/MegaCli64?-PDOnline?-PhysDrv?[32:4]?-a0
手工配置初始化
#/opt/MegaRAID/MegaCli/MegaCli64 -LDInit ?-start –L0 ?-a0 ? ? ? ? ? ? ? #快速初始化
#/opt/MegaRAID/MegaCli/MegaCli64 -LDInit ?-start ?-full –L0 -a0 ? ? ? ?#完全初始化
#/opt/MegaRAID/MegaCli/MegaCli64 -LDInit ?-progdsply -L0 -a0 ? ? ? ?#顯示初始化的進度
#/opt/MegaRAID/MegaCli/MegaCli64 -LDInit ?-abort ?-L0 ?-a0 ? ? ? ? ? ? ? #結束完全初始化
raid電池操作:
#/opt/MegaRAID/MegaCli/MegaCli64 -AdpBbuCmd -BbuLearn a0 ?#手動充電
#/opt/MegaRAID/MegaCli/MegaCli64 -AdpBbuCmd -GetBbuStatus -aALL #查看充電狀態
#/opt/MegaRAID/MegaCli/MegaCli64 -AdpBbuCmd -GetBbuStatus -aALL #查看充電進度百分比
查看raid陳列中掉線的硬盤:
#/opt/MegaRAID/MegaCli/MegaCli64 -pdgetmissing -a0
查看Megacli的log
#/opt/MegaRAID/MegaCli/MegaCli64?-FwTermLog?dsply?-a0?>?/tmp/Megacli.log
博文來自:www.51niux.com
3.6 查看磁盤的raid級別
RAID Level對應關系:
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呢?
#(新的機器可以通過下面命令來判斷,之前的不太清楚,應為raid0和不做raid顯示的信息很難判斷)
#/opt/MegaRAID/MegaCli/MegaCli64 -LDInfo -LAll -aAll|grep 'Is VD emulated'Is?VD?emulated??????:?No???#No就是沒做raid
#/opt/MegaRAID/MegaCli/MegaCli64 -LDInfo -LAll -aAll|grep 'Is VD emulated'Is?VD?emulated??????:?Yes??#yes就是做了raid
#如果是舊的服務器,如果我們上線服務器之前都會配置raid的話,一般會有名字,所以可以根據(但是這種方式也不是絕對的,可能不設置名稱):
#/opt/MegaRAID/MegaCli/MegaCli64 -LDInfo -LAll -aAll|grep NameName????????????????:raid1?#有名字的說明做了raid系統
Name????????????????:??#沒有名字的說明就是一塊裸盤
Name????????????????:
Name????????????????:
Name????????????????:
Name????????????????:
博文來自:www.51niux.com
3.7 如何判斷磁盤的raid級別:
雙盤做了raid1的舉例:
#/opt/MegaRAID/MegaCli/MegaCli64 -LDInfo -LAll -aAllAdapter?0?--?Virtual?Drive?Information:
Virtual?Drive:?0?(Target?Id:?0)
Name????????????????:raid1
RAID?Level??????????:?Primary-1,?Secondary-0,?RAID?Level?Qualifier-0??#通過RAID?Level可以看到這是raid1的盤
Size????????????????:?278.875?GB??#磁盤大小為300G
State???????????????:?Optimal??#最佳狀態
Strip?Size??????????:?64?KB
Number?Of?Drives????:?2??#2?說明是兩塊盤組成
Span?Depth??????????:?1??#說明實際只是raid?1
全盤做了raid5的舉例:
#/opt/MegaRAID/MegaCli/MegaCli64 -LDInfo -LAll -aAllAdapter?0?--?Virtual?Drive?Information:
Virtual?Drive:?0?(Target?Id:?0)
Name????????????????:raid5
RAID?Level??????????:?Primary-5,?Secondary-0,?RAID?Level?Qualifier-3??#通過RAID?Level??可以看出這是raid5
Size????????????????:?60.032?TB?#總大小60T
Sector?Size?????????:?512
Is?VD?emulated??????:?Yes
Parity?Size?????????:?5.457?TB?#單盤大小是6T
State???????????????:?Optimal
Strip?Size??????????:?64?KB
Number?Of?Drives????:?12??#由12塊盤組成
Span?Depth??????????:?1??#深度為1
注:如果是做了熱備盤的情況呢,再最下面會有兩行信息:
Number of Dedicated Hot Spares: 1? #有1塊盤做了熱備
0 : EnclId - 32 SlotId - 11?? #[32:11]盤做的熱備
raid10的舉例:
#/opt/MegaRAID/MegaCli/MegaCli64 -LDInfo -LAll -aAllVirtual?Drive:?1?(Target?Id:?1)
Name????????????????:raid10-01
RAID?Level??????????:?Primary-1,?Secondary-0,?RAID?Level?Qualifier-0
Size????????????????:?556.929?GB??#總大小600G
State???????????????:?Optimal
Strip?Size??????????:?64?KB
Number?Of?Drives?per?span:2??#表示每2個物理盤做成一個RAID1盤組
Span?Depth??????????:?2?#2個RAID1盤組做成了RAID10
3.8 raid的各種創建
對一臺R720XD的服務器做下RAID演示一下(單盤2T,12個插槽):
#這塊服務器的特性就是不做硬盤不做raid,系統識別不到硬盤。
[root@localhost Linux]# /opt/MegaRAID/MegaCli/MegaCli64 -PDList -aALL |egrep ?"Enclosure Device ID|Slot Number"
#用命令查看一下可以看出,Enclosure Device ID為32,Slot Number是從0到11,也就是12塊盤。Enclosure?Device?ID:?32
Slot?Number:?0
Enclosure?Device?ID:?32
Slot?Number:?1
Enclosure?Device?ID:?32
Slot?Number:?2
Enclosure?Device?ID:?32
Slot?Number:?3
Enclosure?Device?ID:?32
Slot?Number:?4
Enclosure?Device?ID:?32
Slot?Number:?5
Enclosure?Device?ID:?32
Slot?Number:?6
Enclosure?Device?ID:?32
Slot?Number:?7
Enclosure?Device?ID:?32
Slot?Number:?8
Enclosure?Device?ID:?32
Slot?Number:?9
Enclosure?Device?ID:?32
Slot?Number:?10
Enclosure?Device?ID:?32
Slot?Number:?11
下面我們先對第三塊盤,創建一個raid0.
# /opt/MegaRAID/MegaCli/MegaCli64 -CfgLdAdd -r0 [32:2] -a0Adapter?0:?Created?VD?1
Adapter?0:?Configured?the?Adapter!!
Exit?Code:?0x00
下面我們先對第四塊和第五塊盤,創建一個raid1
# /opt/MegaRAID/MegaCli/MegaCli64 -CfgLdAdd -r1 [32:3,32:4] -a0Adapter?0:?Created?VD?2
Adapter?0:?Configured?the?Adapter!!
Exit?Code:?0x00
下面我們再對第6,7,8塊盤,創建一個raid5
# /opt/MegaRAID/MegaCli/MegaCli64 -CfgLdAdd -r5 [32:5,32:6,32:7] -a0Adapter?0:?Created?VD?3
Adapter?0:?Configured?the?Adapter!!
Exit?Code:?0x00
下面我們再對第9,10,11,12塊盤,創建一個raid10
# /opt/MegaRAID/MegaCli/MegaCli64 -CfgSpanAdd -r10 -Array0[32:8,32:9] -Array1[32:10,32:11] -a0Adapter?0:?Created?VD?4
Adapter?0:?Configured?the?Adapter!!
Exit?Code:?0x00
#從上圖可以看出,我們做的raid級別
#第一個是raid1
#第二個是raid0
#第三個是raid1
#第四個是raid5
#第五個是raid10
3.9 刪除RAID卷組實操演示:
# /opt/MegaRAID/MegaCli/MegaCli64 -LDInfo -Lall -aALL?? #首先先查看一下我們的系統RAID狀態。Virtual?Drive:?1?(Target?Id:?1)???#帶有Target標記的,Id:1,這個1就是我們所要刪除的raid組的號。
# umount /data/? #這個raid是掛載到了/data目錄,我們先解除掛載
# /opt/MegaRAID/MegaCli/MegaCli64 -cfgldde -L1 -a0? #上面不是查出id=1了嘛,就是指定a0適配器的,id為1的raid卷組刪除.id=1上面是id=0.Virtual?Disk?is?associate?with?Cache?Cade.?Please?Use?force?option?to?delete???#這是說有緩存,要強制刪除
Exit?Code:?0x01
# /opt/MegaRAID/MegaCli/MegaCli64 -cfglddel? -L1 -force -a0? #加上-force參數,再次刪除Adapter?0:?Deleted?Virtual?Drive-1(target?id-1)??#提示刪除成功。
Exit?Code:?0x00
#另外:/opt/MegaRAID/MegaCli/MegaCli64 -cfgldde? -a0? 是將a0適配器所有的raid信息都清除掉。
博文來自:www.51niux.com
3.10 各種注
注一:
做raid之前可以用#smartctl -i 磁盤盤符 ?來過濾出要做raid的磁盤的Serial number:號跟?MegaCli64獲得的磁盤信息進行匹配,確保盤符號無誤。
注二:
在在線做raid的時候可能遇到一個問題:
問題:
The specified physical disk does not have the appropriate attributes to complete
the requested command.
Exit Code: 0x26
解決辦法:
通過MegaCli64查看磁盤詳細發現格式為:
Firmware state: JBOD ? #這種格式不支持直接做raid。
#MegaCli64 -PDMakeGOOD -Physdrv [32:8] ?-force -aALL ?#將磁盤格式轉換一下Adapter:?0:?EnclId-32?SlotId-8?state?changed?to?Unconfigured-Good.
Exit?Code:?0x00
#MegaCli64 -PDInfo -Physdrv [32:8] -a0 | grep -E "Enclosure Device|Slot Number|Firmware state"Enclosure?Device?ID:?32
Slot?Number:?8
Firmware?state:?Unconfigured(good),?Spun?Up??#磁盤格式已經發生了變化,這種就可以做raid了
注三:
磁盤的空間和讀寫情況是我們比較關心的,有時候想測試數據對比一下的時候,如果想跳過一切緩存條件來進行裸盤測試的話,那硬盤也不應該做raid。但是現在R720xd,R730XD系列,不做raid的話,操作系統識別不到硬盤。
問題:
# MegaCli64 -PDMakeJBOD -PhysDrv[32:1] -a0??? #我們將磁盤轉換成JBOD模式,就可以直接被 可以直接被系統識別到。 ???Adapter: 0: Failed to change PD state at EnclId-32 SlotId-1.
Exit Code: 0x01
# MegaCli64 -AdpGetProp -enablejbod -aALL? #查看失敗的原因是默認是禁止向JBOD轉換的,當然還有一種情況就是raid卡不支持了。
# MegaCli64 -PDList -aALL -Nolog|grep '^Firm'? #查看一下,看到現在都是Spun Up模式Firmware?state:?Online,?Spun?Up
Firmware?state:?Unconfigured(good),?Spun?Up
Firmware?state:?Unconfigured(good),?Spun?Up
Firmware?state:?Unconfigured(good),?Spun?Up
Firmware?state:?Unconfigured(good),?Spun?Up
# MegaCli64 -h|grep JBOD? #查看一下如何開啟JBOD模式MegaCli?-AdpSetProp?-EnableJBOD?-val?-aN|-a0,1,2|-aALL
val?-?0=Disable?JBOD?mode.
1=Enable?JBOD?mode.
|?CopyBackDsbl?|?LoadBalanceMode?|?UseFDEOnlyEncrypt?|?WBSupport?|?EnableJBOD
MegaCli?-PDMakeJBOD?-PhysDrv[E0:S0,E1:S1,...]?-aN|-a0,1,2|-aALL
# MegaCli64 -AdpSetProp -EnableJBOD -1? -a0 #開啟支持JBOD模式,如果這里失敗后面的也就沒法轉換了。Adapter?0:?Set?JBOD?to?Enable?success.
Exit?Code:?0x0
# MegaCli64 -PDMakeJBOD -PhysDrv[32:2] -a0? #將某個磁盤轉換為JBOD模式
注四:
磁盤做了raid0,如果涉及到硬盤的更換,如果只是這塊硬盤熱插拔,等你插上的時候會發現磁盤變為了,下面是idrac卡界面的顯示:
#這是因為這塊硬盤上面本身就有raid配置信息,然后你又插上了,raid卡就不識別了認為是一個外來硬盤。Foreign State: Foreign。
#如果就是這塊硬盤硬盤做了個熱插拔,那么可以執行:MegaCli64 -cfgforeign -Import -a0?? #執行導入命令。
#如果這塊硬盤是從別的raid卡上面拔下來的還有raid信息插上了需要在線清一下配置信息再創建呢,就下面的操作。
#MegaCli64? -CfgLdAdd -r0 [32:5] -a0?? #現在直接創建肯定是不行的,會有下面的報錯The?specified?physical?disk?does?not?have?the?appropriate?attributes?to?complete
the?requested?command.
Exit?Code:?0x26
#MegaCli64 -pdinfo -physdrv [32:5] -a0?? #可以單獨查看一下這塊盤的信息Firmware?state:?Unconfigured(good),?Spun?Up???#現在都是Spun?Up模式
Foreign?State:?Foreign???#硬盤被標記為“Foreign”外來配置,要清除一下
Foreign?Secure:?Drive?is?not?secured?by?a?foreign?lock?key
#MegaCli64 -cfgforeign -scan -a0?? #掃描外來配置的個數There?are?1?foreign?configuration(s)?on?controller?0.
Exit?Code:?0x00
#MegaCli64 -cfgforeign -clear -a0? #清除一下foreign配置Foreign?configuration?0?is?cleared?on?controller?0.
Exit?Code:?0x00
#MegaCli64 -cfgforeign -scan -a0?? #再次掃描外來配置的個數已經沒有了There?is?no?foreign?configuration?on?controller?0.
Exit?Code:?0x00
#MegaCli64 -pdinfo -physdrv [32:5] -a0? #再次查看下此塊硬盤的信息Firmware?state:?Unconfigured(good),?Spun?Up
Foreign?State:?None
#MegaCli64 -cfgldadd -r0 [32:5] -a0? #然后將這塊硬盤做成raid0Adapter?0:?Created?VD?5
Adapter?0:?Configured?the?Adapter!!
Exit?Code:?0x00
#MegaCli64? -ldinfo -L5 -a0?? #已經可以看到這塊盤的raid信息了。Adapter?0?--?Virtual?Drive?Information:
Virtual?Drive:?5?(Target?Id:?5)
Name????????????????:
RAID?Level??????????:?Primary-0,?Secondary-0,?RAID?Level?Qualifier-0
Size????????????????:?278.875?GB
State???????????????:?Optimal
Strip?Size??????????:?64?KB
Number?Of?Drives????:?1
Span?Depth??????????:?1
#MegaCli64 -pdinfo -physdrv [32:5] -a0?? #可以再看下這塊盤的磁盤信息Firmware?state:?Online,?Spun?Up
Foreign?State:?None
idrac卡界面查看:
#到此系統已經可以識別到這塊硬盤了。
總結
以上是生活随笔為你收集整理的megacli通过盘符定位物理盘_柴少鹏的官方网站的全部內容,希望文章能夠幫你解決所遇到的問題。
                            
                        - 上一篇: 军人得了白癫风会退伍吗
 - 下一篇: 机器学习中用到的概率知识_机器学习中有关