Server hardware and RAID configuration in Linux (including RAID5 practical operation!)

Server hardware and RAID configuration in Linux

1. RAID disk array

1. Introduction to RAID Disk Array

  • It is the abbreviation of Redundant Array of Independent Disks, Chinese abbreviated as Redundant Array of Independent Disks

  • Combine 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 of composing a disk array are called RAID Levels (RAID Levels)

  • Commonly used RAlD levels

    RAID0, RAID1, RAID5, RAID6, RAID1 + 0, etc.

Insert picture description here

1) RAID 0 (striped storage)

  1. RAID 0 continuously divides data in units of bits or bytes, and reads/writes them on multiple disks in parallel, so it has a high data transfer rate, but it has no data redundancy.

  2. RAID 0 simply improves performance, and does not provide a guarantee for data reliability, and one of the disk failures will affect all data

  3. RAID 0 cannot be used in occasions with high data security requirements

    N hard disks are combined into a new logical disk in parallel, 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. This parallel operation on data can make full use of the bandwidth of the bus and significantly improve the overall disk access performance.
    Insert picture description here

2) RAID 1 (mirrored storage)

  1. Realize data redundancy through disk data mirroring, and generate mutually backup data on a pair of independent disks

  2. When the original data is busy, the data can be read directly from the mirror copy, so RAID 1 can improve the read performance

  3. RAID 1 has 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 read and write on the mirror disk without reorganizing the failed data.

    Insert picture description here

3) RAID 5 (the most used in the current production environment, more important)

  1. N (N≥3) disks form an array. One piece of data generates N-1 stripes, and there is also a piece of check data. A total of N pieces of data are stored cyclically and evenly on N disks.

  2. 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

  3. (N-1)/N Disk utilization

  4. High reliability, allowing one disk to be broken without affecting all data

    RAID5 data writing will be divided into 3 parts according to the algorithm, and then written to these 3 hard disks. When writing, the verification information will be written on these 3 hard disks. When reading the written data, it will start from 3 respectively. Read the data content on the block hard disk, and then verify it by checking the information. When one of the hard disks is damaged, the data content of the third hard disk can be calculated from the data stored on the other two hard disks. That is to say, the storage method of raid5 only allows one hard disk to fail, and it needs to be replaced as soon as possible when it fails. When the failed hard disk is replaced, the data written during the failure will be re-verified. If one block is broken after an unresolved failure, it will be catastrophic. (P stands for calibration data)
    Insert picture description here

4) RAID 6 (two disks write parity data)

  1. N (N≥4) disks form an array, (N-2)/N disk utilization

  2. Compared with RAID 5, RAID 6 adds a second independent block of parity information

  3. Two independent parity systems use different algorithms, even if two disks fail at the same time, it will not affect the use of data

  4. Compared with RAID 5, there is greater "write loss", so the write performance is poor

Insert picture description here

5) RAID 1+0 (Mirror image first, then stripe)

  1. After N (even number, N>=4) disks are mirrored in pairs, they are combined into a RAID 0

  2. N/2 disk utilization

  3. N/2 disks write at the same time, N disks read at the same time

  4. High performance and high reliability

Insert picture description here

6) RAID 0+1 (stripe first, then mirror image)

  1. N (even number, N>=4) After the disks are striped in pairs, they are combined into a RAID 1
  2. The read and write performance is the same as RAID 10
  3. Security is lower than RAID 10

Insert picture description here

7) Comparison of RAID0, RAID1, RAID5, RAID6

RAID level Number of hard drives Disk utilization Is there a check? Protection ability Write performance
RAID0 N N no no N times of a single hard drive
RAID1 N (even number) N/2 no Allow a device failure Need to write two pairs of storage devices, each as a backup
RAID5 N≥3 (N-1)N Have Allow a device failure Need to write calculation check
RAID6 N≥4(even number) N/2 no Allow one for each of the two basis sets Simultaneous writing of N/2 disks

2. Introduction to 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,
    such as RAID0, RAID1, RAID5, RAID10, etc.
  • RAID card interface type
    IDE interface, SCSI interface, SATA interface and SAS interface

3. Build a soft RAID disk array (RAID5)

1. Check the creation environment first

That is, check whether the mdadm package has been installed

Insert picture description here

2. New hard drive

You need to close the virtual machine first, then edit the virtual machine, select add, add hard disks (use the default values ​​except for the capacity selection), after adding 4 hard disks, you can see that there are four more hard disks under the hardware, and then "OK". Turn on the virtual machine and use Xshell to connect to the virtual machine.

Insert picture description here

3. Use fdisk -l to view the disk partition

Insert picture description here

4. Partition management

Change all 4 disk partition types to RAID, the following is one, and the other 3 have the same operation

Insert picture description here

5. View the partition type

Insert picture description here

Insert picture description here

6. Create RAID5

Use cat /proc/mdstat to view the progress of RAID5 creation

Insert picture description here

7. View RAID details

Insert picture description here

8. Simulate a disk damage

Test whether the spare disk will be rebuilt automatically

Insert picture description here

9. Must format and mount before use

Like LVM before, the steps that must be passed to use

Insert picture description here

Four, mdadm command

1. Command format

mdadm [选项] [操作磁盘对象]

2. Common options and functions

Options used in creating RAID5

-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 (level5) means to create RAID5

-n: Specify how many hard disks to create RAID, n3 means to use 3 hard disks to create RAID

/dev/sd [bcd]1: Specify these three disk partitions to create RAID as the active device

-x: Specify how many hard disks to use as a hot spare disk for RAID, x1 means to reserve 1 free hard disk as a spare dev/sde1: Specify a disk to be used as a spare

other options

-r: remove device

-a: add device

-S: Stop RAID

-A: Start RAID

Example:

mdadm -S /dev/md0 #停止运行此RAID

mdadm /dev/md0 -r /dev/sdb1 #从此RAID中移除磁盘/dev/sdb1

supplement:

If you create RAID 10, you need to do mirroring and then striping

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 details

cat /proc/mdstat  #此命令还能查看RAID创建进度

mdadm -D /dev/md0 #展示RAID详细信息

Check whether the disk has been RAID

mdadm -E /dev/sd[b-e]1

Guess you like

Origin blog.csdn.net/qq_35456705/article/details/110595020