分类目录归档:存储

硬盘512e、4kn的解读

传统的硬盘是以512字节大小的扇区为单位分割进行读写, 512字节的空间不全用来存数据,还存放这一些功能性代码,如ECC校验、Gap、Sync/Address Mark的代码,所以真正的存储空间大概不到90% ,整个磁盘空间的利用率大概在88%左右。

为了提升硬盘可用容量,硬盘厂商把每一个磁盘单位(sector format)扇区格式改为4K(512 Bytes x 8),这种格式又叫做(Advanced Format)高级格式,8个(sector format)共用一个 同步/分隔区域和一个容量稍大的 ECC 校验区 (即功能性代码部分,这部分约占用一百多字节),真正的存储空间使用率能达到97%。

但是现有操作系统对4K这种高级格式支持度还不够,为了过渡,硬盘厂商为4K扇区格式的硬盘准备了512e(emulation)的硬盘固件, 利用固件来把传统的对于512字节扇区的逻辑访问转换为对于4K字节扇区的物理访问。

新硬盘还有另一种固件直接支持 4K字节扇区的访问,这种硬盘称之为4Kn(Native)。传统格式的硬盘被称之为512n(Native),原生就是512字节的扇区。

当我们将大于4K的数据块写入512e硬盘时,由于一次写入的扇区大小就是4K,所以写操作的性能会有较大提升。但是如果写入512e硬盘的数据块小于4K时,操作系统就必需经过读取再修改再写入的过程,这会造成比较明显的性能下降。一些传统应用(如数据库系统)的I/O操作最小单位仍小于 4KB,使用原生 512 byte 扇区硬盘可以保证最好的性能,采用 512e 硬盘容易产生性能影响。

megacli查看硬盘状态

通过megacli的如下命令查看RAID的情况,命令如下:

/opt/MegaRAID/MegaCli/MegaCli64 LDPDInfo -Aall

重点关注以下几点:

Media Error Count
Other Error Count
Predictive Failure Count
Last Predictive Failure
Drive has flagged a S.M.A.R.T alert

如果这几个数值不为0,则可能为硬盘故障,需要更换硬盘。

可以通过让指定硬盘闪烁的方式来定位磁盘位置,命令如下:

MegaCli -PdLocate -start -physdrv [E:S] -aALL

其中 E表示 Enclosure Device ID,S表示Slot Number。比如坏盘的位置为:
Enclosure Device ID: 1
Slot Number: 0

可执行以下命令让其闪烁:
root@Storage-c2:/opt/MegaRAID/MegaCli# ./MegaCli64 -PdLocate -start -physdrv[1:0] -a0
Adapter: 0: Device at EnclId-1 SlotId-0 — PD Locate Start Command was successfully sent to Firmware Exit Code: 0x00
root@Storage-c2:/opt/MegaRAID/MegaCli#

更换硬盘后,关闭闪烁的命令如下:
MegaCli -PdLocate -stop -physdrv [E:S] -aALL

如果raid中有硬盘故障,更换硬盘后,一般都无需做操作,阵列卡会自动做rebuild,从拔出硬盘到插入新盘,一般会有以下的过程:

  • Device
    Normal —>Damage —>Rebuild —>Normal
  • Virtual Drive
    Optimal —>Degraded —>Degraded —>Optimal
  • Physical Drive
    Online —>Failed Unconfigured —>Rebuild —>Online

查看rebuild进度的命令如下:

/opt/MegaRAID/MegaCli/MegaCli64 -PDRbld -showprog -physDrv [1:0] -a0

输出一般如下:

root@Storage-c2:/opt/MegaRAID/MegaCli# ./MegaCli64 -PDRbld -showprog -physDrv [1:0] -a0
Rebuild Progress on Device at Enclosure 1, Slot 0 Completed 10% in 0 Minutes.
Exit Code: 0x00
root@Storage-c2:/opt/MegaRAID/MegaCli#

SAS、NL-SAS、SATA硬盘的比较

When you buy a server or storage array these days, you often have the choice between three different kinds of hard drives: Serial Attached SCSI (SAS), Near Line SAS (NL-SAS) and Serial ATA (SATA). Yes, there are other kinds of drives, such as Fibre Channel, but I’m focusing this article on the SAS/SATA question. Further, even though solid-state disks (SSD) can have a SAS or SATA interface, I’m not focused here on SSDs. I’m focusing solely on the devices that spin really, really fast and on which most of the world’s data resides.

So, what is the real difference between SAS, NL-SAS and SATA disks? Well, to be cryptic, there are a lot of differences, but I think you’ll find some surprising similarities, too. With that, let’s dig in!

SAS
SAS disks have replaced older SCSI disks to become the standard in enterprise-grade storage. Of the three kinds of disks, they are the most reliable, maintain their performance under more difficult conditions, and perform much better than either NL-SAS or SATA disks.

In reliability, SAS disks are an order of magnitude safer than either NL-SAS or SATA disks. This metric is measured in bit error rate (BER), or how often bit errors may occur on the media. With SAS disks, the BER is generally 1 in 10^16 bits. Read differently, that means you may see one bit error out of every 10,000,000,000,000,000 (10 quadrillion) bits. By comparison, SATA disks have a BER of 1 in 10^15 (1,000,000,000,000,000 or 1 quadrillion). Although this does make it seem that SATA disks are pretty reliable, when it comes to absolute data protection, that factor of 10 can be a big deal.

SAS disks are also built to more exacting standards than other types of disks. SAS disks have a mean time between failure of 1.6 million hours compared to 1.2 million hours for SATA. Now, these are also big numbers – 1.2 million hours is about 136 years and 1.6 million hours is about 182 years. However, bear in mind that this is a mean. There will be outliers and that’s where SAS’s increased reliability makes it much more palatable.

SAS disks/controller pairs also have a multitude of additional commands that control the disks and that make SAS a more efficient choice than SATA. I’m not going to go into great detail about these commands, but will do so in a future article.

NL-SAS
NL-SAS is a relative newcomer to the storage game, but if you understand SATA and SAS, you already know everything you need to know about NL-SAS. You see, NL-SAS is basically a merging of a SATA disk with a SAS connector. From Wikipedia: “NL-SAS drives are enterprise SATA drives with a SAS interface, head, media, and rotational speed of traditional enterprise-class SATA drives with the fully capable SAS interface typical for classic SAS drives.”

There are two items of import in that sentence: “enterprise SATA drives” and “fully capable SAS interface”. In short, an NL-SAS disk is a bunch of spinning SATA platters with the native command set of SAS. While these disks will never perform as well as SAS thanks to their lower rotational rate, they do provide all of the enterprise features that come with SAS, including enterprise command queuing, concurrent data channels, and multiple host support.

Enterprise/tagged command queuing. Simultaneously coordinates multiple sets of storage instructions by reordering them at the storage controller level so that they’re delivered to the disk in an efficient way.
Concurrent data channels. SAS includes multiple full-duplex data channels, which provides for faster throughout of data.
Multiple host support. A single SAS disk can be controlled by multiple hosts without need of an expander.
However, on the reliability spectrum, don’t be fooled by the acronym “SAS” appearing in the product name. NL-SAS disks have the same reliability metrics as SATA disks – BER of 1 in 10^15 and MTBF of 1.2 million hours. So, if you’re thinking of buying NL-SAS disks because SAS disks have better reliability than SATA disks, rethink. If reliability is job #1, then NL-SAS is not your answer.

On the performance scale, NL-SAS won’t be much better than SATA, either. Given their SATA underpinning, NL-SAS disks rotate at speeds of 7200 RPM… the same as most SATA disks, although there are some SATA drives that operate at 10K RPM.

It seems like there’s not much benefit to the NL-SAS story. However, bear in mind that this is a SATA disk with a SAS interface and, with that interface comes a number of benefits, some of which I briefly mentioned earlier. These features allow manufacturers to significantly simplify their products.

SATA
Lowest on the spectrum is the SATA disk. Although it doesn’t perform as well as SAS and doesn’t have some of the enterprise benefits of NL-SAS, SATA disks remain a vital component in any organization’s storage system, particularly for common low-tier, mass storage needs.

When you’re buying SATA storage, your primary metric is more than likely to be cost per TB and that’s as it should be. SAS disks are designed for performance, which is why they’re available in 10K and 15K RPM speeds and provide significant IOPS per physical disk. With SAS, although space is important, the cost per IOPS is generally just as, if not more, important. This is why many organizations are willing to buy speedier SAS disks even though it means buying many more disks (than SATA or NL-SAS) to hit capacity needs.

Summary
At a high level, SAS and SATA are two sides of the storage coin and serve different needs — SAS for performance and SATA for capacity. Straddling the two is NL-SAS, which brings some SAS capability to SATA disks, but doesn’t bring the additional reliability found with SAS. NL-SAS helps manufacturers streamline production, and can help end users from a controller perspective, but they are not a replacement for SAS.

以上为英文版内容,大致总结如下:
SAS的优势在于性能,SATA的优势在于容量,NL-SAS介于两者之间。

HP MSA2040存储修改端口模式的方法

HP MSA2040存储可以使用iscsi接口,也可以使用fc接口,也可以二者混用。该存储A控制器IP地址为10.0.0.2,B控制器IP地址为10.0.0.3,默认用户名为manage,默认密码为!manage。可以通过web方式来配置存储,该存储接口模式都是fc模式,如果需要使用iscsi接口,则需要通过命令行的方式修改端口模式。

将本机IP地址设置为10.0.0.X网段,使用网线连接本机网卡和控制器管理口,使用putty等软件通过telnet方式登录控制器。

使用show host-parameters查看端口模式,使用set host-port-mode iSCSI命令将fc模式改为iscsi模式,修改后控制器需要重启,并且将会同步到另一个控制器上,同步过程中可能会导致控制器无法正常进入web界面管理,等同步完成即可正常配置使用存储。

Dell服务器linux操作系统下RAID常用管理命令总结

Dell服务器常用管理命令总结
准备
新版本的 MegaCli-1.01.24-0.i386.rpm 会把程序安装在/opt下,可以自定义安装目录,例如:
rpm –relocate /opt/=/usr/sbin/ -i MegaCli-1.01.24-0.i386.rpm
即把安装目录 /opt 替换成 /usr/sbin。

下载地址:http://www.lsi.com/downloads/Public/MegaRAID%20Common%20Files/8.02.16_MegaCLI.zip ;
(linux文件夹下有个MegaCli文件里面有I386 RPM)
查看机器型号    # dmidecode | grep “Product”
查看厂商    # dmidecode| grep  “Manufacturer”
查看序列号    # dmidecode | grep  “Serial Number”
查看CPU信息    # dmidecode | grep  “CPU”
查看CPU个数    # dmidecode | grep  “Socket Designation: CPU” |wc –l
查看出厂日期    # dmidecode | grep “Date”
查看充电状态    # MegaCli -AdpBbuCmd -GetBbuStatus -aALL |grep “Charger Status”
显示BBU状态信息    # MegaCli -AdpBbuCmd -GetBbuStatus –aALL
显示BBU容量信息    # MegaCli -AdpBbuCmd -GetBbuCapacityInfo –aALL
显示BBU设计参数    # MegaCli -AdpBbuCmd -GetBbuDesignInfo –aALL
显示当前BBU属性    # MegaCli -AdpBbuCmd -GetBbuProperties –aALL
查看充电进度百分比    # MegaCli -AdpBbuCmd -GetBbuStatus -aALL |grep “Relative State of Charge”
查询Raid阵列数    # MegaCli -cfgdsply -aALL |grep “Number of DISK GROUPS:”
显示Raid卡型号,Raid设置,Disk相关信息      # MegaCli -cfgdsply –aALL
显示所有物理信息    # MegaCli -PDList -aALL
显示所有逻辑磁盘组信息    # MegaCli -LDInfo -LALL –aAll
查看物理磁盘重建进度(重要)    # MegaCli -PDRbld -ShowProg -PhysDrv [1:5] -a0
查看适配器个数    #MegaCli –adpCount
查看适配器时间    #MegaCli -AdpGetTime –aALL
显示所有适配器信息    #MegaCli -AdpAllInfo –aAll
查看Cache 策略设置    # MegaCli -cfgdsply -aALL |grep Polic
1、查看所有物理磁盘信息
MegaCli -PDList -aALL

Adapter #0

Enclosure Number: 1
Slot Number: 5
Device Id: 5
Sequence Number: 2
Media Error Count: 0
Other Error Count: 0
Predictive Failure Count: 0
Last Predictive Failure Event Seq Number: 0
Raw Size: 140014MB [0x11177328 Sectors]
Non Coerced Size: 139502MB [0x11077328 Sectors]
Coerced Size: 139392MB [0x11040000 Sectors]
Firmware state: Hotspare
SAS Address(0): 0x5000c50008e5cca9
SAS Address(1): 0x0
Inquiry Data: SEAGATE ST3146855SS     S5273LN4Y1X0
…..

2、查看磁盘缓存策略
MegaCli -LDGetProp -Cache -L0 -a0

Adapter 0-VD 0: Cache Policy:WriteBack, ReadAheadNone, Direct

or
MegaCli -LDGetProp -Cache -L1 -a0

Adapter 0-VD 1: Cache Policy:WriteBack, ReadAheadNone, Direct

or
MegaCli -LDGetProp -Cache -LALL -a0

Adapter 0-VD 0: Cache Policy:WriteBack, ReadAheadNone, Direct
Adapter 0-VD 1: Cache Policy:WriteBack, ReadAheadNone, Direct

or
MegaCli -LDGetProp -Cache -LALL -aALL

Adapter 0-VD 0: Cache Policy:WriteBack, ReadAheadNone, Direct
Adapter 0-VD 1: Cache Policy:WriteBack, ReadAheadNone, Direct

or
MegaCli -LDGetProp -DskCache -LALL -aALL

Adapter 0-VD 0: Disk Write Cache : Disk’s Default
Adapter 0-VD 1: Disk Write Cache : Disk’s Default

3、设置磁盘缓存策略
缓存策略解释:
WT    (Write through
WB    (Write back)
NORA  (No read ahead)
RA    (Read ahead)
ADRA  (Adaptive read ahead)
Cached
Direct

例子:
MegaCli -LDSetProp WT|WB|NORA|RA|ADRA -L0 -a0

or
MegaCli -LDSetProp -Cached|-Direct -L0 -a0

or
enable / disable disk cache
MegaCli -LDSetProp -EnDskCache|-DisDskCache -L0 -a0

4、创建/删除 阵列
4.1 创建一个 raid5 阵列,由物理盘 2,3,4 构成,该阵列的热备盘是物理盘 5
MegaCli -CfgLdAdd -r5 [1:2,1:3,1:4] WB Direct -Hsp[1:5] -a0

4.2 创建阵列,不指定热备
MegaCli -CfgLdAdd -r5 [1:2,1:3,1:4] WB Direct -a0

4.3 删除阵列
MegaCli -CfgLdDel -L1 -a0

4.4 在线添加磁盘
MegaCli -LDRecon -Start -r5 -Add -PhysDrv[1:4] -L1 -a0
意思是,重建逻辑磁盘组1,raid级别是5,添加物理磁盘号:1:4。重建完后,新添加的物理磁盘会自动处于重建(同步)状态,这个 时候 fdisk -l是看不到阵列的空间变大的,只有在系统重启后才能看见。
5、查看阵列初始化信息
5.1 阵列创建完后,会有一个初始化同步块的过程,可以看看其进度。
MegaCli -LDInit -ShowProg -LALL -aALL

或者以动态可视化文字界面显示
MegaCli -LDInit -ProgDsply -LALL -aALL

5.2 查看阵列后台初始化进度
MegaCli -LDBI -ShowProg -LALL -aALL

或者以动态可视化文字界面显示
MegaCli -LDBI -ProgDsply -LALL -aALL

6、创建全局热备
指定第 5 块盘作为全局热备
MegaCli -PDHSP -Set [-EnclAffinity] [-nonRevertible] -PhysDrv[1:5] -a0

也可以指定为某个阵列的专用热备
MegaCli -PDHSP -Set [-Dedicated [-Array1]] [-EnclAffinity] [-nonRevertible] -PhysDrv[1:5] -a0

7、删除全局热备
MegaCli -PDHSP -Rmv -PhysDrv[1:5] -a0

8、将某块物理盘下线/上线
MegaCli -PDOffline -PhysDrv [1:4] -a0

MegaCli -PDOnline -PhysDrv [1:4] -a0

9、查看物理磁盘重建进度
MegaCli -PDRbld -ShowProg -PhysDrv [1:5] -a0

一台DELL服务器开机显示BLANCCO信息的解决方法

现有一台DELL服务器,更换了硬盘并重新配置了阵列后,准备对该设备安装操作系统,但是每次重启自检后都进入Blancco画面,显示各种hardware information信息,再次更换硬盘更换安装盘后,问题仍然存在,后来在阵列卡BIOS中,对新建的虚拟磁盘进行快速初始化操作后,问题解决。

看来配置阵列时,对新建的虚拟磁盘进行快速虚拟化是很有用的,有时候在操作系统中不能对新建的虚拟磁盘进行正常分区格式化操作,也可以通过对虚拟磁盘快速初始化来解决。

但是对已经有数据的虚拟磁盘则不能进行快速初始化操作,因为这样会清除虚拟磁盘上的数据。

DELL阵列卡采用的芯片组的名称及芯片组驱动程序下载地址

目前DELL常见的阵列卡有H310和H710,这些阵列卡都采用LSI公司的芯片组,以下是DELL阵列卡与LSI芯片组的对应关系:

DELL阵列卡名称 LSI芯片组 LSI公司使用相同芯片的RAID卡或HBA卡
H710/H810 LSI2208 MegaRAID SAS 9265-8i
H700/H800 LSI2108 MegaRAID SAS 9260-8i
PERC6i/E LSI1078 MegaRAID SAS 8888ELP
PERC5i/E LSI1068 MegaRAID SAS 8408E/8480E
H310 LSI2008 MegaRAID SAS 9240
H200/SAS6G LSI2008 LSISAS2008
SAS6ir/E LSI1068 LSISAS1068E
SAS5i/r/E LSI1068 LSISAS1068

驱动程序下载页面:驱动页面:
http://www.lsi.com/products/storagecomponents/Pages/MegaRAIDSAS9265-8i.aspx

Dell PERC H310、H710、H710P 和 H810 卡硬件配置

规格 H310 H710 H710P H810
RAID级别 0、1、5、10、50 0、1、5、6、10、50、60 0、1、5、6、10、50、60 0、1、5、6、10、50、60
每个端口的机柜数量 不适用 不适用 不适用 最多四个机柜
处理器 带有LSI2008芯片组的8端口Dell适配器SAS片上RAID 带有LSI2008芯片组的8端口Dell适配器SAS片上RAID 带有LSI2008芯片组的8端口Dell适配器SAS片上RAID 带有LSI2008芯片组的8端口Dell适配器SAS片上RAID
备用电池单元(BBU)
非易失性高速缓存 不适用
高速缓存存储器 不适用 512MB DDR3 800 Mhz 1GB DDR3 133 Mhz 1GB DDR3 133 Mhz
高速缓存功能 不适用 回写、直写、自适应预读、不预读、预读 回写、直写、自适应预读、不预读、预读 回写、直写、自适应预读、不预读、预读
每磁盘组的最大跨区数量 8 8 8 8
每磁盘组的最大虚拟磁盘数量 16 16 16 16
联机容量扩展
专用热备份和全局热备份
支持热插拔设备
硬件异或引擎
冗余路径支持

PERC H310、H710 和 H710P 卡支持以下操作系统:
Microsoft Windows Server 2012
提供 Hyper-V 虚拟化的 Microsoft Windows Server 2008
Microsoft Windows Server 2008 R2 及更高版本
Red Hat Enterprise Linux 5.8 版及更高版本(32 位和 64 位)
Red Hat Enterprise Linux 6.2 版及更高版本(64 位)
SUSE Linux Enterprise Server 版本 10 SP4(64 位)
SUSE Linux Enterprise Server 版本 11 SP2(64 位)
VMware ESX 4.1 和 ESXi 4.1 Update 2
VMware ESX 5.0

Dell raid控制卡(perc)6、7、8系列介绍

PowerEdge RAID Controller (PERC) Series 8 Family
Model  Interface Support PCI Support SAS Connectors  Cache Memory Size
Write Back Cache  RAID Levels  Max Drive Support  RAID Support
PERC H810 Adapter 6Gb/s SAS PCI-Express 2.0 2×4 External 1GB NV Flash Backed Cache 0,1,5,6,10,50,60 192 Hardware RAID
PERC H710P Adapter 6Gb/s SAS PCI-Express 2.0 2×4 Internal 1GB NV Flash Backed Cache 0,1,5,6,10,50,60 32 Hardware RAID
PERC H710P Mini Mono 6Gb/s SAS PCI-Express 2.0 2×4 Internal 1GB NV Flash Backed Cache 0,1,5,6,10,50,60 32 Hardware RAID
PERC H710P Mini Blade 6Gb/s SAS PCI-Express 2.0 2×4 Internal 1GB NV Flash Backed Cache 0,1,5,6,10,50,60 4 Hardware RAID
PERC H710 Adapter 6Gb/s SAS PCI-Express 2.0 2×4 Internal 512MB NV Flash Backed Cache 0,1,5,6,10,50,60 32 Hardware RAID
PERC H710 Mini Mono 6Gb/s SAS PCI-Express 2.0 2×4 Internal 512MB NV Flash Backed Cache 0,1,5,6,10,50,60 32 Hardware RAID
PERC H710 Mini Blade 6Gb/s SAS PCI-Express 2.0 1×4 Internal 512MB NV Flash Backed Cache 0,1,5,6,10,50,60 4 Hardware RAID
PERC H310 Adapter 6Gb/s SAS PCI-Express 2.0 2×4 Internal 0,1,5,10,50 16, Non-RAID 32 Hardware RAID
PERC H310 Mini Mono 6Gb/s SAS PCI-Express 2.0 2×4 Internal 0,1,5,10,50 16, Non-RAID 32 Hardware RAID
PERC H310 Mini Blade 6Gb/s SAS PCI-Express 2.0 1×4 Internal 0,1,5,10,50 4 Hardware RAID
S110 Software RAID 3Gb/s SATA PCI-Express 2.0 0,1,5,10 4 Software RAID – Windows Only
PERC H310 Mini Blade 3Gb/s SAS Express 2.0 1×4 Internal 0,1,5,10,50 4 Hardware RAID
PowerEdge RAID Controller (PERC) Series 6 & 7 Family
 Model Interface Support PCI Support SAS Connectors Cache Memory Size Write Back Cache RAID Levels Max Drive Support RAID Support
PERC H800 Adapter 6Gb/s SAS PCI-Express 2.0 2×4 External 2MB, 512MB NV, 1GB NV Yes (TBBU) 0,1,5,6,10,50,60 192 Hardware RAID
PERC H700 Integrated / Adapter 6Gb/s SAS PCI-Express 2.0 2×4 Internal 512MB, 512MB NV, 1GB NV Yes (BBU) 0,1,5,6,10,50,60 16 Hardware RAID
PERC H700 Modular 6Gb/s SAS PCI-Express 2.0 1×4 Internal 512MB Yes (BBU) 0,1,5,6,10 4 Hardware RAID
PERC H200 Integrated / Adapter 6Gb/s SAS PCI-Express 2.0 2×4 Internal 0,1,10 Supports non-RAID 16 Hardware RAID
PERC H200 Modular 6Gb/s SAS PCI-Express 2.0 1×4 Internal 0,1,10 Supports non-RAID 4 Hardware RAID
6Gbps SAS HBA 6Gb/s SAS PCI-Express 2.0 2×4 External HBA Hardware
PERC 6/E Adapter 3Gb/s SAS PCI-Express 1.0 2×4 External 512MB, 256 MB Yes (TBBU) 0,1,5,6,10,50,60 144 Hardware RAID
PERC 6/I Integrated / Adapter 3Gb/s SAS PCI-Express 1.0 2×4 Internal 256MB Yes (BBU) 0,1,5,6,10,50,60 16 Hardware RAID
PERC 6/I Modular 3Gb/s SAS PCI-Express 1.0 1×4 Internal 256MB Yes (BBU) 0,1,5,6,10 4 Hardware RAID
CERC 6/I Modular 3Gb/s SAS PCI-Express 1.0 1×4 Internal 128MB 0,1,5,6,10 4 Hardware RAID
SAS 6/iR Integrated / Adapter 3Gb/s SAS PCI-Express 1.0 2×4 Internal 0,1 8 Hardware RAID
SAS 6/iR Modular 3Gb/s SAS PCI-Express 1.0 1×4 Internal 0,1 4 Hardware RAID
PERC S300Windows only OS 3Gb/s SAS PCI-Express 1.0 2×4 Internal 0,1,10,5 8 Software RAID on HBA
PERC S100Windows only OS 3Gb/s SATA 4 cabled SATA 0,1,10,5 4 Software RAID on SATA Chipset

RAID5初始化方法及写方式

目前使用的初始化方法
目前RAID5的初始化主要有两种方法,一种是标示为resync的全同步;另一种方法是标示为recovery的数据恢复。
所谓resync,就是进行全阵列磁盘同步,从头到尾按条带读取所有磁盘的数据,计算新的校验值并与原来的校验值相比较,如果相同则直接进入下一个条带的操作,如果不同则需要把新计算的校验数据写到校验磁盘上。
所谓recovery,就是恢复失效盘的数据。磁盘阵列中的单个磁盘是有可能失效的,这时磁盘阵列会将失效磁盘从阵列中剔除,那么对于那些有数据恢复能力的RAID阵列,如RAID-1456,我们就能够通过加入热备盘恢复失效盘上的数据,recovery就是从头到尾恢复数据的过程。recovery完成之后热备盘就会成为正式的成员盘取代原来的失效盘。Recovery原本用于失效磁盘的数据恢复,但也可以用于刚创建的RAID,在刚创建的时候,把最后一块盘设置为热备盘,该磁盘的数据通过读取其它磁盘的数据校验得出,这样下来,也会保证各个条带的数据一致性。
RAID5的两种写方式
在提出新方法之前,先讨论下RAID5 的两种写方式:读改写和重构写。读改写的实现方式是先将所需写入的数据保存到内存,同时读取所需要写入位置的旧数据及校验盘上的数据,然后将新数据、旧数据和老校验数据进行校验运算,得出新校验数据,最后将新数据与新校验值写入磁盘。
以6块盘的RAID5为例,假设要写D1数据块,而所在条带别的数据块没有写请求,则需要读取旧的D1数据,和旧的校验数据P0,再和新的数据NEW D1做异或校验计算,得到新的校验NEW P0,再把NEW D1和NEW P0写到对应的磁盘。
所谓重构式写,就是预读没有写请求的磁盘的数据,而将写请求磁盘的bio中的数据拷贝到磁盘缓冲区,然后用这些数据来重构新的校验结果。之后,就将新修改的数据和新校验结果写入下层设备即可。
仍以6块盘的RAID5为例,假设要写D1,D2,D3的数据块,则需要读D4,D5数据,再和新的数据NEW D1,NEW D2,NEW D3做异或校验计算,得到新的校验NEW P0,再把NEW D1,NEW D2,NEW D3和NEW P0写到对应的磁盘。