Saturday, March 29, 2008

RAID

1. What is RAID


* The basic idea behind RAID is to combine multiple small, inexpensive
disk drives into an array to accomplish performance or redundancy goals not
attainable with one large and expensive drive.

* This array of drives will appear to the computer as a single logical storage
unit or drive.

* RAID is a method in which information is spread across several disks, using
techniques such as :

* Disk Striping (RAID Level 0) [no redundancy,no FT]
* Disk Mirroring (RAID level 1) [redundancy,with FT]
* disk striping with parity on single disk (RAID Level 4) Not Supported
* disk striping with parity across disks (RAID Level 5)
* Linear RAID

to achieve redundancy, lower latency and/or increase bandwidth for reading or
writing to disks, and maximize the ability to recover from hard disk crashes.

* The underlying concept of RAID is that data may be distributed across each
drive in the array in a consistent manner.

* To do this, the data must first be broken into consistently-sized chunks
or strips (often 32K or 64K in size, although different sizes can be used).

* Each chunk is then written to a hard drive in RAID according to the RAID level
used.

* When the data is to be read, the process is reversed, giving the illusion
that multiple drives are actually one large drive.

2. Who Should Use RAID


* Anyone who needs to keep large quantities of data on hand
(such as a sysadmin) would benefit by using RAID technology.

* The Primary reasons to use RAID include:

* Enhanced speed

* Increased storage capacity using a single virtual disk

* Lessened impact of a disk failure


3. Hardware RAID versus Software RAID


* There are two possible RAID approaches: Hardware RAID and Software RAID.

Hardware RAID

* H/W systems manages the RAID subsystem independently from
the host and presents to the host only a single disk per RAID array.

* An example of a Hardware RAID device would be one that connects to a SCSI
controller and presents the RAID arrays as a single SCSI drive.

* An external RAID system moves all RAID handling "intelligence" into a
controller located in the external disk subsystem.

* The whole subsystem is connected to the host via a normal SCSI controller and
appears to the host as a single disk.

* RAID controllers also come in the form of cards that act like a SCSI
controller to the operating system but handle all of the actual drive
communications themselves.

* In these cases, you plug the drives into the RAID controller just like you
would a SCSI controller, but then you add them to the RAID controller's
configuration, and the operating system never knows the difference.

* Many controllers have their own BIOS and can be configured independantly
of the host computer to which they are attached, just like you use the CMOS
to configure your system.

Software RAID


* Software RAID implements the various RAID levels in the kernel disk
(block device) code. It offers the cheapest possible solution, as expensive
disk controller cards or hot-swap chassis are not required.

* Software RAID also works with cheaper IDE disks as well as SCSI disks.
With today's fast CPUs, Software RAID performance can excel against Hardware
RAID.

* The MD driver in the Linux kernel is an example of a RAID solution that is
completely hardware independent. The performance of a software-based array is
dependent on the server CPU performance and load.

Software RAID has to offer some important features:

* Threaded rebuild process
* Kernel-based configuration
* Portability of arrays between Linux machines without reconstruction
* Backgrounded array reconstruction using idle system resources
* Hot-swappable drive support
* Automatic CPU detection to take advantage of certain CPU
optimizations

Note: A hot-swap chassis allows you to remove a hard drive without having to
power-down your system.


4. RAID Level 0 [Striping]


* RAID-0 is also called Striping. In this level two or more Hard Disks are
combined to appear as one large one to the OS

Example :
=======
I have two HDD of 8GB and 20GB. In RAID-0, both are combined and you get a
combined disk space of 28GB. There is no Data Redudancy and Fault Tolerance.
If one of the HDD fails, you lose all your data.

ADVANTAGES
==========

* One advantage of this is speed since a file is spread [strips] across the
two disks and can be read twice as fast

* Can accomodate very large files

* Can accomodate disks of unequal sizes. When RAID runs out of space on the
smaller [8GB] disk, it then continues the striping using the available space
on the remaining drives. When this occurs, the data access speed is lower for
this portion of data, because the total number of RAID drives available is
reduced. For this reason, RAID 0 is best used with drives of equal size.

DISADVANTAGES
=============

* There is no Data Redundancy and Fault Tolerance.
If one of the HDD fails, you lose all your data.

* You could, however, use one HDD too, if you are stupid enough to do that


+---------+ +---------+
| Block 1 | | Block 1 |
+---------+ +---------+
+---------+ Physical +---------+
| Block 2 | Disk 1 | Block 3 |
+---------+ +---------+
+---------+ +---------+
| Block 3 | RAID-0 | Block 5 |
+---------+ +---------+
==========>
+---------+ +---------+
| Block 4 | | Block 2 |
+---------+ Physical +---------+
Disk 2
+---------+ +---------+
| Block 5 | | Block 4 |
+---------+ +---------+

+---------+ +---------+
| Block 6 | | Block 6 |
+---------+ +---------+



5. RAID Level 1 [Mirroring]



* RAID 1, or "mirroring," has been used longer than any other form of RAID.

* Level 1 provides redundancy by writing identical data to each member disk of
the array, leaving a "mirrored" copy on each disk.

* Here you use two hard disks such that both of them contain exactly the same
information.

* In case of failure of one disk, the server will boot through the second disk.
When the failed disk is replaced, the data is automatically cloned to the new
disk from the surviving disk.

* Level 1 operates with two or more disks that may use parallel access for high
data-transfer rates when reading but more commonly operate independently to
provide high I/O transaction rates.

* RAID 1 also offers the possibility of using a hot standby spare disk that will
be automatically cloned in the event of a disk failure on any of the primary
RAID devices.

* Mirroring remains popular due to its simplicity and high level of data
availability.

ADVANTAGES
==========

* Offers redundancy and more Fault Tolerance.

* Provides very good data reliability and improves performance for
read-intensive applications

DISADVANTAGES
=============

* Total RAID size in GB is equal to that of the smallest disk in the RAID set.
Unlike RAID 0, the extra space on the larger device isn't used.

* RAID 1 offers data redundancy, without the speed advantages of RAID 0.
The server has to send data twice to be written to each of the mirrored disks.
This can saturate data busses and CPU use.

With a hardware-based solution, the server CPU sends the data to the RAID
disk controller once, and the disk controller then duplicates the data to
the mirrored disks.

This makes RAID-capable disk controllers the preferred solution when
implementing RAID 1.

* The storage capacity of the level 1 array is equal to the capacity of one
of the mirrored hard disks in a Hardware RAID or one of the mirrored
partitions in a Software RAID.

+---------+ +---------+ +---------+
| Block 1 | | Block 1 | | Block 1 |
+---------+ RAID-1 +---------+ +---------+
| Block 2 | | Block 2 | | Block 2 |
+---------+ +---------+ +---------+
| Block 3 | | Block 3 | | Block 3 |
+---------+ ========> +---------+ ========> +---------+
| Block 4 | | Block 4 | | Block 4 |
+---------+ +---------+ +---------+
| Block 5 | | Block 5 | | Block 5 |
+---------+ +---------+ +---------+
| Block 6 | | Block 6 | | Block 6 |
+---------+ +---------+ +---------+

Physical Disk 1 Physical Disk 2



6. RAID Level 4 = 0 + 1 w/o parity


* Linux RAID 4 requires a minimum of three disks or partitions and can
survive the loss of one disk only

* RAID 4 combines the high speed provided of RAID 0 with the redundancy of
RAID 1.

* Level 4 uses parity concentrated on a single disk drive to protect data.
RAID 4 operates likes RAID 0 but inserts a special error-correcting or parity
chunk on an additional disk dedicated to this purpose.

* Its major disadvantage is that the data is striped, but the parity info 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.
Because the dedicated parity disk represents an inherent bottleneck,
level 4 is seldom used without accompanying technologies such as
write-back caching.

* 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 re-populated with the lost data with the
help of the parity disk's information.

* It is better suited to transaction I/O rather than large file transfers.

* Although RAID level 4 is an option in some RAID partitioning schemes, it is
not an option allowed in Red Hat Linux RAID installations.

* The storage capacity of Hardware RAID level 4 is equal to the capacity of
member disks, minus the capacity of one member disk.

* The storage capacity of Software RAID level 4 is equal to the capacity of
the member partitions, minus the size of one of the partitions if they
are of equal size.

* RAID 4 is not supported by Fedora Linux.


7. RAID 5 = 4 with parity


* Linux RAID 5 requires a minimum of three disks or partitions and can
survive the loss of one disk only

* This is the most common type of RAID. By distributing parity across some
or all of an array's member disk drives, RAID level 5 eliminates the
write bottleneck inherent in level 4.

* The only performance bottleneck is the parity calculation process. With
modern CPUs and Software RAID, that usually is not a very big problem.

* As with level 4, the result is asymmetrical performance, with reads
substantially outperforming writes.

* Level 5 is often used with write-back caching to reduce the asymmetry.

* The storage capacity of Hardware RAID level 5 is equal to the capacity of
member disks, minus the capacity of one member disk.

* The storage capacity of Software RAID level 5 is equal to the capacity
of the member partitions, minus the size of one of the partitions if they
are of equal size.

* 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, whilst
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 below illustrates the data
allocation process in RAID 5.


+---------+
| Block 1 |
+---------+
+---------+ +----------+ +---------+ +-----------------+
| Block 2 | | Block 1 | | Block 2 | |ErrChk Blocks 1+2|
+---------+ +---------+ +---------+ +-----------------+
+---------+ +----------+-----------+ +---------+ +---------+
| Block 3 | RAID-5 | ErrChk Blocks 3+4 | | Block 1 | | Block 3 |
+---------+ +-Block 3+4----------+ +---------+ +---------+
+---------+ +---------+ +-------------------+ +---------+
| Block 4 | | Block 6 | | ErrChk Blocks 6+5 | | Block 5 |
+---------+ +---------+ +-------------------+ +---------+
+---------+ +---------+ +---------+ +------------------+
| Block 5 | | Block 7 | | Block 8 | |ErrChk Blocks 7+8 |
+---------+ +---------+ +---------+ +------------------+
+---------+
| Block 6 |
+---------+

Linear RAID

Linear RAID is a simple grouping of drives to create a larger virtual drive.
In linear RAID, the chunks are allocated sequentially from one member drive,
going to the next drive only when the first is completely filled.

This grouping provides no performance benefit, as it is unlikely
that any I/O operations will be split between member drives. Linear RAID also
offers no redundancy and, in fact, decreases reliability if any one member
drive fails, the entire array cannot be used. The capacity is the total of all
member disks.

Note : RAID level 1 comes at a high cost because you write the same info to
all of the disks in the array, which wastes drive space.
For example, if you have RAID level 1 set up so that your
root (/) partition exists on two 40G drives, you have 80G total but
are only able to access 40G of that 80G. The other 40G acts like a
mirror of the first 40G.

Note : Parity information is calculated based on the contents of the rest of
the member disks in the array. This information can then be used to
reconstruct data when one disk in the array fails. The reconstructed
data can then be used to satisfy I/O requests to the failed disk before
it is replaced and to repopulate the failed disk after it has been
replaced.

Note : RAID level 4 takes up the same amount of space as RAID level 5, but
level 5 has more advantages. For this reason, level 4 is not supported.

No comments: