-install mdadm tool: sudo apt-get install mdadm. Remeber to set postfig to local.
-Creating 4 Disks for array 5 level
VM ware: file>virtual media manager>new, then follow screen instruction. I chose 5 gb for size for my drive.
Add SCSI controller. then add 5 new drives i just created for to the controller.
Now, i need to check if the disks are properly install on my system: sudo fdisk -l | more. Result: 5 drives are unpartitioned.
now, i have to do: fdisk my 5 drive using command: sudo fdisk /dev/sdb (sdc, sde, sdd, sde, sdf) to partition my 5 drive.
follow screen instruction: n for create new partition>p for primary partition>choose 1 for drive number> then take the default for the first and last cylinders. Then t for chosing file system>fd (NOT "df") for auto Raid autodetect.
-Now my 5 drives are ready for the array
-creating array level 5 with 3 drives 1 hot spare
sudo mdadm --create /dev/md5 --level=5 --raid-devices=3 --spare-devices=1 /dev/sdb1 /dev/sdc1 /dev/sdd1 /dev/sde1now check if my array is running: cat /proc/mdstatit should be active.
-create mount point for array: mkdir /mnt/array5
-now i need to make sure my array is mounted by system everytime i reboot: add to the /etc/fstab/dev/md5 /mnt/array5 ext4 defaults 0 1
create the file system to assign for my array: sudo mkfs.ext4 /dev/md5
I think it's better to create label for my array so that the name of my array devices won't change due to the drive failure: sudo e2label /dev/md5 myarray5. then, i need to re-edit the /etc/fstab to change my label for array: change /dev/md5 to LABEL=myarray5 (that's all i have to change, keep the rest the same).
Now, i have to make sure after reboot, my array still there. to do this, use command: sudo mdadm --examine --scan. then copy the output from that command and paste it in /etc/mdadm/mdadm.conf file. then add: DEVICE /dev/sdb1 /dev/sdc1 /dev/sdd1 /dev/sde1 right above that output. (note, yours could be different).
Note: if you skip this one step, it will mess up your array after reboot. VERY IMPORTANT.
Now, all i need to do is mount my Raid Array sudo mount -a (-a mean mount all devices).
Reboot my server, and i see the array is mounted during start up.
Now that i know my array is set up properly, i need to check if the hot spare is working. i fail one drive using command: sudo mdadm /dev/md5 -f /dev/sdc1 (this will fail sdc1 drive in the array). To check, if the hot spare is taking over, check: /proc/mdstat using: more /proc/mdstat. i see my array is recovering. it take me appropriate 4 min to recover.
i go back to check my array, i see the /dev/sdc1(F) meaning failed drive. So i need to hot-remove the fail drive: sudo mdadm /dev/md5 --remove /dev/sdc1, then add the drive back to the array: sudo mdadm /dev/md5 --add /dev/sde1.
Now that the array is back to normal again with 3 disk and 1 hot spare. I know the next time 1 of the drives fail, my data will be saved because my hot-spare will take over the failed drive and save my life.
And i think this is the whole purpose of doing the array: to save your precious data from unexpected events.
Mission Accomplished.
thanks for viewing my blog.
No comments:
Post a Comment