1. What is RAID?
RAID is a fault-tolerant, inexpensive disk array that consolidates multiple small disks into a larger disk device that not only expands the capacity of the disk, but also enables data protection.
2.RAID Rating
RAID depending on the level of the implementation of the function and performance is also different
RAID0 requires at least two disks, dividing the data into chunks of equal size (chunk) before writing the data, and then crossing the data to different devices. The advantage is that the data read and write performance is good, the disadvantage is that if a piece of disk data corruption, the entire file is destroyed.
RAID1 mirroring mode, can achieve full data backup, write data, the same data is written to two different disks, disk space utilization is 50%, read performance, write performance is poor. The biggest advantage is that you can implement a full backup of your data.
RAID 1+0 requires four disks, first with two disks for RAID1, and two RAID1 for RAID0
RAID 0+1 requires four disks, first with two disks for RAID0, and two RAID1 for RAID0
RAID5 requires at least three or more disk implementations, and when any piece of disk has data corruption, the data can be recovered using the same bit check code (parity). For example, 1+2=3,3 can be seen as a parity, and when data 1 is damaged, it can be destroyed by 3-2=1 (of course, the concrete implementation is certainly more complicated than this). Note that RAID5 only supports the destruction of a piece of disk.
3.RAID Pre-disk
In order to be able to externally a damaged disk faster, you can prepare the disk, which is not normally used by raid, and when there is data corruption, the disk can be actively pulled into the disk array to replace the damaged disk. If hot-swappable is supported, it can be replaced online with different shutdowns.
4. Software disk array
Usually the production environment is used in the hardware disk array, the management of the disk array in the disk array card in the implementation of the chip, the performance is very good, the disadvantage is that disk array cards are generally expensive.
Software disk array can be implemented by software Mdadm, but it consumes more system resources and has poor performance. Software disk array with the device name/dev/md#, we can achieve the purpose of learning through the software disk array.
5. Settings for the software disk array
Below we through the mdadm to rehearse, achieves the study goal.
The format of the MDADM is
Mdadm--detail/dev/md# #查看某个RAID设备的详细信息
Mdadm--create--auto=yes/dev/md#--level=n--raid-devices=n
--spare-devices=n
The meaning of the specific parameters:
--create #创建RAID设备
--auto=yes #后面指定软件磁盘阵列设备
--level=n #设置级别 suggest just use 0 1 5
--raid-devices=n #设置几个磁盘设备作为RAID设备
--spare-devices=n #设置几个磁盘作为预备设备
The following is a practical walkthrough, no practical operation will never get intuitive experience, Marco's famous saying ...
Mdadm--create--auto=yes/dev/md0--level=1--raid-device=2--spare-devices=1/dev/sda{9,10,11}
650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M02/84/69/wKiom1eQNjWycJe3AAGtugIET-k214.jpg-wh_500x0-wm_3 -wmp_4-s_2608750523.jpg "title=" 1.jpg "alt=" Wkiom1eqnjwycje3aagtugiet-k214.jpg-wh_50 "/>
Mdadm--detail/dev/md0
650) this.width=650; "Src=" Http://s1.51cto.com/wyfs02/M02/84/69/wKiom1eQNpKgl791AAKqIlVO-yk615.jpg-wh_500x0-wm_3 -wmp_4-s_3985294084.jpg "title=" 1.jpg "alt=" Wkiom1eqnpkgl791aakqilvo-yk615.jpg-wh_50 "/>
Format the RAID device and mount it
Mke2fs-j/dev/md0
Mkdir/mnt/raid
Mount/dev/md0/mnt/raid
650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M00/84/69/wKioL1eQN0rydupZAALLqrQcstg650.jpg-wh_500x0-wm_3 -wmp_4-s_3075867591.jpg "title=" 1.jpg "alt=" Wkiol1eqn0rydupzaallqrqcstg650.jpg-wh_50 "/>
Df/mnt/raid #查看一下该设备我们可以看到设备的容量是100M Because we are creating a RAID1 device, and another 100M partition exists as a mirror.
650) this.width=650; "Src=" Http://s2.51cto.com/wyfs02/M01/84/69/wKioL1eQN7OTo2npAADdSfY83Pg608.jpg-wh_500x0-wm_3 -wmp_4-s_1569780896.jpg "title=" 1.jpg "alt=" Wkiol1eqn7oto2npaaddsfy83pg608.jpg-wh_50 "/>
Below we simulate the destruction of a disk, to achieve hot-swappable functions
Mdadm--manage/dev/md0
--add Equipment #添加设备
--remove Equipment #删除设备
--fail Equipment #模拟损毁后面的设备
Mdadm--manage/dev/md0--fail/dev/sda9 #很显然9换下去了, 11 in exchange.
650) this.width=650; "Src=" Http://s4.51cto.com/wyfs02/M01/84/69/wKiom1eQOK-ihJM-AAJh3go4k8M514.jpg-wh_500x0-wm_3 -wmp_4-s_2984817790.jpg "title=" 1.jpg "alt=" Wkiom1eqok-ihjm-aajh3go4k8m514.jpg-wh_50 "/>
The following disk is removed from the error
Mdadm--manage/dev/md0--remove/dev/sda9
650) this.width=650; "Src=" Http://s4.51cto.com/wyfs02/M00/84/69/wKiom1eQOR_i8xG-AAKk4bRiigg804.jpg-wh_500x0-wm_3 -wmp_4-s_4070930374.jpg "title=" 1.jpg "alt=" Wkiom1eqor_i8xg-aakk4briigg804.jpg-wh_50 "/>
6. How to shut down the raid device correctly
Shut down the RAID device cannot simply delete its partition, must follow the steps, otherwise it will be a file system error
Umount/mnt/raid #先卸载
Sed-i "/^\/dev\/md0/d"/mnt/raid #如果设置了自动挂载, which line will be/mnt/raid deleted
Mdadm--stop/dev/md0 #关闭raid设备
Cat/proc/mdstat #确实不存在任何的数组设备
Vim/etc/mdadm.conf #将开头的ARRAY那一行注释掉.
650) this.width=650; "Src=" Http://s5.51cto.com/wyfs02/M01/84/6A/wKiom1eQOteiqEtQAADZWRgjES0215.jpg-wh_500x0-wm_3 -wmp_4-s_2949208208.jpg "title=" 1.jpg "alt=" Wkiom1eqoteiqetqaadzwrgjes0215.jpg-wh_50 "/>
This article is from the "thick Product Thin Hair" blog, please make sure to keep this source http://joedlut.blog.51cto.com/6570198/1828303
Linux Basic (19) software disk array raid