RAID
- RAID disk array
- Array card
-
- Cache of array card
- Steps to create a soft RAID disk array
-
- Check if the mdadm package is installed
- Use the fdisk tool to divide the new disk devices /dev/sdb, /dev/sdc, /dev/sdd, /dev/sde into primary partitions sdb1, sdc1, sdd1, sde1, and change the ID mark number of the partition type to "fd "
- Create RAID device (RAID5 or RAID10)
- Create and mount file system
- Achieve failure recovery
- Create the /etc/mdadm.conf configuration file
RAID disk array
RAID (Redundant Array of Independent Disks) is a combination of multiple independent physical hard disks in different ways to form a hard disk group (logical hard disk), thereby providing higher storage performance than a single hard disk and providing data backup technology
The different ways to promote disk arrays are called RAID levels. Commonly used RAID levels are: RAID0, RAID1, RAID5, RAID6, RAID1+0, etc.
RAID0 (striped storage)
RAID 0 continuously divides data in units of bits or bytes, and reads/writes to multiple disks in parallel, so it has a high data transfer rate, but it has no data redundancy
RAID 0 simply improves performance, and does not provide a guarantee for data reliability, and one of the disk failures will affect all data
RAID 0 cannot be used in occasions with high data security requirements
RAID1 (mirrored storage)
Realize data redundancy through disk data mirroring, and generate mutually backup data on a pair of independent disks
When the original data is busy, the data can be read directly from the mirror copy, so RAID 1 can improve the read performance
RAID 1 is the highest unit cost in the disk array, but it provides high data security and availability. When a disk fails, the system can automatically switch to the mirror disk for reading and writing, without the need to reorganize the failed data
RAID5
N (N>=3) disks form an array, one piece of data generates N-1 stripes, and one copy of parity data. A total of N pieces of data are cyclically and evenly stored on N disks.
N disks read and write at the same time, the read performance is very high, but due to the problem of the verification mechanism, the write performance is relatively low
(N-1)/N Disk utilization
High reliability, allowing one disk to be damaged without affecting all data
RAID6
N (N>=4) disks form an array
(N-2)/N Disk utilization
Compared with RAID 5, RAID 6 adds a second independent parity information block
Two independent parity systems use different algorithms, even if two disks fail at the same time, it will not affect the use of data
Compared with RAID 5, there is greater "write loss", so the write performance is poor
RAID1+0 and RAID0+1
RAID1+0 (mirroring first, then striping)
After N (even number, N>=4) disks are mirrored in pairs, they are combined into a RAID 0
N/2 disk utilization
N/2 disks write at the same time, N disks read at the same time
High performance and high reliability
RAID0+1 (stripe first, then mirror)
The read and write performance is the same as RAID10
Safety performance is lower than RAID10
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 RAlD0, RAID1, RAID5, RAID10, etc.
RAID card interface type
IDE interface, SCSI interface, SATA interface and SAS interface
Cache of array card
The RAID card first transfers the data to the cache, and then exchanges data between the cache and 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
Check if the mdadm package is installed
rpm -q mdadm
yum install -y mdadm
Use the fdisk tool to divide the new disk devices /dev/sdb, /dev/sdc, /dev/sdd, /dev/sde into primary partitions sdb1, sdc1, sdd1, sde1, and change the ID mark number of the partition type to "fd "
fdisk /dev/sdb
fdisk /dev/sdc
Create RAID device (RAID5 or RAID10)
#创建RAID5
mdadm -C -v /dev/md0 [-a yes] -l5 -n3 /dev/sd[bcd]1 -x1 /dev/sde1
-C: means new
-v: display detailed information during the creation process
/dev/md0: Create the name of RAID5
-a yes: -auto, which means that if any device file does not exist, it will be created automatically, which can be omitted
-l: Specify the level of RAID, l5 means to create RAID5
-n: Specify to use several hard disks to create RAID, n3 means to use 3 hard disks to create RAID
/dev/sd[bcd]1: Specify these four disk partitions to create RAID
-x: Specify how many hard disks to use as hot spare disks for RAID, x1 means to reserve 1 free hard disk as a spare
/dev/sde1: designated as a spare disk
#创建RAID10(先做镜象,再做条带)
mdadm -Cv /dev/md0 -l1 -n2 /dev/sd[bc]1
mdadm -Cv /dev/md1 -l1 -n2 /dev/sd[bc]1
mdadm -Cv /dev/md10 -l0 -n2 /dev/md0 /dev/md1
#查看RAID磁盘详细信息
cat /proc/mdstat #还能查看创建RAID的进度
或者
mdadm -D /dev/md0
#检查磁盘是否已做RAID
mdadm -E /dev/sd[b-e]1
Create and mount 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
Achieve failure recovery
mdadm /dev/md0 -f /dev/sdb1 #模拟/dev/sdb1 故障
mdadm -D /dev/md0 #查看发现sde1已顶替sdb1
Other common options of mdadm command
-r: remove device
-a: add device
-S: Stop RAID
-A: Start RAID
Command example
mdadm -S /dev/md0
Create the /etc/mdadm.conf configuration file
Convenient to manage the configuration of software RAID, such as start and stop
echo ‘DEVICE /dev/sdc1/dev/sdb1/dev/sdd1’ > /etc/mdadm.conf
mdadm --detail --scan >> /etc/mdadm.conf