Article Directory
-
-
- RAID disk array
- Array card
- Steps to create a soft RAID disk array
-
RAID disk array
Introduction to RAID Disk Array
- RAID is Redundant Array of Independent Disks (Redundant Array of Independent Disks) referred to as disk array. The main thing is the concentration of resources and unified management.
- Combining multiple independent physical hard disks into a hard disk group in different ways can logically be regarded as a large hard disk, thereby providing higher storage performance than a single hard disk and providing data backup technology.
- The different ways of composing a disk array are called RAID Levels (RAID Levels)
- Common RAID levels:
RAID0, RAID1, RAID5, RAID6, RAID1+0, etc.
RAID0 (striped storage)
- Advantages: Has the highest storage performance among all RAID levels. The principle is to distribute continuous data to multiple disks for access, so that the system has data requests that can be executed by multiple disks in parallel, and each disk executes its own part of the data request. So the transmission rate is very fast
- Disadvantages: no backup function, poor reliability, when the data of a hard disk is lost, it will affect all the data, so there is no need for places with high application and data security requirements.
- Number of hard disks: at least 2.
RAID1 (mirrored storage)
- Advantages: It can ensure the availability and data security of user data to the greatest extent. Its main function is to automatically copy 100% of the data written by the user to the hard disk to another hard disk. Therefore, RAID1 has the highest data security guarantee and higher read performance among the RAID levels.
- Disadvantages: Due to the 100% backup of data, the backup data occupies half of the total storage space. Due to the low utilization of disk space, the storage cost is the highest among the RAID levels.
- Number of hard disks: at least 2.
RAID5 :
- Advantages: A storage solution that takes into account storage performance, data security, and storage cost. RAID 5 compares the backup method of RAID1. RAID5 backs up not the data itself, but stores the data and the corresponding parity data on each of the disks that make up RAID5. Therefore, when a disk of RAID5 is damaged, the remaining data can be used. Download the data and the corresponding check data to restore the damaged data, with high reliability.
- Disadvantages: Due to the verification mechanism, the writing ability is relatively low
RAID6
- Advantages: Similar to RAID5, except that the parity data has one more independent parity information block than RAID5, and the two parity data have different algorithms, which is more secure than RAID5.
- Disadvantages: poor write performance
RAID1+0 (mirroring first, then striping):
- Advantages: RAID1+0 is a solution that takes into account both storage performance and data security. While it provides the same data security guarantee as RAID1, it also provides storage performance similar to RAID0.
- Disadvantages: Since RAID1+0 also provides data security through 100% data backup, the disk space utilization of RAID 0+1 is the same as that of RAID1, and the storage cost is high.
RAID level | Number of hard drives | Disk utilization | Is there a check? | Protection ability | Read and write performance |
---|---|---|---|---|---|
RAID0 | N | 100% | no | no | N times of a single hard disk (best) |
RAID1 | N (even number) | 50% | no | Allow a device failure | There is no difference between reading and a single hard disk, but writing on both sides |
RAID5 | N>=3 | (N-1)/N | Have | Allow a device failure | Read and RAID0 are similar, write<single hard disk |
RAID6 | N>=4 | (N-2)/N | Have | Allow two device failures | Read and write are similar to RAID5, write<RAID5 |
RAID10 | N>=4 (even number) | 50% | no | Allow one of the two basis sets to be bad | Read=RAID0, write=RAID1 |
Array card
- Array card is a board used to realize RAID function
- Usually composed of a series of components such as I/O processor, hard disk controller, hard disk connector and cache
- Different RAID cards support different RAID functions.
For example: support RAID0, RAID1, RAID5, RAID10, etc. - RAID card interface type:
IDE interface, SCSI interface, SATA interface and SAS interface
Cache of array card
- Cache is the place where the RAID card exchanges data with the external bus. The RAID card first transmits the data to the cache, and then the cache exchanges data with the external data bus.
- The size and speed of the cache are important factors directly related to the actual transmission speed of the RAID card
- Different RAID cards are equipped with different memory capacities when they leave the factory, generally ranging from a few megabytes to hundreds of megabytes.
Steps to create a soft RAID disk array
Install four hard drives first
1. Check the command package
rpm -q mdadm
yum install -y mdadm
2. Use the fdisk tool to manage disks
Divide the new disk device into the primary partition and change the ID mark number of the partition type to "fd"
fdisk /dev/sdb (sdc,sdd,sde等)
#The other three hard drives are the same as the above steps
Finally, use the mdadm -E /dev/sd[be]1 command to check whether the disk has been RAID
3. Create a RAID device
(1) Create RAID5
mdadm -C -v /dev/md0 [-a yes] -l5 -n3 /dev/sd[bcd]1 -x1 /dev/sde1
-C:表示新建;
-v:显示创建过程中的详细信息。
/dev/md0:创建 RAID5 的名称。
-a yes:--auto,表示如果有什么设备文件没有存在的话就自动创建,可省略。
-l:指定 RAID 的级别,l5 表示创建 RAID5。
-n:指定使用几块硬盘创建 RAID,n3 表示使用 3 块硬盘创建 RAID。
/dev/sd[bcd]1:指定使用这四块磁盘分区去创建 RAID。
-x:指定使用几块硬盘做RAID的热备用盘,x1表示保留1块空闲的硬盘作备用
/dev/sde1:指定用作于备用的磁盘
Use the cat /proc/mdstat command to view the progress
Created successfully
(2) Create RAID10 (first mirror image, then stripe)
mdadm -Cv /dev/md0 -l1 -n2 /dev/sd[bc]1
mdadm -Cv /dev/md1 -l1 -n2 /dev/sd[de]1
mdadm -Cv /dev/md10 -l0 -n2 /dev/md0 /dev/md1
View RAID disk commands
cat /proc/mdstat #查看RAID磁盘详细信息和创建RAID的进度
mdadm -D /dev/md0 #查看RAID磁盘详细信息
watch -n 10 'cat /proc/mdstat' #用watch命令来每隔一段时间刷新 /proc/mdstat 的输出
mdadm -E /dev/sd[b-e]1 #检查磁盘是否已做RAID
4. Create and mount the file system
mkfs -t xfs /dev/md0
mkdir /myraid
mount /dev/md0 /myraid/
df -Th
cp /etc/fstab /etc/fstab.bak
vim /etc/fstab
/dev/md0 /myraid xfs defaults 0 0
Format the newly created RAID5
Create a mount point and mount the created md0 to the created mount point
5. Realize failure recovery
mdadm /dev/md0 -f /dev/sdb1 #模拟/dev/sdb1 故障
mdadm -D /dev/md0 #查看发现sde1已顶替sdb1
6. Create the /etc/mdadm.conf configuration file to facilitate the management of software RAID configuration, such as start and stop
echo 'DEVICE /dev/sdc1 /dev/sdb1 /dev/sdd1' > /etc/mdadm.conf
mdadm --detail --scan >> /etc/mdadm.conf
Other common options of mdadm command:
-r:移除设备
-a:添加设备
-S:停止RAID
-A:启动RAID
mdadm /dev/md0 -f /dev/sdb1
mdadm /dev/md0 -r /dev/sdb1
mdadm /dev/md0 -a /dev/sde1
echo 'DEVICE /dev/sdc1 /dev/sdb1 /dev/sdd1' > /etc/mdadm.conf
mdadm --detail --scan >> /etc/mdadm.conf
umount /dev/md0
mdadm -s /dev / md0
mdadm -As / dev/ md0
#一s:指查找letc/ mdadm. conf 文件中的配置信息
Need to close the original mount point first, otherwise it won’t stop
After restarting, rebuild RAID5
The reconstruction is successful and it can be used normally again