个人工具

Quick HOWTO : Ch26 : Linux Software RAID/zh

来自Ubuntu中文

Lipeng8413讨论 | 贡献2008年6月3日 (二) 18:47的版本 RAID 1

跳转至: 导航, 搜索


简介

使用独立磁盘冗余阵列(RAID)的主要目的是提高磁盘数据处理能力和提供数据冗余。

RAID既能通过操作系统来设置(软件式RAID),也可以在不设置操作系统的情况下通过硬件RAID控制器来实现(硬件式RAID)。这章将向您解释如何在Redhat/Fedora linux下配置软件式RAID结构。

为简洁起见,本章的重点是:在没有/boot或/文件系统的分区上进行RAID设置。

RAID 类型

不管是硬件式或软件式,冗余磁盘阵列RAID能用很多不同的标准来配置,下面我们看看最流行的几种配置方式

线性RAID

在线性RAID中,RAID控制器将RAID集(set)视为一个磁盘链。当前一个磁盘空间被填满后,数据顺序写入磁盘链中的下一个磁盘。 线性RAID的目的是容纳跨磁盘的超大文件系统,而且没有数据冗余性。驱动器故障将损坏您的数据。

Fedora Linux不支持此方式的RAID。

RAID 0

在RAID 0下,RAID控制器试图将数据平均的写入RAID集(set)中的所有磁盘。

将磁盘视为盘子,将数据视为蛋糕。假设你有四个蛋糕-巧克力味、香草味、樱桃味、草莓味-和四个盘子。RAID 0初始操作是将蛋糕切成片,然后将这些片放到每个盘子里。RAID 0 驱动器让操作系统觉得蛋糕是完整的,而且是放到了一个大盘子里。例如,4个9GB的硬盘,配置成RAID 0集的话,操作系统将它们视为一个36GB的硬盘

和线性RAID相似,RAID 0也是为了容纳跨磁盘的超大容量文件系统,并没有数据冗余性。RAID 0的优点是数据访问速度。一个文件分放在四个磁盘上能以四倍于一个磁盘的读取速度读取出来。记住RAID 0常被称为条带集

RAID 0允许磁盘的空间大小不同。当RAID使用完最小磁盘上的条带空间时,它继续使用剩余磁盘的可用空间作为条带集。当这种情况发生时,这部分数据的访问速度将变慢,因为RAID驱动器的数量减少了。所以,RAID 0 最好使用同容量的磁盘。

Fedora Linux支持RAID 0 ,图26.1说明了RAID 0的数据分配过程

RAID 1

在RAID 1方式下,数据被复制放到另一磁盘上。这种RAID方式因此经常被称之为磁盘镜像。想像一下,您将一个同样的故事说给两个人挺,这样的话,如果其中一个人忘记了故事的情节,您可以让另一个来告诉您。

当RAID 1集中的一个磁盘坏了的话,剩下的那个磁盘仍然能够工作。当坏的磁盘被更换后,数据能够自动的从剩下的那个好的磁盘上复制到新磁盘上。在任一主RAID磁盘发生故障时,RAID 1还可以将数据自动的复制到一个热备的空磁盘上。

RAID 1提供了数据冗余性,但没有RAID 0的速度优点。软件式的RAID 1的一个缺点是服务器不得不将数据写入两次以便写入每个镜像磁盘。这回占用数据总线和cpu资源。在硬件式RAID 1下,服务器cpu只需将数据传给RAID磁盘控制器一次,剩下的工作就由磁盘控制器来完成了。这使得在实现RAID 1时,优先选用能提供RAID的磁盘控制器

RAID 1 的一个限制是总的RAID集大小等于磁盘集中容量最小的那块磁盘。这跟RAID 0不同,较大磁盘中剩余部分的磁盘空间会浪费掉。

Fedora Linux支持RAID 1。 图26.1说明了RAID 1方式下的数据分发过程

图26.1 RAID 0和RAID 1 的工作方式

Raid0.gif

RAID 4

RAID 4 operates likes RAID 0 but inserts a special error-correcting or parity chunk on an additional disk dedicated to this purpose.

RAID 4 requires at least three disks in the RAID set and can survive the loss of a single drive only. When this occurs, the data in it can be recreated on the fly with the aid of the information on the RAID set's parity disk. When the failed disk is replaced, it is repopulated with the lost data with the help of the parity disk's information.

RAID 4 combines the high speed provided of RAID 0 with the redundancy of RAID 1. Its major disadvantage is that the data is striped, but the parity information is not. In other words, any data written to any section of the data portion of the RAID set must be followed by an update of the parity disk. The parity disk can therefore act as a bottleneck. For this reason, RAID 4 isn't used very frequently.

RAID 4 is not supported by Fedora Linux.

RAID 5

RAID 5 improves on RAID 4 by striping the parity data between all the disks in the RAID set. This avoids the parity disk bottleneck, while maintaining many of the speed features of RAID 0 and the redundancy of RAID 1. Like RAID 4, RAID 5 can survive the loss of a single disk only.

RAID 5 is supported by Fedora Linux. Figure 26.2 illustrates the data allocation process in RAID 5.

Linux RAID 5 requires a minimum of three disks or partitions.

图26.2 RAID 5的工作方式

Raid5.gif