RAID disk array in Linux

1. Disk array (Redundant Arrays of Independent Disks, RAID) means “a redundant array of independent disks”.

A disk array is composed of many cheaper disks, combined into one in the form of hardware (RAID card) or software (MDADM) A large-capacity disk group uses multiple disks to combine to improve the performance of the entire disk system. Using this technology, the data is cut into many sections and stored on each hard disk. Disk arrays can also use the concept of Parity Check. When any hard disk in the array fails, the data can still be read out.
Note: RAID can prevent data loss, but it does not completely guarantee that your data will not be lost, so it is important to pay attention to backup while using RAID Data.

2. RAID creation method

There are two ways to create RAID: soft RAID (implemented by operating system software) and hard RAID (using hardware array cards); understand raid1, raid5, and raid10 . However, with the rapid development of cloud, vendors can generally solve hardware problems.

Three. Features of RAID disk array

High-speed access to disks (speed up): RAID combines ordinary hard disks into a disk array. When the host writes data, the RAID controller divides the data to be written by the host into multiple data blocks, and then writes them to the disk array in parallel; when the host reads data, the RAID controller reads the data scattered on each hard disk in the disk array in parallel. Data, reassemble them and provide them to the host. Due to the use of parallel read and write operations, the access speed of the storage system is improved.
Expansion.
Data redundancy

four. RAID type

raid level: raid 0 raid 1 raid5 raide 10 raid 01

< span style="font-size: 18px;">RAID 0

0:(stripe) strip mode , At least two hard disks are required, and each piece of data is evenly divided into multiple pieces and stored in multiple disks, and they are all in a horizontal strip

Advantages: The speed of reading and writing is improved, and the number of disks used is as many times as many timesDisadvantages : No redundancy (also called fault tolerance) Space utilization: the sum of multiple disks, 100% p>

share picture

RAID 1

1: (mirror) mirror mode, the number of disks needs to be a multiple of 2, and the data stored in the two disks are exactly the same. When one disk is damaged, the data can still be read and written

Pros: redundant ability

Disadvantages: Disk utilization The rate is only 50%, and the writing speed drops< /p>

share picture

RAID 5

5:check code check code mode, at least three hard disks are required, and each time data is stored, use strip mode to save Save to Among the n-1 disks, the other disk stores the encrypted data obtained after the data in the other disks are encrypted in a certain way, and every time it is stored, the disk storing the encrypted data is constantly changing. When the data of any one of the disks is damaged, the data of the other disk can be known through encryption and the data of the other two disks, which has a high redundancy capability

Advantages: fast reading and writing speed, redundant ability

Disadvantages: The disk utilization is n-1/n. When two disks are damaged, the data will be Lost

share picture

Combined useRAID10

10:mirror+stripe mode, at least 4 fast hard disks are required. First, two hard disks are combined into Raid1 , And then combine the two groups of Raid1 into Raid0, when storing one point of data, the data stored in each Raid1 combination is equally divided, and then the Raid1 combination is stored in mirror mode

Advantages: fast reading and writing speed, strong redundancy

Disadvantages: Disk utilization is 50%

share picture

< p>Combined with RAID01

RAID01 is striped and then mirrored. The essence is to mirror the physical disk

Advantages: fast read and write speed, redundant Strong spare capacity

Disadvantages: Disk utilization rate is 50%, security performance is worse than 10

< p>share picture p>

Compare:

Share a picture

Comparison of RAID10 and RAID01

The most important difference between the two is that the bottom layer of RAID10 is mirroring RAID1, and mirroring ensures that when a hard disk such as A1 is damaged, it does not affect its write function, and the read performance may be slightly reduced (about 1/8). But the bottom layer of RAID01 is striped RAID0, and striping causes as long as one hard disk such as A1 in Disk0 on the left is damaged, then the entire left RAID0 cannot be used, so the entire RAID01 becomes only the right RAID0 It can be used, that is, when RAID01 is changed to RAID0, the read performance is immediately reduced in general, the write performance is not affected, and the reliability becomes the worst. With this alone, we should never use RAID01, but choose RAID10

V. RAID command

Command: mdadm (download required)
#Function: Create/manage/delete disk arrays
#Syntax format:
mdadm [mode] [option]
#Mode:

 assemble: will A previously defined array is added to the currently used array.
  create: Create a new array, each device has a super block
  manage: Manage arrays, such as adding or removing
  misc: Allows to perform operations on a device in the array alone, such as erasing the super block or terminating the array in use.
  follow or Monitor: monitor the status of the disk array
  grow: Change the capacity of the disk array or the number of devices in the array

  

Options:

 -A: Add a previously defined array
 -C: Create a new array (important)
 -D: Print detailed information of one or more devices
 -E: Print the contents of the super block on the device
 -h: Help information, after using the above options, the option information will be displayed
 -v: display details
 -b: Less details. Used for -D and -E options
 -f, --force enforce
 -c: Specify the configuration file, the default is /etc/mdadm.conf
 -s: Scan configuration files or /proc/mdstat to search for missing information.

  

Options used for create or build:

 -c: Specify the block size, the unit is kb. The default is 64 .
 -l,: Set the RAID mode. (Very important)
 -n=: Specify the number of devices available in the array.
 -x: Specify the number of hot spare disks in the initial array.
 -a, --auto{=no,yes,md,mdp,part,p}{NN}: Whether to create a device while creating a RAID.

  

Example: Use sdb sdc to create raid0
< span style="font-size: 18px;">mdadm -C /dev/md0 -l 0 -n 2 /dev/sd{b,c}1
raid view method

cat /proc/mdstat mdadm --detail /dev/mdXXX

  

Delete the raid (You need to uninstall the corresponding hanger before deleting the raid Loading point)

mdadm - stop /dev/mdXXXX

High speed to disk Access (speed up): RAID composes ordinary hard disks into a disk array. When data is written on the host, the RAID controller divides the data to be written by the host into multiple data blocks, and then writes them to the disk array in parallel; when the host reads data , RAID controller reads the data scattered on each hard disk in the disk array in parallel, reassembles them and provides it to the host. Due to the use of parallel read and write operations, the access speed of the storage system is improved.
Expansion.
Data redundancy

 assemble: change the previous A defined array is added to the currently used array.
  create: Create a new array, each device has a super block
  manage: Manage arrays, such as adding or removing
  misc: Allows to perform operations on a device in the array alone, such as erasing the super block or terminating the array in use.
  follow or Monitor: monitor the status of the disk array
  grow: Change the capacity of the disk array or the number of devices in the array

 -A: Add a previous definition Array of
 -C: Create a new array (important)
 -D: Print detailed information of one or more devices
 -E: Print the contents of the super block on the device
 -h: Help information, after using the above options, the option information will be displayed
 -v: display details
 -b: Less details. Used for -D and -E options
 -f, --force enforce
 -c: Specify the configuration file, the default is /etc/mdadm.conf
 -s: Scan configuration files or /proc/mdstat to search for missing information.

 -c: Specify the block size, The unit is kb. The default is 64.
 -l,: Set the RAID mode. (Very important)
 -n=: Specify the number of devices available in the array.
 -x: Specify the number of hot spare disks in the initial array.
 -a, --auto{=no,yes,md,mdp,part,p}{NN}: Whether to create a device while creating a RAID.

cat /proc/mdstat mdadm --detail /dev/mdXXX

  

cat /proc/mdstat mdadm --detail /dev/mdXXX

mdadm --stop /dev/ mdXXXX

Leave a Comment

Your email address will not be published.