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
- Yum install-y parted mdadm
View disk usage
- Fdisk-cul
-
- Disk/dev/sdb: 2147 MB, 2147483648 bytes
- 255 heads, 63 sectors/track, 261 cylinders, total 4194304 sectors
- Units = sectors of 1*512 = 512 bytes
- Sector size (logical/physical): 512 bytes/512 bytes
- I/O size (minimum/optimal): 512 bytes/512 bytes
- Disk identifier: 0x00000000
-
- Disk/dev/sdc: 2147 MB, 2147483648 bytes
- 255 heads, 63 sectors/track, 261 cylinders, total 4194304 sectors
- Units = sectors of 1*512 = 512 bytes
- Sector size (logical/physical): 512 bytes/512 bytes
- I/O size (minimum/optimal): 512 bytes/512 bytes
- 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:
- Fdisk/dev/sdb
-
- Command (m for help): n # Enter n and press Enter.
- Command action
- E extended
- P primary partition (1-4)
- P # Enter p and press Enter.
- Partition number (1-4): 1 # Enter 1 and press ENTER
- First cylinder (1-261, default1): # Press ENTER
- Usingdefault value 1
- Last cylinder, + cylinders or + size {K, M, G} (1-261, default261): # Press ENTER
- Usingdefault value 261
-
- Command (m for help): t # input t, press ENTER
- Selected partition 1
- Hex code (type L to list codes): fd # Enter fd and press ENTER
- Changed system type of partition 1 to fd (Linux raid autodetect)
-
- Command (m for help): w # input w, save and release
- The partition table has been altered!
-
- Calling ioctl () to re-read partition table.
- Syncing disks.
Now sdb is changed to a raid hard disk. You can use fdisk-cul to check whether sdc works the same way.
- Fdisk-cul
- DeviceBootStartEndBlocksIdSystem
- /Dev/sdb1 12612096451 fd Linux raid autodetect
- /Dev/sdc1 12612096451 fd Linux raid autodetect
-
- # If you directly add a hard disk to the server, you need to execute a command
- Partprobe-
- # 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:
- # Check the parameters of this command before performing the operation.
- -C # create a software RAID
- -L # specify the RAID level
- -N # specify the number of disks
- -X # specify the number of slave devices
-
- Mdadm-C/dev/md1-l 1-n 2/dev/sdb1/dev/sdc1
- Mdadm: array/dev/md1 started. # prompt that you have created successfully
-
- # View the md1 device details just created
- Mdadm -- detail/dev/md1
-
- /Dev/md1:
- Version: 1.2
- CreationTime: WedNov1216: 19: 532014 # Creation Time
- RaidLevel: raid1 # RAID level
- ArraySize: 2095360 (2046.59MiB2145.65 MB) # size of the RAID Disk
- UsedDevSize: 2095360 (2046.59MiB2145.65 MB)
- RaidDevices: 2 # Number of disks
- TotalDevices: 2
- Persistence: Superblockis persistent
-
- UpdateTime: WedNov1217: 19: 042014.
- State: clean
- ActiveDevices: 2 # Number of active Disks
- WorkingDevices: 2 # Number of working Disks
- FailedDevices: 0 # Number of disks with errors
- SpareDevices: 0 # Number of spare disks
-
- Name: server1: 1 (local to host server1)
- UUID: ae9a70dd: dc2917a7: de515e04: f82950a7
- Events: 21
-
- NumberMajorMinorRaidDeviceState
- 08170 active sync/dev/sdb1
- 18331 active sync/dev/sdc1
Format and Mount
- Mkfs. ext4/dev/md1 # format as ext4
- Mkdir/raid1 # create the directory to be mounted
- Mount/dev/md1/raid1 # mount
-
- # Set the device of the disk array to automatically mount the device when it is started
- Echo "DEVICE/dev/sdb1/dev/sdc1">/etc/mdadm. conf
- Mdadm-Evs>/etc/mdadm. conf
- 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: