Why RAID?

From Linux Raid Wiki
(Difference between revisions)
Jump to: navigation, search
(Swapping on RAID)
m (Device and filesystem support)
 
(7 intermediate revisions by 4 users not shown)
Line 1: Line 1:
 +
{| style="border:1px solid #aaaaaa; background-color:#f9f9f9;width:100%; font-family: Verdana, sans-serif;"
 +
|- padding:5px;padding-top:0.5em;font-size: 95%;
 +
| <span style="float:right; padding-left:5px;">Forward to [[Devices]]</span>
 +
|}
 +
 
=Why RAID?=
 
=Why RAID?=
  
There can be many good reasons for using RAID. A few are; the ability
+
There can be many good reasons for using RAID. A few are: the ability
to combine several physical disks into one larger "virtual" device,
+
to combine several physical disks into one larger ''virtual'' device,
 
performance improvements, and redundancy.
 
performance improvements, and redundancy.
  
Line 8: Line 13:
 
substitute for good backups. Some RAID levels will make your systems
 
substitute for good backups. Some RAID levels will make your systems
 
immune to data loss from one or two disk failures, but RAID will not allow
 
immune to data loss from one or two disk failures, but RAID will not allow
you to recover from an accidental "rm -rf /". RAID will also not help
+
you to recover from an accidental <code>rm -rf /</code>. RAID will also not help
 
you preserve your data if the server holding the RAID itself is lost
 
you preserve your data if the server holding the RAID itself is lost
 
in one way or the other (theft, flooding, earthquake, Martian invasion
 
in one way or the other (theft, flooding, earthquake, Martian invasion
 
etc.)
 
etc.)
  
RAID will generally allow you to keep systems up and running, in case
+
RAID is meant to allow you to keep systems up and running, in case
 
of common hardware problems (disk failure). It is not in itself
 
of common hardware problems (disk failure). It is not in itself
 
a complete data safety solution. This is very important to realize.
 
a complete data safety solution. This is very important to realize.
  
 +
With modern huge SATA drives, however, it is still very easy to lose an array to a
 +
single drive failure. The wrong choice of raid level, for example. And it is common
 +
for the reconstruction of an array after one drive has failed, to be actively responsible
 +
for the failure of a second drive. Drives don't tend to fail at random - if you buy all
 +
the drives for your raid at the same time, then they are all likely to fail at roughly the
 +
same time. And the most common cause of anguished emails to the mailing list is using
 +
unsuitable drives for the raid.
  
 
==Device and filesystem support==
 
==Device and filesystem support==
Line 26: Line 38:
 
Since a Linux Software RAID device is itself a block device, the above
 
Since a Linux Software RAID device is itself a block device, the above
 
implies that you can actually create a RAID of other RAID devices.
 
implies that you can actually create a RAID of other RAID devices.
This in turn makes it possible to support RAID-10 (RAID-0 of multiple
+
This in turn makes it possible to support RAID-1+0 (RAID-0 of multiple
 
RAID-1 devices), simply by using the RAID-0 and RAID-1 functionality
 
RAID-1 devices), simply by using the RAID-0 and RAID-1 functionality
 
together. Other more exotic configurations, such a RAID-5 over RAID-5
 
together. Other more exotic configurations, such a RAID-5 over RAID-5
 
"matrix" configurations are equally supported.
 
"matrix" configurations are equally supported.
 +
 +
(Do not confuse RAID 1+0 with RAID-10. Although nominally identical, 1+0 is a raid array built on other raid arrays, while RAID-10 is actually a distinct linux raid level. Unfortunately, the terms are usually used interchangeably. If you see a "+" sign it should mean a raid array of raid arrays - the other common one is 5+0.)
  
 
The RAID layer has absolutely nothing to do with the filesystem layer.
 
The RAID layer has absolutely nothing to do with the filesystem layer.
Line 45: Line 59:
 
each level.
 
each level.
  
 
+
See the [[Performance]] section for comparison of different levels of RAID.
  
 
==Swapping on RAID==
 
==Swapping on RAID==
  
Swapping on a mirrored RAID can help you survive a failing disk. If a disk fails, then data for swapped processes would be inaccessable in a non-mirrored environment. If you run in a mirrored environment, then the system can go on running even if a disk fails   in service. You can even have more than one copy of the data with a raid10 type array, preventing against multiple disks failing.  
+
Swapping on a mirrored RAID can help you survive a failing disk. If a disk fails, then data for swapped processes would be inaccessible in a non-mirrored environment. If you run in a mirrored environment, then the system can go on running even if a disk fails in service. You can even have more than one copy of the data with a raid10 type array, preventing against multiple disks failing.  
  
 
There's not much reason to use RAID0 for swap performance reasons. The kernel
 
There's not much reason to use RAID0 for swap performance reasons. The kernel
Line 66: Line 80:
  
  
This setup lets the machine swap in parallel on seven SCSI devices. No
+
This setup lets the machine swap in parallel on seven hard drives. No
 
need for RAID0, since this has been a kernel feature for a long time.
 
need for RAID0, since this has been a kernel feature for a long time.
  
Line 87: Line 101:
 
==Why mdadm?==
 
==Why mdadm?==
  
mdadm is now the standard software RAID management tool
+
mdadm is now the standard software RAID management tool for Linux.
for Linux; using raidtools is deprecated (and the code does not appear
+
to have been worked on since Jan 2003) and although it will still work
+
for basic use, bugs have been reported where raidtools does not handle
+
new features correctly.
+
  
The mdadm tool, written by Neil Brown, a software engineer at the
+
The mdadm tool was written by Neil Brown, who is a software engineer at the
 
University of New South Wales and a kernel developer.
 
University of New South Wales and a kernel developer.
 
See http://www.kernel.org/pub/linux/utils/raid/mdadm/ANNOUNCE for the latest version.
 
See http://www.kernel.org/pub/linux/utils/raid/mdadm/ANNOUNCE for the latest version.
 
+
It was based on and has obsoleted the raidtools suite.
The main differences between mdadm and raidtools are:
+
  
 
* mdadm can diagnose, monitor and gather detailed information about your arrays
 
* mdadm can diagnose, monitor and gather detailed information about your arrays
* mdadm is a single centralized program and not a collection of disperse programs, so there's a common syntax for every RAID management command
+
* mdadm is a single centralized program and provides a common syntax for every RAID management command
 
* mdadm can perform almost all of its functions without having a configuration file and does not use one by default
 
* mdadm can perform almost all of its functions without having a configuration file and does not use one by default
* Also, if a configuration file is needed, mdadm will help with management of it's contents
+
* Also, if a configuration file is needed, mdadm will help with management of its contents
 +
 
 +
 
 +
{| style="border:1px solid #aaaaaa; background-color:#f9f9f9;width:100%; font-family: Verdana, sans-serif;"
 +
|- padding:5px;padding-top:0.5em;font-size: 95%;
 +
| <span style="float:right; padding-left:5px;">Forward to [[Devices]]</span>
 +
|}

Latest revision as of 22:42, 3 October 2016

Forward to Devices

Contents

[edit] Why RAID?

There can be many good reasons for using RAID. A few are: the ability to combine several physical disks into one larger virtual device, performance improvements, and redundancy.

It is, however, very important to understand that RAID is not a general substitute for good backups. Some RAID levels will make your systems immune to data loss from one or two disk failures, but RAID will not allow you to recover from an accidental rm -rf /. RAID will also not help you preserve your data if the server holding the RAID itself is lost in one way or the other (theft, flooding, earthquake, Martian invasion etc.)

RAID is meant to allow you to keep systems up and running, in case of common hardware problems (disk failure). It is not in itself a complete data safety solution. This is very important to realize.

With modern huge SATA drives, however, it is still very easy to lose an array to a single drive failure. The wrong choice of raid level, for example. And it is common for the reconstruction of an array after one drive has failed, to be actively responsible for the failure of a second drive. Drives don't tend to fail at random - if you buy all the drives for your raid at the same time, then they are all likely to fail at roughly the same time. And the most common cause of anguished emails to the mailing list is using unsuitable drives for the raid.

[edit] Device and filesystem support

Linux RAID can work on most block devices. It doesn't matter whether you use SATA, USB, IDE or SCSI devices, or a mixture. Some people have also used the Network Block Device (NBD) with success.

Since a Linux Software RAID device is itself a block device, the above implies that you can actually create a RAID of other RAID devices. This in turn makes it possible to support RAID-1+0 (RAID-0 of multiple RAID-1 devices), simply by using the RAID-0 and RAID-1 functionality together. Other more exotic configurations, such a RAID-5 over RAID-5 "matrix" configurations are equally supported.

(Do not confuse RAID 1+0 with RAID-10. Although nominally identical, 1+0 is a raid array built on other raid arrays, while RAID-10 is actually a distinct linux raid level. Unfortunately, the terms are usually used interchangeably. If you see a "+" sign it should mean a raid array of raid arrays - the other common one is 5+0.)

The RAID layer has absolutely nothing to do with the filesystem layer. You can put any filesystem on a RAID device, just like any other block device.

[edit] Performance

Often RAID is employed as a solution to performance problems. While RAID can indeed often be the solution you are looking for, it is not a silver bullet. There can be many reasons for performance problems, and RAID is only the solution to a few of them.

See the Introduction#The_RAID_levels for a mention of the performance characteristics of each level.

See the Performance section for comparison of different levels of RAID.

[edit] Swapping on RAID

Swapping on a mirrored RAID can help you survive a failing disk. If a disk fails, then data for swapped processes would be inaccessible in a non-mirrored environment. If you run in a mirrored environment, then the system can go on running even if a disk fails in service. You can even have more than one copy of the data with a raid10 type array, preventing against multiple disks failing.

There's not much reason to use RAID0 for swap performance reasons. The kernel itself can stripe swapping on several devices, if you just give them the same priority in the /etc/fstab file.

A nice /etc/fstab could look like:

 /dev/sda2       swap           swap    defaults,pri=1   0 0
 /dev/sdb2       swap           swap    defaults,pri=1   0 0
 /dev/sdc2       swap           swap    defaults,pri=1   0 0
 /dev/sdd2       swap           swap    defaults,pri=1   0 0
 /dev/sde2       swap           swap    defaults,pri=1   0 0
 /dev/sdf2       swap           swap    defaults,pri=1   0 0
 /dev/sdg2       swap           swap    defaults,pri=1   0 0


This setup lets the machine swap in parallel on seven hard drives. No need for RAID0, since this has been a kernel feature for a long time.

A different reason to use RAID for swap is high availability. If you set up a system to boot on eg. a RAID-1 device, the system should be able to survive a disk crash. If a system without mirrored swapping has been swapping on the now faulty device, you will most likely be going down. Swapping on a mirrored RAID partition such as RAID-1, raid10,n2 or raid10,f2 type would solve this problem.

There has been a lot of discussion about whether swap was stable on RAID devices. This is a continuing debate, because it depends highly on other aspects of the kernel as well. As of this writing, it seems that swapping on RAID should be perfectly stable, you should however stress-test the system yourself until you are satisfied with the stability.

You can set up RAID in a swap file on a filesystem on your RAID device, or you can set up a RAID device as a swap partition, as you see fit. As usual, the RAID device is just a block device.

[edit] Why mdadm?

mdadm is now the standard software RAID management tool for Linux.

The mdadm tool was written by Neil Brown, who is a software engineer at the University of New South Wales and a kernel developer. See http://www.kernel.org/pub/linux/utils/raid/mdadm/ANNOUNCE for the latest version. It was based on and has obsoleted the raidtools suite.

  • mdadm can diagnose, monitor and gather detailed information about your arrays
  • mdadm is a single centralized program and provides a common syntax for every RAID management command
  • mdadm can perform almost all of its functions without having a configuration file and does not use one by default
  • Also, if a configuration file is needed, mdadm will help with management of its contents


Forward to Devices
Personal tools