current position:Home>Yyds dry inventory creation of Linux dynamic disk (RAID5), expansion and contraction of capacity and explanation of various noun parameters, detailed explanation of commands

Yyds dry inventory creation of Linux dynamic disk (RAID5), expansion and contraction of capacity and explanation of various noun parameters, detailed explanation of commands

2022-01-27 03:26:25 Jr_ C

Manage dynamic disks


raid Concept It is called independent redundant disk array

It is a method that can manage disks in strips and redundancy


Banding :

Multiple hard disks can be accessed in parallel   This is a raid The biggest concept in

Parallelism is to access at the same time

Compared with a single hard disk, this can improve the efficiency of hard disk access  ( The minimum unit is divided into strips )


redundancy :

Different raid There are different redundancy technologies

raid1: Adopt mirror redundancy Two hard disks write the same data   Double reliability   The capacity is only 50%

raid5: Distributed parity redundancy It uses XOR algorithm The forward calculation and reverse calculation of this algorithm are reversible  

raid0: Data redundancy is not provided by default

raid10: First make the hard disk into several raid1 How many are you putting raid1 Make it raid10

raid50: and raid10 similar


raid5 redundancy

It consists of three hard disks , When writing the first data, first create a stripe on each hard disk , Three strips on three hard disks form a strip , Then it divides the written data into two binary numbers , Write the first data in the first stripe , Write the second data in the second sub bar , The XOR algorithm value of two data is written in the third sub strip , When writing the second data , Create a stripe on each hard disk , Then write the first data in the first stripe , The second sub bar is used to write the check value at this time , The third sub bar is used to write the second data , In this way, there is no verification value stored in any hard disk , In this way, the utilization rate of each hard disk can be similar , There will be no hot disk problem , When any hard disk fails, the data of the broken hard disk can be calculated from the data of the other two hard disks


Downgrade

When raid5 One of the hard disks is out of order Now raid5 It's in a degraded state   At this time, the efficiency of data access will be significantly reduced   Hard disk damage is called raid Downgrade


Capacity

raid5 The capacity is only n Divided n-1 n Is the number of hard disks

raid1 Capacity of 2 Divided n n Is the number of hard disks


Best hard disk configuration

raid5 8+1   Eight data disks and A calibration disk


Hot standby

When raid When one hard disk in the group fails The hot spare disk automatically replaces the failed disk


raid Group reconstruction

When the hot spare is replaced, the data on the damaged disk will be rechecked or transferred to the hot spare This process is called refactoring raid Group


invalid

When raid In the group meanwhile After the damaged hard disk exceeds the allowable number of damaged hard disks At this time raid The group is in a failed state Data can also be lost and unrecoverable  


collapse

When raid When the group is in the reconstruction state, another hard disk is damaged, so that the data cannot be reconstructed So you're in a state of collapse


raid Divided into soft raid And hard raid

soft raid More features However, it will occupy the resources of the server itself, resulting in a certain decline in performance

hard raid Does not affect server performance   But the function is relatively single And an additional payment of RMB


establish raid

First, divide each hard disk into a main partition Give all hard disk space to this partition   Do not format each partition Otherwise, the creation will fail

mdadm --create /dev/raid name --level=raid Level --raid-devices= Number of hard disks Hard disk name list     # When creating, you can set the strip size, strip size, etc Parameters can be found in the help file

  appear array /dev/raid name /started identification raid Create success


see raid Details

mdadm --detail /dev/raid name

  You can see raid size raid Which hard drives consist of Which hard disk fails Is there a hot spare Hot spare reconfiguration progress   Number of failed equipment   Number of working equipment   Status of each equipment  raid Alignment mode  chunk Size is the strip size, etc


To mount raid You also need to format it first


Hot spare add

mdadm --add /dev/raid name Hot spare name ( Is the name of the hard disk )

  Now go and check raid For details, you can see that the hot spare has been added to raid In the group


expand raid Number of hard disks in the Group

mdadm --grow /dev/raid name --raid-devices= Increased number of hard disks


Hot spare drift test

take raid An active disk in the group is set to a failed state

 mdadm /dev/raid name --fail /dev/ Invalid hard disk name

  Go to see raid For details, you will see that the hot spare has drifted into the active device list and is being reconstructed rebuild status For refactoring progress  state Status as degraded,recovering Refactoring state

Remove the failed disk from raid Delete in

 mdadm /dev/raid name --remove /dev/ Invalid hard disk name

Add a new hot spare



raid5 At least three disks are required

raid10 Can damage two hard disks Because of two parity checks  


raid10 Create method

mdadm –create –verbose /dev/md0 –level=10 –raid-devices=4 /dev/sd[bcde]1 –spare-devices=1 /dev/sdf1



mdadm –detail /dev/md0

The output of should be as follows :


Used Dev Size Indicates the capacity of each disk used by the array .


Array Size Represents the overall size of the array .RAID 10 The size of the array is determined by (N*C)/M Calculation , among N Is the number of active disks ,C Is the capacity of each active disk ,M Is the number of disks in each image . In the case of this article , This value is equal to (4*8GiB)/2 = 16GiB.


Layout Is the details of the entire data layout . Possible layout values are as follows .


 n( The default option ): On behalf of the nearest (near) Copy . Multiple copies of a data block have the same offset in different disks . This layout provides and RAID 0 The array has similar read and write performance .


 o Represents the offset (offset) Copy . Blocks are not copied in strips , But the whole strip is copied together , But the cycle will disrupt , Therefore, the copied blocks in the same partition will appear on different disks . therefore , Subsequent copies of a block will appear on the next disk , Block by block . In order to be in RAID 10 This layout is used in the array , Add... To the command to create an array --layout=o2 Options .


 f Represents the remote end (far) Copy ( Multiple copies have different offsets on different disks ). This layout provides better read performance but worse write performance . therefore , It's the best choice for systems that read far more than write . In order to be in RAID 10 This layout is used in the array , Add... To the command to create an array --layout=f2.


  Follow the layout options n、f and o The following number represents the number of copies of each data block required . The default value is 2, But it can be 2 To the number of disks in the array . Providing a sufficient number of copies can minimize the number of copies on a single disk I/O influence .

  Chunk Size, Reference resources Linux RAID wiki Explanation , Is the smallest data unit written to disk . The best chunk The size depends on I/O The rate of operations and the associated file size . For a large number of write operations , By setting a relatively large chunk You can get lower overhead , But for arrays that mainly store small files, it's smaller chunk Better performance . To give RAID 10 To specify a chunk size , Add... To the command to create an array --chunk=desiredchunksize.


Chunk Size, Reference resources Linux RAID wiki Explanation , Is the smallest data unit written to disk . The best chunk The size depends on I/O The rate of operations and the associated file size . For a large number of write operations , By setting a relatively large chunk You can get lower overhead , But for arrays that mainly store small files, it's smaller chunk Better performance . To give RAID 10 To specify a chunk size , Add... To the command to create an array --chunk=desiredchunksize.


file system : As a whole ,XFS It is said to be the best , Of course EXT4 It's also a good choice .


Best layout : Remote layout can improve reading performance , But it will reduce write performance .


Number of copies : More copies can be minimized I/O influence , But more disks cost more .


Hardware : In the same environment ,SSD Than traditional ( Mechanical rotation ) Disk can bring more performance improvement



copyright notice
author[Jr_ C],Please bring the original link to reprint, thank you.
https://en.cdmana.com/2022/01/202201270326116957.html

Random recommended