What is RAID?

Redundant Array of Independent Disks (RAID), formerly known as Redundant Array of Inexpensive Disks. The basic idea is to combine multiple relatively inexpensive hard drives into a hard disk array group to achieve performance even more than an expensive hard drive. Depending on the version chosen, RAID has one or more of the following benefits over a single hard drive: enhanced data integration, enhanced fault tolerance, increased throughput or capacity. In addition, the disk array looks like a separate hard disk or logical storage unit for the computer. Divided into RAID 0, RAID 1, RAID 1E, RAID 5, RAID 6, RAID 7, RAID 10, RAID 50, RAID 60.

Simply put, RAID combines multiple hard disks into one logical sector, so the operating system only treats it as a hard disk. RAID is often used on server computers and often uses the same hard drive as a combination. As hard drive prices continue to fall and RAID functions are more effectively integrated with the motherboard, it has also become an option for players, especially those that require large amounts of storage space, such as video and audio production.

The original RAID was divided into different levels. Each level had its theoretical advantages and disadvantages. Different levels were balanced between the two targets, which were to increase data reliability and increase memory (group) read and write performance. Over the years, there have been applications for different RAID concepts.

How to create a soft RAID

Want to create RAID, certainly indispensable to the disk array card, and now most of the servers have this kind of hardware, it is also very simple to create, fool-like operation, but there will be some differences between different vendors, but they are similar. But today we are going to discuss how to create a soft RAID without a disk array card. Let’s take a look now.

ready

  1. Yum install – y parted mdadm

View disk usage

  1. Fdisk – cul
  2.  
  3. Disk dev sdb 2147 MB 2147483648 bytes
  4. 255 heads , 63 sectors / track , 261 cylinders , total 4194304 sectors
  5. Units sectors of 512 512 bytes
  6. Sector size logical physical ): 512 bytes 512 bytes
  7. O size minimum optimal ): 512 bytes 512 bytes
  8. Disk identifier 0x00000000
  9.  
  10. Disk dev sdc 2147 MB 2147483648 bytes
  11. 255 heads , 63 sectors / track , 261 cylinders , total 4194304 sectors
  12. Units sectors of 512 512 bytes
  13. Sector size logical physical ): 512 bytes 512 bytes
  14. O size minimum optimal ): 512 bytes 512 bytes
  15. Disk identifier 0x00000000

Start

For demonstration, I created two 2G hard disks in the virtual machine. I can see that they are sdb and sdc respectively. Make these two hard disk groups into a soft RAID1. The operation is as follows:

  1. Fdisk dev sdb
  2.  
  3. Command for help ): # enter n, enter
  4. Command action
  5. E extended
  6. p primary partition – )
  7. #Enter p, enter
  8. Partition number – ): 1 #Enter 1, enter
  9. First cylinder – 261 default ): #回车
  10. Using default value 1
  11. Last cylinder , + cylinders or size – 261 default 261 ): #回回
  12. Using default value 261
  13.  
  14. Command for help ): #Enter t, enter
  15. Selected partition 1
  16. Hex code type L to list codes ): fd #入fd, enter
  17. Changed system type of partition to fd Linux raid autodetect )
  18.  
  19. Command for help ): #Enter w, save and launch
  20. The partition table has been altered !
  21.  
  22. Calling ioctl () to re – read partition table .
  23. Syncing disks .

Now sdb becomes a raid-type hard disk, which can be viewed by fdisk-cul. The operation of sdc is the same as above, and the demonstration is not repeated.

  1. Fdisk – cul
  2. Device Boot Start End Blocks Id System
  3. dev sdb1 1 261 2096451 fd Linux raid autodetect
  4. dev sdc1 1 261 2096451 fd Linux raid autodetect
  5.  
  6. #If you are adding a hard disk directly on the server, you also need to execute a command.
  7. Partprobe – a
  8. #This way you don’t need to restart the server and let the new hard drive join the battle.

Create RAID

The next thing to do is simple. Just put the two hard disks into the raid1 and format them through the mdadm command group, and then mount them to a specific directory. The operation is as follows:

  1. #Please take a look at the parameters of this command before the operation
  2. – #Create Software RAID
  3. – #Specify the RAID level
  4. – # specifies the number of disks
  5. – # specifies the number of spare devices
  6.  
  7. Mdadm – dev md1 – 1 – n 2 / dev / sdb1 / dev / sdc1
  8. Mdadm array dev md1 started #提示你Created successfully
  9.  
  10. #View the md1 device details just created
  11. Mdadm — detail dev md1
  12.  
  13. dev md1 :
  14. Version 1.2
  15. Creation Time Wed Nov 12 16 19 53 2014 #Create time
  16. Raid Level raid1 #RAID level
  17. Array Size 2095360 2046.59 MiB 2145.65 MB #RAID How much is the disk space?
  18. Used Dev Size 2095360 2046.59 MiB 2145.65 MB )
  19. Raid Devices #Number of disks
  20. Total Devices 2
  21. Persistence Superblock is persistent
  22.  
  23. Update Time Wed Nov 12 17 19 04 2014
  24. State clean
  25. Active Devices #Number of active disks
  26. Working Devices 2 #Number of disks in operation
  27. Failed Devices 0 #Number of disks with errors
  28. Spare Devices 0 #iPod spares
  29.  
  30. Name server1 local to host server1 )
  31. UUID ae9a70dd dc2917a7 de515e04 f82950a7
  32. Events 21
  33.  
  34. Number Major Minor RaidDevice State
  35. 0 8 17 0 active sync dev sdb1
  36. 1 8 33 1 active sync dev sdc1

Formatting and mounting

  1. Mkfs ext4 dev md1 #Formatted to ext4 format
  2. Mkdir raid1 #Create a directory to be mounted
  3. Mount dev MD1 RAID1 # mount
  4.  
  5. # Then set the device of the disk array to boot automatically.
  6. Echo “DEVICE /dev/sdb1 /dev/sdc1” /etc/ mdadm conf
  7. mdadm – Evs >> / etc / mdadm conf
  8. Echo “/dev/md1 /raid1 ext4 defaults 0 0” >> /etc/ fstab

At this point, all the work is done, get it, and get it done!