Setting Up RAID
A Redundant Array of Independent Disks (RAID) is a series of disks that can save your data even if a terrible failure occurs on one of the disks. While some versions of RAID make complete copies of your data, others use the so-called parity bit to allow your computer to rebuild the data on lost disks RAID allows an administrator to form an array of several hard drives into one logical drive recognized as one drive by the operating system. It also spreads the data stored over the array of drives to decrease disk access time and accomplish data redundancy. The data redundancy can be used to recover data should one of the hard drives in the array crash.
RAID level 0, or Striping
Disks are grouped together to form one large drive. This offers better performance at the cost of availability. Should any single disk in the RAID fail, the entire set of disks becomes unusable. Two disk minimum.
RAID level 1, or Mirroring,
Disks are copied from one to another, allowing for redundancy. Should one disk fail, the other disk takes over, having an exact copy of data from the original disk. The downside here is slow write times. Two disk minimum.
RAID level 5
Disks are similar to RAID level 0 and join together to form one large drive. The difference here is that 25% of the disk is used for parity bit, which allows the disks to be recovered should a single disk fail. Three disk minimum.
While RAID can be implemented at the hardware level, the Red Hat exams are not hardware based and therefore on the software implementation of RAID through the MD drive.
Step 1. Install the following package for RHEL-6 .
# yum □ install □ mdadm
Step 2. Verify the install:
# rpm □ -qa □ mdadm
Creating a RAID Array
Sdb For RAID |
sda OS |
Sdc For RAID |
Sdd For Spare |
You should know how to create basic partitions by now, so creating a RAID Array should be good practice for you. Create three partitions one on each disk ( sdb, sdc, sdd), allowing each partition to consume the whole disk.
Step-1: Here are the results you should see when you’re done.
# fdisk □ –l
Now you can begin to set up the RAID 5 array with the three partitions in hand. You can use the mdadm command to create any RAID array.
Syntax: mdadm □ [Options]
Options:
-a [Adds a disk into a current array]
-C, [or] – – create [Create a new RAID array]
-D, [or] – – detail [Prints the details of an array]
-G, [or] – – grow [Changes the size or shape of an active array]
-f [Fails a disk in the array]
-l , [or] – – level [Specifies level (type) of RAID array to create]
-n [Specifies the devices in the RAID array]
– q, [or] – – quiet [Species not to show output]
-S, [or] – – stop [Stop an array]
-v, [or] – – verbose [Provides verbose output]
Step-2. You should be able to tell from the following command that you created a new RAID array (/dev/md0), which is a RAID 5, and it contain three disks:
# mdadm □ –Cv □ /dev/md0 □ –l □ 5 □ –n □ 3 □ /dev/sdb1 □ /dev/sdc1 □ /dev/sdd1
Step-3. Use the mdadm command agin to verify that the RAID array has been created successfully.
# mdadm □ –D □ /dev/md0
Step-4. View the status of the newly created RAID array.
# cat □ /proc/mdstat
Step-5. You wait the estimated 2.90 minutes and then query again, you see the [3/3] [UUU].
# cat □ /proc/mdstat
What to Do When a Disk Fails
Suppose that a disk in the array failed. In that case, you need to remove that disk from the array and replace it with a working one. You do have extra disk drives, right? You can manually fail a disk to see what it would be like if a disk failed in the array.
Step-1. To lfail a disk array, use this command.
# mdadm □ /dev/md0 □ –f □ /dev/sdd1
Step-2. Verify that the disk in the array has failed by looking at the details of the RAID array.
# mdadm □ –D □ /dev/md0
Step-3. To remove failed disk from the array, use the command.
# mdadm □ /dev/md0 □ –r □ /dev/sdd1
Step-4. Look at the last few lines of the RAID details again.
# mdadm □ –D □ /dev/md0
Note: When you have a new disk in place, you need to make it active in the array. First, you need to partition the disk like you did originally when setting up the RAID array.
Step-5. When the disk is partitioned, you can add it back to the array as follows:
# mdadm □ /dev/md0 □ –a □ /dev/sdd1
Step-6. Verify that it has been added properly:
# mdadm □ –D □ /dev/md0
Notice that the state of the drive is “rebuilding”. You can query the kernel again to find out how long the system thinks it will be before the spare has been rebuilt.
Step-7. Query the kernel.
# cat □ /proc/mdstat
Step-8. Should something go seriously wrong and you need to take the RAID array offline completely, you can use the following command.
# mdadm □ –vS □ /dev/md0
Deleting A RAID Array
Now that you have successfully implemented a RAID array, you can take it apart by deleting the array.
Step-1. To delete an array, first stop if.
# mdadm □ –vS □ /dev/md0
Step-2. Then remove the RAID Array Device.
# mdadm □ – – remove □ /dev/md0
You should also remove the partitions created for the RAID array.
Warning: When you are creating RAID arrays, there is only one restriction to them. The /boot partition that contains the files necessary to boot the system can be located only on a RAID-level-1 and basic partition. The reason is that the boot loader (GRUB) understands how to handle only RAID-level-1 and basic partition. If you try to create the /boot partition on a RAID-level-5 array, you get an error message.