Linux-based server hardware and RAID configuration (a simple understanding)

One, RAID disk array

1. Introduction to RAID Disk Array

  • RAID is Redundant Array of Independent Disks (Redundant Array of Independent Disks) for short. 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 to form a disk array are called RAID Levels (RAID Levels)
  • Commonly used RAID levels
    RAID0, RAID1, RAID5, RAID6, RAID1+0, etc.

2. Commonly used RAID levels

1) RAID0 (striped storage)

  • Advantages: Has the highest storage performance among all RAID levels. The principle is to disperse continuous data to multiple disks for access, so that data requests in the system 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 a hard disk data is lost, it will affect all data, so there is no need for places with high requirements for application and data security.
    Insert picture description here

2) RAID1 (mirrored storage)

  • Advantages: It can guarantee 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 100% data backup, 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.
    Insert picture description here

RAID5 :

  • Advantages: A storage solution that balances storage performance, data security and storage costs. RAID 5 compares RAID1 backup method. RAID5 backups not the data itself, but stores the data and the corresponding parity data on each disk that composes RAID5, so when a disk data 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 check mechanism problem, the writing ability is relatively low.
    Insert picture description here
    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
    Insert picture description here
    RAID1+0 (mirroring first, then striping):
  • Advantages: RAID1+0 is a solution for both storage performance and data security. While it provides the same data security as RAID1, it also provides storage performance similar to RAID0.
  • Disadvantages: As RAID1+0 also provides data security through 100% data backup, the disk space utilization of RAID 0+1 is the same as RAID1, and the storage cost is high.

Insert picture description here
Comparison of various levels

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

2. Array card (for understanding only)

1. 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
    Insert picture description here

2. 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 at the factory, generally ranging from several megabytes to hundreds of megabytes

Three, create a soft RAID disk array

Create a demo in the next blog: Linux Technical Document: Create RAID5 and RAID10 Disk Arrays

1. Check the command package

rpm -q mdadm
yum install -y mdadm

2. Use fdisk tool to manage disk

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, etc.)

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:指定用作于备用的磁盘

2) Create RAID10 (mirror first, 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

3) View RAID disk commands

cat /proc/mdstat		 #查看RAID磁盘详细信息和创建RAID的进度
mdadm -D /dev/md0        #查看RAID磁盘详细信息

mdadm -E /dev/sd[b-e]1   #检查磁盘是否已做RAID

4. Create and mount a 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

5. Realize failure recovery

mdadm /dev/md0 -f /dev/sdb1 		#模拟/dev/sdb1 故障
mdadm -D /dev/md0					#查看发现sde1已顶替sdb1


mdadm命令其它常用选项
-r:移除设备
-a:添加设备
-S:停止RAID
-A:启动RAID

Guess you like

Origin blog.csdn.net/weixin_51326240/article/details/110138545