This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | |||
user:kkrauss1:portfolio:raid [2012/04/05 20:34] – [Conclusions] kkrauss1 | user:kkrauss1:portfolio:raid [2012/04/05 20:35] (current) – [Resources] kkrauss1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ======Advanced Data and Storage(RAID)====== | ||
+ | |||
+ | =====BackGround==== | ||
+ | *For this project we are going to play with RAID. So what is RAID? Well its a good bug killer but it is also an acronym for " | ||
+ | |||
+ | ====Prerequisites==== | ||
+ | *So the first thing we are going to need is our virtual server. | ||
+ | *We are going to virtualize our disk drives so the first thing we want to do is log into the VM server. | ||
+ | *Once you are logged in you want to edit the / | ||
+ | *Under the section titled Disk Devices you should see two entries one for disk.img and one for swap.img. | ||
+ | *So add the following lines: | ||
+ | * ' | ||
+ | * ' | ||
+ | * ' | ||
+ | * ' | ||
+ | *Save your changes and exit | ||
+ | |||
+ | *Now you want to change the directory to / | ||
+ | *Once you are in the right place you can do an ls and you should see two files: disk.img and swap.img. | ||
+ | *For this project I want to make each virtual disk one GIG each | ||
+ | *The next steps are going to take a moment. | ||
+ | * dd if=/ | ||
+ | * dd if=/ | ||
+ | * dd if=/ | ||
+ | * dd if=/ | ||
+ | | ||
+ | *Now that we have our virtual disks we now need a utility to manage our RAID devices. | ||
+ | *Keep in mind though that you want this utility on the virtual machine, not the server so make sure you startup your VM and then log into that. | ||
+ | *Once you are on your virtual machine you should do this: | ||
+ | * aptitude update | ||
+ | * aptitude upgrade | ||
+ | * aptitude search mdadm | ||
+ | * (assuming search found the mdadm package) aptitude install mdadm(or whatever the package name was when you did the search) | ||
+ | * Once all of this is done you should restart your VM and log back in | ||
+ | |||
+ | *So all prerequisites are done, we have virtualized 4 disks for our RAID project and have the RAID utility installed so lets start out with RAID 0 | ||
+ | *As a side note, all of this will work even when not virtualized, | ||
+ | |||
+ | ====RAID 0==== | ||
+ | *Make sure you have rebooted your VM and are logged back in, you do NOT do this from the server. | ||
+ | *RAID 0 needs at least two disks, it has no redundancy but increases performance because the blocks are striped. | ||
+ | *To create RAID 0 array, format and mount do this: | ||
+ | * mdadm --create /dev/md0 --level=0 --raid-disks=2 /dev/xvda3 / | ||
+ | * mkfs.ext3 /dev/md0 | ||
+ | * mount /dev/md0 /mnt | ||
+ | |||
+ | *When doing this it can take a while for the entire process to complete, you can check the process by doing the following: | ||
+ | * cat / | ||
+ | |||
+ | *Once everything is complete you will have created your first RAID array, now being that this is a level 0 array all you have done is taken two virtual drives that are each one gig and virtually combined them to access them as a single 2 gig drive. | ||
+ | *Two ways to test and play with it is to do a "df -h" and if you look at the /dev/md0 you should see it as approximately 2 GIGS | ||
+ | *You can also try to copy a file larger than 1 gig to the drive. | ||
+ | |||
+ | *So in conclusion for RAID 0; it allows for multiple disks to be tied together as one logical unit and allows for faster writing of data since twice(or more) devices can be written to at a time. | ||
+ | |||
+ | ====RAID 1==== | ||
+ | *RAID 1 also requires a minimum of 2 disks but does have redundancy and does not increase performance as it does not stripe. | ||
+ | *Before we create a new ARRAY we need to deactivate the last one using: mdadm --misc -S /dev/md0 | ||
+ | *To create a RAID 1 array do the following: | ||
+ | * mdadm --create /dev/md0 --level=1 --raid-disks=2 /dev/xvda3 /dev/xvda4 | ||
+ | * mkfs.ext3 /dev/md0 | ||
+ | * mount /dev/md0 /mnt | ||
+ | |||
+ | *When doing this it can take a while for the entire process to complete, you can check the process by doing the following: | ||
+ | * cat / | ||
+ | |||
+ | |||
+ | *Once everything is complete you will have created level 1 array. You have taken two virtual drives that are each one gig and mirrored them. | ||
+ | *Two ways to test and play with it is to do a "df -h" and if you look at the /dev/md0 you should see it as approximately 1 GIGS(There are two 2 gig drives but they are mirrored so will only show up as 1 gig drive.) | ||
+ | *You can also write a couple of files to /mnt then overwrite one of the disk images used for our virtual disks. | ||
+ | * By doing this we have simulated a harddrive failure. | ||
+ | * First we must tell mdadm that we have a faulty drive: | ||
+ | * mdadm --manage --set-fault /dev/md0 /dev/xvda3 | ||
+ | * Now we simply add a new drive and it will automatically rebuild! (I used disk5.img) | ||
+ | * mdadm --manage /dev/md0 -a /dev/xvda5 | ||
+ | * you can type: watch cat / | ||
+ | |||
+ | *So in conclusion for RAID 1; it allows for multiple disks to be tied together and mirrored thus allowing for a complete restore if one of the disks in the array is damaged. | ||
+ | |||
+ | ====RAID 5==== | ||
+ | *RAID 5 needs at least 3 disks. | ||
+ | *Before we create a new ARRAY we need to deactivate the last one using: mdadm --misc -S /dev/md0 | ||
+ | |||
+ | *To create a RAID 5 array do the following: | ||
+ | * mdadm --create /dev/md0 --level=5 --raid-disks=3 /dev/xvda3 /dev/xvda4 /dev/xvda5 | ||
+ | * mkfs.ext3 /dev/md0 | ||
+ | * mount /dev/md0 /mnt | ||
+ | |||
+ | *When doing this it can take a while for the entire process to complete, you can check the process by doing the following: | ||
+ | * cat / | ||
+ | |||
+ | |||
+ | *You have now built a level 5 RAID array. | ||
+ | |||
+ | *So in conclusion RAID5 is an efficient way to get both performance and redundancy benefits with only 3 drives. | ||
+ | |||
+ | ====Conclusions==== | ||
+ | *RAID is quite interesting and fun to play with. You can use it for faster data storage and for redundancy which is always a nice thing. | ||
+ | *Little shout out to Matt as he helped me alot with this and in the process learned a thing or two as well. | ||
+ | |||
+ | ====Resources==== | ||
+ | [[http:// | ||
+ | |||
+ | [[http:// | ||
+ | |||
+ | [[http:// | ||