28 June 2011

MD Quickstart–md raid

Easy software raid using MD (multiple device driver).
MD just seems more intuitive than the LVM that comes with a click click CentOS installation. Here are the steps for creating a md device.
1. Create the virtual drive
First create the disks, whether in AWS or on ESX. Four seems to be a magic number.
mdadm --create /dev/md0 --chunk=256 --level 0 --raid-devices=4 /dev/sdl /dev/sdm /dev/sdn /dev/sdo
In AWS, the device is easy to know because it is set when the disk is attached to the system.

In ESX, at adding a disk to SCSI 1:0 will likely start at sdb and would look something like this:
 mdadm --create /dev/md0 --chunk=256 --level 5 --raid-devices=4 /dev/sdb /dev/sdc /dev/sdd /dev/sde
MD RAID level 0 has excellent performance on AWS (and ESX as well). I’ve seen garnering 15 percent performance boost in Hudson build environments on AWS. However, RAID 0 cannot be expanded, so upsizing (adding a disk) will require a forklift migration.

Finally format the drive. If using xfs, that package may need to be installed.
yum install xfsprogs
mkfs.xfs /dev/md0
2. Ensure the device will start at boot
Create a /etc/mdadm.conf file with the following line:
DEVICE partitions
Then add the device md information with the following command:
mdadm --detail --scan | tee -a /etc/mdadm.conf
3. Wire up the drive so it will be there after reboot
In /etc/fstab, add the device to the mount point, in this case /data:
/dev/md0 /data xfs noatime,nodiratime,allocsize=512m 0 0
Running the command mount -a should mount the drive without any errors.
4. Check the drive
Two commands will help check status of the drive.

 mdadm --detail /dev/md0 will show the RAID health of the drive.
df –h will show the operating system’s view of the drive.

No comments: