Saturday, July 20, 2013

Configure RAID in RHEL6

Redundant Array of Inexpensive Disk:
RAID Disk partitions technology that allow more advanced features such as redundancy and better performance. This technology is usually used on server based storage where a large amount of storage required with fault tolerance. Before we describe how to implement RAID, let’s look at the different types of RAID Levels: There are many types of RAID Levels but right now i am going to describe only those that are required for RHCE exam preparation:

A- RAID 0 (Striping): disks are grouped together to form one large drive. This offers better performance at the cost of availability. If any single disk in the RAID fail, the entire set of disks becomes unusable. It require minimum two disks. For eaxample suppose you have two disks wtih 50GB in size, you can combine both to treat as a single disk to achieve 100Gb space.

B- RAID 1 (Mirroring): disks are copied from one to another, allowing for redundancy. If one disk fail, the other disk takes over, having an exact copy of data from the original disk but here is slow write speed. Two disk minimum.

C- RAID 5 (Striping with parity): disks are similar to RAID 0 and are join together to form one large drive. The difference here is that 25% of the disk is used for a parity bit, which allows the disks to be recovered if a single disk fail. RAID 5 require minimum three disks.
While RAID can be implemented at the hardware level, the Red Hat exams are not hardware based and therefore focus on the software implementation of RAID. Next, let’s use the three free disk drives (hdb, hdc, and hdd) to set up a RAID array.

Step 1. Install the following package:
# yum install -y mdadm

Step 2. Verify the install:
# rpm -qa | grep mdadm
mdadm-3.1.3-1.el6.x86_64
Now we are going to start with a RAID 5 setup, so you need to make partitions on at least three different disks. You can use the mdadm command to create any RAID array.
Syntax: mdadm [options]

Options:
-a  Adds a disk into a current array.
-C --create Creates a new RAID array.
-D --detail Prints the details of an array.
-f   Fails a disk in the array.
-l --level Specifies level (type) of RAID array to create.
-n --raid-devices Specifies the devices in the RAID array.
-S --stop Stops an array.
-v --verbose Provides verbose output.

Step 3. You can use the following command to create a new RAID array (/dev/md0), which is a RAID 5, and it contains three disks:
# mdadm -Cv /dev/md0 —level=5 -n3 /dev/sda6 /dev/sda7 /dev/sda8
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md0 started.

Step 4. Use the mdadm command again to verify that the RAID array has been created successfully:
# mdadm –D /dev/md0
/dev/md0:
Version : 1.2
Creation Time : Thu jul 27 14:09:23 2013
Raid Level : raid5
Array Size : 16769024 (15.99 GiB 17.17 GB)
Used Dev Size : 8384512 (8.00 GiB 8.59 GB)
Raid Devices : 3
Total Devices : 3

Step 5. View the status of the newly created RAID array:
# 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.

Step 1. To fail a disk in the array, use this command:
# mdadm /dev/md0 -f /dev/sda6
mdadm: set /dev/sda6 faulty in /dev/md0
Step 2. Verify that the disk in the array has failed by looking at the details of the RAID array:
# mdadm -D /dev/md0
Number Major Minor RaidDevice State
0 8 17 0 active sync /dev/sda7
1 8 33 1 active sync /dev/sda8
2 0 0 2 removed
3 8 49 - faulty spare
/dev/sda6

Now that you know that the disk has failed, you need to remove it from the array so it can be replaced.
Step 3. To remove a disk from the array, use this command:
# mdadm /dev/md0 -r /dev/sda6
mdadm: hot removed /dev/sda6 from /dev/md0

Step 4. Look at the last few lines of the RAID details again:
# mdadm -D /dev/md0
/dev/md0:
Number Major Minor RaidDevice State
0 8 17 0 active sync /dev/sda7
1 8 33 1 active sync /dev/sda8
2 0 0 2 removed
You can see from the last line of the output that the disk has been “removed.”

Step 5. When the disk is partitioned, you can add it back to the array as follows:
# mdadm /dev/md0 -a /dev/sda6
mdadm: re-added /dev/sda6
Step 6. Verify that it has been added properly:
# mdadm -D /dev/md0
/dev/md0:
Number Major Minor RaidDevice State
0 8 17 0 active sync /dev/sda7
1 8 33 1 active sync /dev/sda8
3 8 49 2 spare rebuilding /dev/sda6
Note: Notice that the state of the drive is “rebuilding" it may take approx 2 minute to rebuid please wait and verify again.

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 it:
# mdadm -vS /dev/md0
mdadm: stopped /dev/md0
Step 2. Then remove the RAID array device:
# mdadm --remove /dev/md0

No comments:

Post a Comment