查看MegaSAS RAID卡的緩存策略
root@localhost:/usr/bin# MegaCli -LDInfo -Lall -aALL Adapter 0 -- Virtual Drive Information: Virtual Drive: 0 (Target Id: 0) Name : RAID Level : Primary-1, Secondary-0, RAID Level Qualifier-0 Size : 1.090 TB Sector Size : 512 Is VD emulated : No Mirror Data : 1.090 TB State : Optimal Strip Size : 256 KB Number Of Drives : 2 Span Depth : 1 Default Cache Policy: WriteBack, ReadAhead, Direct, No Write Cache if Bad BBU Current Cache Policy: WriteBack, ReadAhead, Direct, No Write Cache if Bad BBU Default Access Policy: Read/Write Current Access Policy: Read/Write Disk Cache Policy : Disk's Default Encryption Type : None Bad Blocks Exist: No PI type: No PI Is VD Cached: No Virtual Drive: 1 (Target Id: 1) Name : RAID Level : Primary-5, Secondary-0, RAID Level Qualifier-3 Size : 4.363 TB Sector Size : 512 Is VD emulated : Yes Parity Size : 893.75 GB State : Optimal Strip Size : 256 KB Number Of Drives : 6 Span Depth : 1 Default Cache Policy: WriteBack, ReadAhead, Direct, No Write Cache if Bad BBU Current Cache Policy: WriteBack, ReadAhead, Direct, No Write Cache if Bad BBU Default Access Policy: Read/Write Current Access Policy: Read/Write Disk Cache Policy : Disk's Default Encryption Type : None Bad Blocks Exist: No PI type: No PI Is VD Cached: No Exit Code: 0x00
- Default Cache Policy: 默認的緩存策略,針對每個RAID可以有不同的設置.
- Current Cache Policy: 當前生效的緩存策略.
策略說明
第一段: WriteBack, WriteThrough
- WriteBack:回寫。進行寫操作時,將數據寫入RAID卡緩存,並直接返回,RAID卡控制器將在系統負載低或者Cache滿了的情況下把數據寫入硬盤。該設置會大大提升RAID卡寫性能,絕大多數的情況下會降低系統IO負載。 數據的可靠性由RAID卡的BBU(Battery Backup Unit)進行保證。
- WriteThrough: 寫通。數據寫操作不使用緩存,數據直接寫入磁盤。RAID卡寫性能下降,在大多數情況下該設置會造成系統IO負載上升。
第二段: ReadAheadNone, ReadAdaptive, ReadAhead.
- ReadAheadNone: 不開啟預讀。這是默認的設置
- ReadAhead: 在讀操作時,預先把后面順序的數據加載入Cache,在順序讀取時,能提高性能,相反會降低隨機讀的性能。
- ReadAdaptive: 自適應預讀,當Cache memory和IO空閑時,采取順序預讀,平衡了連續讀性能及隨機讀的性能,需要消耗一定的計算能力。
第三段: Direct, Cached.
- Direct: Direct IO模式,讀操作不緩存到cache memory中,數據將同時傳輸到cache中和應用,如果接下來要讀取相同的數據塊,則直接從Cache memory中獲取. 這是默認的設置
- Cached: Cached IO模式,所有讀操作都會緩存到cache memory中。
第四段: 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作額外保證,不然不推薦采用這個設置。
策略自動切換的問題
由於MegaSAS RAID卡默認采用No Write Cache if Bad BBU的設置,將可能發生Write Cache策略變更的情況(由WriteBack變成WriteThrough),導致寫性能下降,如果該自動變更發生在業務高峰且系統Io負載高的時候,可能會引發不可預測的問題,如卡機。以下原因將造成Write Cache策略的變更.
- RAID卡進入BBU Learn Cycle: 詳細介紹見下面
- 檢測到某些電池故障,如電池容量過低等,一般是電池老化帶來的影響,IBM建議一年更換一次RAID卡電池
- 沒有安裝電池, 部分服務器購買時不帶電池,導致被自動設置為WriteThrough
查看當前BBU的狀態
MegaCli -AdpBbuCmd -GetBbuStatus -aALL
root@localhost:/usr/bin# MegaCli -AdpBbuCmd -GetBbuStatus -aALL BBU status for Adapter: 0 BatteryType: CVPM02 Voltage: 9512 mV Current: 0 mA Temperature: 26 C Battery State: Optimal BBU Firmware 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 be replaced : No Cache Offload premium feature required : No Module microcode update required : No BBU GasGauge Status: 0x6bf6 Pack energy : 246 J Capacitance : 107 Remaining reserve space : 0 Exit Code: 0x00
- Charging Status: 當前電池處於什么狀態,有Charging, Discharging, None等值,分別代表電池充電,放電,及沒有充放電操作的狀態
- Learn Cycle Requested: Learn Cycle請求,當為Yes時,並且下面的Learn Cycle Active為No, 說明已經開始了Learn Cycle的第一階段, 此時策略開始變為WriteThrough, 電池將經歷一個放電后充電或者充電的過程
- Learn Cycle Active: 是否處於Learn Cycle的校准階段,如果為Yes, 則進入了Learn Cycle的第二階段,控制器開始校准電池.
- Battery Replacement required: 電池是否需要維修,如果為Yes, 請盡快更換電池
- Remaining Capacity Low: 剩余電容量低, 如果為Yes, 需要更換電池
參考文檔:https://www.cnblogs.com/ylqmf/archive/2013/02/28/2936895.html
————————————————
版權聲明:本文為CSDN博主「owlcity123」的原創文章,遵循CC 4.0 BY-SA版權協議,轉載請附上原文出處鏈接及本聲明。
原文鏈接:https://blog.csdn.net/owlcity123/article/details/105856072