Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #RAID under linux summary: http://www.ducea.com/2009/03/08/mdadm-cheat-sheet/
- #RAID with EC2: http://bruun.co/2012/06/06/software-raid-on-ec2-with-mdadm
- #Why RAID10 instead of RAID0: http://blog.9minutesnooze.com/raid-10-ebs-data/
- #EBS durability: http://aws.amazon.com/ebs/ (durability section, between 0.1% and 0.5% Anual Failure Rate)
- #Initial situation:
- #root: dev/sda1
- #ebs volumes (1GBx4): /dev/sdb /dev/sdc /dev/sdd /dev/sde
- #Script to create and test RAID10:
- #Show devices
- ls -l /dev/sd* /dev/xv*
- #Avoid race lock
- sudo udevadm control --stop-exec-queue
- #Create RAID
- sudo mdadm --create /dev/md0 --run --level=10 --raid-devices=4 --chunk=64 /dev/sdb /dev/sdc /dev/sdd /dev/sde
- sudo udevadm control --start-exec-queue
- #Now there's an entry under /dev/md/* with the name of the device, for example /dev/md/ip-10-251-94-61:0
- #Use it to update the /etc/fstab file adding a line like this one:
- #/dev/md/ip-10-251-94-61:0 /media/ebs xfs defaults 0 0
- #prewarm with 0s
- sudo time shred -vfz -n 0 /dev/md0
- sudo yum install -y xfsprogs
- #Format and mount
- #BTW, in order to freeze the fs for backups see the xfs_freeze command
- sudo mkdir -p /media/ebs
- sudo mkfs.xfs /dev/md0 -f
- sudo mount -t xfs /dev/md0 /media/ebs
- sudo chown ec2-user:ec2-user /media/ebs/
- #show available space
- df -h
- #Get 821.7 megabytes of data:
- cd /media/ebs
- wget http://dumps.wikimedia.org/eswiki/20120906/eswiki-20120906-abstract.xml
- head eswiki-20120906-abstract.xml
- #status (U means it's OK, F means it's in failed status)
- cat /proc/mdstat
- #alternative
- mdadm --detail /dev/md0
- #mark a volume as failed:
- sudo mdadm --fail /dev/md0 /dev/sdc
- sudo mdadm --remove /dev/md0 /dev/sdc
- #Now is safe to detach de volume (using the ec2 console)
- #Check it's still working
- cp eswiki-20120906-abstract.xml eswiki-20120906-abstract2.xml
- #Create another volume (or reattach the old one) with the name /dev/sdx
- #Add the new volume
- sudo mdadm --add /dev/md0 /dev/sdx
- #A mdadm --detail should indicate all four disk are available and in clean state after a while
- #In case you cannot access de device after a reboot:
- sudo mdadm --stop --scan
- sudo mdadm --assemble --scan
- sudo mount /dev/md0 ebs
Advertisement
Add Comment
Please, Sign In to add comment