CentOS6.5 create soft RAID

Source: Internet
Author: User
Tags hex code

CentOS6.5 create soft RAID
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. Disk/dev/sdb: 2147 MB, 2147483648 bytes
  3. 255 heads, 63 sectors/track, 261 cylinders, total 4194304 sectors
  4. Units = sectors of 1*512 = 512 bytes
  5. Sector size (logical/physical): 512 bytes/512 bytes
  6. I/O size (minimum/optimal): 512 bytes/512 bytes
  7. Disk identifier: 0x00000000
  8. Disk/dev/sdc: 2147 MB, 2147483648 bytes
  9. 255 heads, 63 sectors/track, 261 cylinders, total 4194304 sectors
  10. Units = sectors of 1*512 = 512 bytes
  11. Sector size (logical/physical): 512 bytes/512 bytes
  12. I/O size (minimum/optimal): 512 bytes/512 bytes
  13. 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. Command (m for help): n # Enter n and press Enter.
  3. Command action
  4. E extended
  5. P primary partition (1-4)
  6. P # Enter p and press Enter.
  7. Partition number (1-4): 1 # Enter 1 and press ENTER
  8. First cylinder (1-261, default 1): # Press ENTER
  9. Using default value 1
  10. Last cylinder, + cylinders or + size {K, M, G} (1-261, default 261): # Press ENTER
  11. Using default value 261
  12. Command (m for help): t # input t, press ENTER
  13. Selected partition 1
  14. Hex code (type L to list codes): fd # Enter fd and press ENTER
  15. Changed system type of partition 1 to fd (Linux raid autodetect)
  16. Command (m for help): w # input w, save and release
  17. The partition table has been altered!
  18. Calling ioctl () to re-read partition table.
  19. 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. 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. # If you directly add a hard disk to the server, you need to execute a command
  6. Partprobe-
  7. # 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. Mdadm-C/dev/md1-l 1-n 2/dev/sdb1/dev/sdc1
  7. Mdadm: array/dev/md1 started. # prompt that you have created successfully
  8. # View the md1 device details just created
  9. Mdadm -- detail/dev/md1
  10. /Dev/md1:
  11. Version: 1.2
  12. Creation Time: Wed Nov 12 16:19:53 2014 # Creation Time
  13. Raid Level: RAID 1 # Raid Level
  14. Array Size: 2095360 (2046.59 MiB 2145.65 MB) # Size of RAID disk space
  15. Used Dev Size: 2095360 (2046.59 MiB 2145.65 MB)
  16. Raid Devices: 2 # Number of disks
  17. Total Devices: 2
  18. Persistence: Superblock is persistent
  19. Update Time: Wed Nov 12 17:19:04 2014
  20. State: clean
  21. Active Devices: 2 # Number of Active Disks
  22. Working Devices: 2 # Number of Working Disks
  23. Failed Devices: 0 # Number of disks with errors
  24. Spare Devices: 0 # Number of Spare disks
  25. Name: server1: 1 (local to host server1)
  26. UUID: ae9a70dd: dc2917a7: de515e04: f82950a7
  27. Events: 21
  28. Number Major Minor RaidDevice State
  29. 0 8 17 0 active sync/dev/sdb1
  30. 1 8 33 1 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. # Set the device of the disk array to automatically mount the device when it is started
  5. Echo "DEVICE/dev/sdb1/dev/sdc1">/etc/mdadm. conf
  6. Mdadm-Evs>/etc/mdadm. conf
  7. Echo "/dev/md1/raid1 ext4 defaults 0 0">/etc/fstab

At this point, all the work is done, done, and finished!

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.