Linux查看MegaSAS raid卡缓存策略

查看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策略的变更.

  1. RAID卡进入BBU Learn Cycle: 详细介绍见下面
  2. 检测到某些电池故障,如电池容量过低等,一般是电池老化带来的影响,IBM建议一年更换一次RAID卡电池
  3. 没有安装电池, 部分服务器购买时不带电池,导致被自动设置为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
  1. Charging Status: 当前电池处于什么状态,有Charging, Discharging, None等值,分别代表电池充电,放电,及没有充放电操作的状态
  2. Learn Cycle Requested: Learn Cycle请求,当为Yes时,并且下面的Learn Cycle Active为No, 说明已经开始了Learn Cycle的第一阶段, 此时策略开始变为WriteThrough, 电池将经历一个放电后充电或者充电的过程
  3. Learn Cycle Active: 是否处于Learn Cycle的校准阶段,如果为Yes, 则进入了Learn Cycle的第二阶段,控制器开始校准电池.
  4. Battery Replacement required: 电池是否需要维修,如果为Yes, 请尽快更换电池
  5. 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

原文地址:https://www.cnblogs.com/xingxiz/p/15497913.html