Last active
December 15, 2015 04:39
-
-
Save armanddp/5202995 to your computer and use it in GitHub Desktop.
RAID-0 on EBS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create volumes | |
for x in {1..6}; do \ | |
ec2-create-volume --size 100 -z us-east-1c --type io1 --iops 1000; \ | |
done > volumes.txt | |
# Tag volumes for easy reference | |
VOLUME_LIST=$(ec2-describe-volumes \ | |
| grep "2013-03-20" | awk '{print $2}') | |
for volume in $(echo $VOLUME_LIST); do | |
echo "Setting tags on the EBS volume ($volume)..." | |
ec2-create-tags $volume -t "raid0" | |
done | |
# Attach the volumes to new instance | |
available_devs=("f" "g" "h" "i" "j" "k") | |
for vol in $(awk '{print $2}' volumes.txt); do \ | |
echo $vol -i i-2b74c149 -d /dev/sd${available_devs[i]}; \ | |
ec2-attach-volume $vol -i i-2b74c149 -d /dev/sd${available_devs[i]}; \ | |
i=$(( i + 1 )); \ | |
done | |
# Install relevant dependencies | |
sudo yum -y install mdadm | |
sudo yum -y install xfsprogs | |
# Setup RAID array | |
sudo mdadm --create /dev/md0 --level 0 --chunk=256 --raid-devices=6 /dev/sdf /dev/sdg /dev/sdh /dev/sdi /dev/sdj /dev/sdk | |
mdadm: Defaulting to version 1.2 metadata | |
mdadm: array /dev/md0 started. | |
# Make it persistent | |
sudo mdadm --detail --scan --verbose > /etc/mdadm.conf | |
# See http://aws.amazon.com/amazon-linux-ami/faqs/#raid why raid uses /dev/md127 on reboot and rather use labels | |
# Create filesystem | |
sudo mkfs.xfs -L RAID0 /dev/md0 | |
# Next lets add the /dev/md0 drive to the file systems table for auto-mounting on reboot. | |
echo "LABEL=RAID0 /raiddrive xfs noatime 0 0" | sudo tee -a /etc/fstab | |
# Mount the drive | |
sudo mkdir /raiddrive | |
sudo mount /raiddrive | |
#Lets set the block device read ahead have to 64k which seems to really smooth out and improve the EBS drives. | |
sudo blockdev --setra 65536 /dev/md0 | |
#Next lets verify the drive is operation | |
df -h /raiddrive | |
#Prewarm our RAID to avoid 5-50% IOPS penalty on 1st read (Think this is bogus so skipping in future setups) | |
dd if=/dev/md0 of=/dev/null | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment