1 什么是RAID
RAID全稱是獨立磁盤冗余陣列(Redundant Array of Independent Disks),基本思想是把多個磁盤組合起來,組合一個磁盤陣列組,使得性能大幅提高。
RAID分為幾個不同的等級,各個不同的等級均在數據可靠性及讀寫性能做了不同的權衡。實際工作中根據自己的業務需求選擇不同的RAID方案。
2 RAID的實現方式
外接式磁盤陣列:通過擴展卡提供適配能力內接式RAID:主板集成RAID控制器安裝OS前在BIOS里配置軟件RAID:通過OS實現
3 標準的RAID
3.1 RAID0
RAID0稱為條帶化存儲,將數據分段存儲在各個磁盤中,讀寫均可以并行處理,因此讀寫速率為單個磁盤的N倍,沒有冗余功能,任何一個磁盤的損壞就會導致的數據不可用。

3.2 RAID1
RADI1是鏡像存儲,沒有數據校驗,數據被同等的寫入到2個或者多個磁盤中,寫入速度相對慢, 但是讀取速度比較快。

3.3 RAID 4
RADI4在RAID1的基礎上,N個盤用于數據存儲,另外加入了1個磁盤作為校驗盤。一共N+1個盤,任何一個盤壞掉也不影響數據的訪問
3.4 RAID 5
RAID5在RAID4的基礎上,由原來的一個盤來存儲校驗數據,改為每個盤都有數據和校驗信息的。

4 混合RAID
4.1 RAID01
先組成RAID0,然后組成RAID1.

4.2 RAID10
先組成RAID1,然后組成RAID0

5 軟RAID的實現
5.1 RAID5的實現
創建由三塊硬盤組成的可用空間為2G的RAID5設備,要求其chunk大小為256k,文件系統為ext4,開機可自動掛載至/mydata目錄
5.1.1 先看看我們的磁盤情況
[root@centos7 Bash]$ lsblkNAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTsda 8:0 0 200G 0 disk ├─sda1 8:1 0 1G 0 part /boot├─sda2 8:2 0 128G 0 part ├─sda3 8:3 0 48.8G 0 part /├─sda4 8:4 0 512B 0 part └─sda5 8:5 0 19.5G 0 part /appsdb 8:16 0 100G 0 disk sdc 8:32 0 20G 0 disk sdd 8:48 0 20G 0 disk sde 8:64 0 20G 0 disk sdf 8:80 0 20G 0 disk sr0 11:0 1 8.1G 0 rom /run/media/root/CentOS 7 x86_64
這里我們使用sdb,sdc,sdd,每個盤創建一個主分區1G,構建RADI5.
5.1.2 根據實際情況分區
[root@centos7 Bash]$ fdisk /dev/sdbWelcome to fdisk (util-linux 2.23.2).Changes will remain in memory only, until you decide to write them.Be careful before using the write command.Device does not contain a recognized partition tableBuilding a new DOS disklabel with disk identifier 0x93d380cf.Command (m for help): nPartition type: p primary (0 primary, 0 extended, 4 free) e extendedSelect (default p): pPartition number (1-4, default 1): First sector (2048-209715199, default 2048): Using default value 2048Last sector, +sectors or +size{K,M,G} (2048-209715199, default 209715199): +1GPartition 1 of type Linux and of size 1 GiB is setCommand (m for help): tSelected partition 1Hex code (type L to list all codes): fdChanged type of partition 'Linux' to 'Linux raid autodetect'Command (m for help): pDisk /dev/sdb: 107.4 GB, 107374182400 bytes, 209715200 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk label type: dosDisk identifier: 0x93d380cf Device Boot Start  End Blocks Id System/dev/sdb1  2048 2099199 1048576 fd Linux raid autodetectCommand (m for help): wThe partition table has been altered!Calling ioctl() to re-read partition table.Syncing disks.[root@centos7 Bash]$ fdisk /dev/sdcWelcome to fdisk (util-linux 2.23.2).Changes will remain in memory only, until you decide to write them.Be careful before using the write command.Device does not contain a recognized partition tableBuilding a new DOS disklabel with disk identifier 0xc56b90d8.Command (m for help): nPartition type: p primary (0 primary, 0 extended, 4 free) e extendedSelect (default p): pPartition number (1-4, default 1): First sector (2048-41943039, default 2048): Using default value 2048Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039): +1GPartition 1 of type Linux and of size 1 GiB is setCommand (m for help): tSelected partition 1Hex code (type L to list all codes): fdChanged type of partition 'Linux' to 'Linux raid autodetect'Command (m for help): pDisk /dev/sdc: 21.5 GB, 21474836480 bytes, 41943040 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk label type: dosDisk identifier: 0xc56b90d8 Device Boot Start  End Blocks Id System/dev/sdc1  2048 2099199 1048576 fd Linux raid autodetectCommand (m for help): wThe partition table has been altered!Calling ioctl() to re-read partition table.Syncing disks.[root@centos7 Bash]$ fdisk /dev/sddWelcome to fdisk (util-linux 2.23.2).Changes will remain in memory only, until you decide to write them.Be careful before using the write command.Device does not contain a recognized partition tableBuilding a new DOS disklabel with disk identifier 0x7e0900d8.Command (m for help): nPartition type: p primary (0 primary, 0 extended, 4 free) e extendedSelect (default p): pPartition number (1-4, default 1): First sector (2048-41943039, default 2048): Using default value 2048Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039): +1GPartition 1 of type Linux and of size 1 GiB is setCommand (m for help): pDisk /dev/sdd: 21.5 GB, 21474836480 bytes, 41943040 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk label type: dosDisk identifier: 0x7e0900d8 Device Boot Start  End Blocks Id System/dev/sdd1  2048 2099199 1048576 83 LinuxCommand (m for help): tSelected partition 1Hex code (type L to list all codes): fdChanged type of partition 'Linux' to 'Linux raid autodetect'Command (m for help): wThe partition table has been altered!Calling ioctl() to re-read partition table.Syncing disks.
新聞熱點
疑難解答