Create soft RAID 1 under CentOS6.5

Source: Internet
Author: User
Tags hex code

Create soft RAID 1 under CentOS6.5
What is RAID?

RAID, Redundant Array of Independent Disks, formerly known as Redundant Array of Inexpensive Disks, is short for hard disk arrays. The basic idea is to combine multiple relatively inexpensive hard disks into a hard disk array group, so that the performance can reach or even exceed a hard disk with a high price and huge capacity. Depending on the selected version, RAID has the following advantages over a single hard disk: Enhanced Data Integration, enhanced fault tolerance, and increased processing capacity or capacity. In addition, the disk array looks like a separate hard disk or logical storage unit for a computer. It can be divided into RAID 0, RAID 1, RAID 1E, RAID 5, RAID 6, RAID 7, RAID 10, RAID 50, and RAID 60.

To put it simply, RAID combines multiple hard disks into one logical sector. Therefore, the operating system only treats them as one hard disk. RAID is often used on server computers, and identical hard disks are often used as a combination. As Hard Disk prices continue to decline and RAID functions are more effectively integrated with the motherboard, it has become a choice for players, especially those who need large storage space, such as video and audio production.

The initial RAID is divided into different levels, each of which has its own theoretical advantages and disadvantages. Different Levels strike a balance between the two targets, increasing data reliability and increasing storage (group) read/write performance. Over the years, applications with different RAID concepts have emerged.

How to Create a soft RAID

If you want to create a RAID, you must have a disk array card. Currently, most servers have such hardware, which is easy to create. It is a silly operation, but it will certainly be different between different vendors, but they are all similar. But today we want to discuss how to create a soft RAID without a disk array card. Let's take a look.

Preparation
  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 1*512 = 512 bytes
  6. Sector size (logical/physical): 512 bytes/512 bytes
  7. I/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 1*512 = 512 bytes
  13. Sector size (logical/physical): 512 bytes/512 bytes
  14. I/O size (minimum/optimal): 512 bytes/512 bytes
  15. Disk identifier: 0x00000000
Start

To demonstrate this, I created two 2G hard disks in the virtual machine. We can see that they are sdb and sdc respectively. We can build these two hard disks into a soft RAID 1. The operation is as follows:

  1. Fdisk/dev/sdb
  2.  
  3. Command (m for help): n # Enter n and press Enter.
  4. Command action
  5. E extended
  6. P primary partition (1-4)
  7. P # Enter p and press Enter.
  8. Partition number (1-4): 1 # Enter 1 and press ENTER
  9. First cylinder (1-261, default1): # Press ENTER
  10. Usingdefault value 1
  11. Last cylinder, + cylinders or + size {K, M, G} (1-261, default261): # Press ENTER
  12. Usingdefault value 261
  13.  
  14. Command (m for help): t # input t, press ENTER
  15. Selected partition 1
  16. Hex code (type L to list codes): fd # Enter fd and press ENTER
  17. Changed system type of partition 1 to fd (Linux raid autodetect)
  18.  
  19. Command (m for help): w # input w, save and release
  20. The partition table has been altered!
  21.  
  22. Calling ioctl () to re-read partition table.
  23. Syncing disks.

Now sdb is changed to a raid hard disk. You can use fdisk-cul to check whether sdc works the same way.

  1. Fdisk-cul
  2. DeviceBootStartEndBlocksIdSystem
  3. /Dev/sdb1 12612096451 fd Linux raid autodetect
  4. /Dev/sdc1 12612096451 fd Linux raid autodetect
  5.  
  6. # If you directly add a hard disk to the server, you need to execute a command
  7. Partprobe-
  8. # In this way, you do not need to restart the server and add the new hard disk to the battle.
Create RAID

The next step is simple. You only need to build and format the two hard disks through the mdadm Command Group and then mount them to a specific directory. The operation is as follows:

  1. # Check the parameters of this command before performing the operation.
  2. -C # create a software RAID
  3. -L # specify the RAID level
  4. -N # specify the number of disks
  5. -X # specify the number of slave devices
  6.  
  7. Mdadm-C/dev/md1-l 1-n 2/dev/sdb1/dev/sdc1
  8. Mdadm: array/dev/md1 started. # prompt that you have 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. CreationTime: WedNov1216: 19: 532014 # Creation Time
  16. RaidLevel: raid1 # RAID level
  17. ArraySize: 2095360 (2046.59MiB2145.65 MB) # size of the RAID Disk
  18. UsedDevSize: 2095360 (2046.59MiB2145.65 MB)
  19. RaidDevices: 2 # Number of disks
  20. TotalDevices: 2
  21. Persistence: Superblockis persistent
  22.  
  23. UpdateTime: WedNov1217: 19: 042014.
  24. State: clean
  25. ActiveDevices: 2 # Number of active Disks
  26. WorkingDevices: 2 # Number of working Disks
  27. FailedDevices: 0 # Number of disks with errors
  28. SpareDevices: 0 # Number of spare disks
  29.  
  30. Name: server1: 1 (local to host server1)
  31. UUID: ae9a70dd: dc2917a7: de515e04: f82950a7
  32. Events: 21
  33.  
  34. NumberMajorMinorRaidDeviceState
  35. 08170 active sync/dev/sdb1
  36. 18331 active sync/dev/sdc1
Format and Mount
  1. Mkfs. ext4/dev/md1 # format as ext4
  2. Mkdir/raid1 # create the directory to be mounted
  3. Mount/dev/md1/raid1 # mount
  4.  
  5. # Set the device of the disk array to automatically mount the device when it is started
  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, done, and finished!

How to build a RAID 10 array on Linux

Debian soft RAID Installation notes-use mdadm to install RAID1

Common RAID technology introduction and demo (Multi-chart)

The most common disk array in Linux-RAID 5

RAID0 + 1 and RAID5 Performance Test Results

Getting started with Linux: disk array (RAID)

This article permanently updates the link address:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.