Configuring Amazon EC2 for RAID

Articles & Tutorials>Configuring Amazon EC2 for RAID
Take advantage of the Large and Extra Large instances by configuring them to use RAID for more fault tolerance or better disk throughput.

Details

Submitted By: Bruce@AWS
AWS Products Used: Amazon EC2
Created On: November 28, 2007 2:23 AM GMT
Last Updated: September 21, 2008 10:08 PM GMT

Editor's Note: The following tutorial only applies to instances launched after December 6, 2007.

By Marcin Kowalski and Bruce Gutman, Amazon Web Services

A Redundant Array of Independent Drives (RAID) is a method of grouping multiple drives together to improve performance or fault tolerance. Because m1.large and m1.xlarge instances have multiple ephemeral stores, you can now use RAID with these instance types.

Important: Using RAID does not guarantee against instance failure and is not a replacement for a sound backup policy. If an underlying drive fails, you should immediately migrate to a new instance.

This tutorial describes how to set up a RAID 0 or RAID 1 mirror on an Amazon EC2 m1.large or m1.xlarge instance.

  • RAID 0 stripes data across two ephemeral stores to increase write performance. If an ephemeral store fails, all data is lost.
  • RAID 1 redundantly writes data to two ephemeral stores. If an ephemeral store fails, a copy of the data remains on the surviving ephemeral store.

Although m1.large and m1.xlarge instances can support other RAID types, this is beyond the scope of this tutorial.

To configure RAID 0 or RAID 1 on Amazon EC2, complete the following procedures:

  1. Installing the Software
  2. Creating Partition Tables
  3. Configuring the Mirror

Installing the Software

Before you do anything else, follow these steps to install the software:

  1. Login as root
  2. Install mdadm and its dependencies by entering the following:
    yum -y install mdadm
    Dependencies Resolved
    =============================================================================
    Package                 Arch       Version          Repository        Size 
    =============================================================================
    Installing:
    mdadm                   x86_64     2.5.4-2.fc6      core              809 k
    Installing for dependencies:
    exim                    x86_64     4.63-5.fc6       extras            1.2 M
    mysql                   x86_64     5.0.27-1.fc6     updates-released  3.3 M
    perl-DBI                x86_64     1.52-1.fc6       core              605 k
    postgresql-libs         x86_64     8.1.9-1.fc6      updates-released  197 k
    Transaction Summary
    =============================================================================
    Install      5 Package(s)         
    Update       0 Package(s)         
    Remove       0 Package(s)        
    Total download size: 6.1 M
    Is this ok [y/N]: y
    Downloading Packages:
    (1/5): exim-4.63-5.fc6.x8  100% |=========================| 1.2 MB     00:01     
    (2/5): perl-DBI-1.52-1.fc  100% |=========================| 605 kB     00:00     
    (3/5): postgresql-libs-8.  100% |=========================| 197 kB     00:01     
    (4/5): mysql-5.0.27-1.fc6  100% |=========================| 3.3 MB     00:34     
    (5/5): mdadm-2.5.4-2.fc6.  100% |=========================| 809 kB     00:00     
    warning: rpmts_HdrFromFdno:  Header V3 DSA signature: NOKEY, key ID 1ac70ce6
    Importing GPG key 0x1AC70CE6  "Fedora Project <fedora-extras@fedoraproject.org>" from  /etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-extras
    Is this ok [y/N]: y
    warning: rpmts_HdrFromFdno:  Header V3 DSA signature: NOKEY, key ID 4f2a6fd2
    Importing GPG key 0x4F2A6FD2  "Fedora Project <fedora@redhat.com>" from  /etc/pki/rpm-gpg/RPM-GPG-KEY-fedora
    Is this ok [y/N]: y
    Importing GPG key 0xDB42A60E  "Red Hat, Inc <security@redhat.com>" from  /etc/pki/rpm-gpg/RPM-GPG-KEY
    Is this ok [y/N]: y
    Running Transaction Test
    Finished Transaction Test
    Transaction Test Succeeded
    Running Transaction
    Installing: postgresql-libs              ######################### [1/5] 
    Installing: perl-DBI                     #########################  [2/5] 
    Installing: mysql                         ######################### [3/5] 
    Installing: exim                          ######################### [4/5] 
    Installing: mdadm                         ######################### [5/5]
    Installed: mdadm.x86_64  0:2.5.4-2.fc6
    Dependency Installed:  exim.x86_64 0:4.63-5.fc6 mysql.x86_64 0:5.0.27-1.fc6 perl-DBI.x86_64  0:1.52-1.fc6 postgresql-libs.x86_64 0:8.1.9-1.fc6
    Complete!
  3. Remove the /mnt entry from /etc/fstab.
  4. Verify the entry is removed:
    # cat /etc/fstab
    # Supplied by: Amazon EC2 public image
    /dev/sda1 /     ext3    defaults 1 1
    none      /proc proc    defaults 0 0
    none      /sys  sysfs    defaults

Creating Partition Tables

To create the partition tables:

  1. Create a partition table on /dev/sdb. In this tutorial, we are creating 500MB RAID partitions. You can create any partition size that you like.
    # fdisk /dev/sdb
    Device contains neither a  valid DOS partition table, nor Sun, SGI or OSF disklabel
    Building a new DOS  disklabel. Changes will remain in memory only,
    until you decide to write  them. After that, of course, the previous
    content won't be  recoverable.
         
    The number of cylinders for  this disk is set to 54827.
    There is nothing wrong with  that, but this is larger than 1024,
    and could in certain setups  cause problems with:
    1) software that runs at  boot time (e.g., old versions of LILO)
    2) booting and partitioning  software from other OSs
    (e.g., DOS FDISK, OS/2 FDISK)
    Warning: invalid flag 0x0000  of partition table 4 will be corrected by w(rite)
  2. When the Command prompt appears, enter "p."
    Command (m for help): p
    Disk /dev/sdb: 450.9 GB, 450971566080  bytes
    255 heads, 63 sectors/track,  54827 cylinders
    Units = cylinders of 16065 *  512 = 8225280 bytes
      Device Boot      Start         End      Blocks    Id  System
  3. When the Command prompt appears, enter "n."
    Command (m for help): n
       e    extended
    p    primary partition (1-4)
  4. Enter "p" to select the primary partition.
  5. When prompted to specify the partition number, enter "1."
    Partition number (1-4): 1
  6. When prompted to specify the first cylinder, enter "1."
    First cylinder (1-54827,  default 1): 1
  7. When prompted to specify the size of the RAID array, enter a value up to the size of the ephemeral store.
    Last cylinder or +size or  +sizeM or +sizeK (1-54827, default 54827): +500M
  8. When the Command prompt appears, enter "t."
    Command (m for help): t
  9. When prompted to select the partition, enter "1."
    Selected partition 1
  10. When prompted to specify the Hex code, enter "fd" to select Linux RAID Auto.
    Hex code (type L to list  codes): fd
    Changed system type of  partition 1 to fd (Linux raid autodetect)
    	
    Note:To view a list of codes, enter "L."
  11. When the Command prompt appears, enter "w" to modify the partition table.
    Command (m for help): w
    The partition table has been  altered!
    Calling ioctl() to re-read  partition table.
    Syncing disks.
  12. Repeat this procedure for /dev/sdc.

Configuring the Mirror

After creating the second partition, create the actual mirror:

  1. Enter the following command:
    # mdadm --create /dev/md0 --level 1 --raid-devices 2 /dev/sdb1 /dev/sdc1
    mdadm: array /dev/md0  started.
    The instance  begins building the mirror.

    For RAID 0, enter "--level 0".
  2. To view the status of the build, enter the following command:
    # cat /proc/mdstat 
    Personalities : [raid1] 
    md0 : active raid1 sdc1[1] sdb1[0]
    497856 blocks [2/2] [UU]
    [>....................] resync = 2.6% (13728/497856) finish=5.2min speed=1525K/sec
    unused devices: <none>

    After the build is complete, you can mount and format the mirror.
  3. To increase the speed of the initial construction, increase the minimum reconstruction speed limit to =~15MB/sec by entering the following command:
    # echo "15000" > /proc/sys/dev/raid/speed_limit_min 
  4. To make sure that the device is correctly initialised at boot time, create the /etc/mdadm.conf file by entering the following command:
    # echo 'DEVICE /dev/hd*[0-9] /dev/sd*[0-9]' > /etc/mdadm.conf
    # mdadm --detail --scan >> /etc/mdadm.conf
  5. Setup monitoring of your new page as described in the mdadm man page.

Comments

mdadm: Cannot open /dev/sdo: Device or resource busy
I followed the instructions above except the installation of mdadm as I'm using Debian (Lenny) (apt-get install mdadm) but I got this error and still can't make raid 0 mdadm --create /dev/md0 --level 0 --raid-devices 4 /dev/sdl /dev/sdm /dev/sdn /dev/sdo mdadm: Cannot open /dev/sdl: Device or resource busy mdadm: Cannot open /dev/sdm: Device or resource busy mdadm: Cannot open /dev/sdn: Device or resource busy mdadm: Cannot open /dev/sdo: Device or resource busy mdadm: create aborted cat /proc/mdstat Personalities : md1 : inactive sdl[0] sdo[3] sdn[2] sdm[1] 629145344 blocks unused devices:
deathect on April 30, 2009 12:18 PM GMT
We are temporarily not accepting new comments.
©2014, Amazon Web Services, Inc. or its affiliates. All rights reserved.