Create soft RAID1 under CentOS6.5
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
- 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
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:
- Fdisk / dev / sdb
- Command ( m for help ): n # enter n, enter
- Command action
- E extended
- p primary partition ( 1 – 4 )
- p #Enter p, enter
- Partition number ( 1 – 4 ): 1 #Enter 1, enter
- First cylinder ( 1 – 261 , default 1 ): #回车
- Using default value 1
- Last cylinder , + cylinders or + size { K , M , G } ( 1 – 261 , default 261 ): #回回
- Using default value 261
- Command ( m for help ): t #Enter t, enter
- Selected partition 1
- Hex code ( type L to list codes ): fd #入fd, enter
- Changed system type of partition 1 to fd ( Linux raid autodetect )
- Command ( m for help ): w #Enter w, save and launch
- The partition table has been altered !
- Calling ioctl () to re – read partition table .
- 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.
- Fdisk – cul
- Device Boot Start End Blocks Id System
- / dev / sdb1 1 261 2096451 fd Linux raid autodetect
- / dev / sdc1 1 261 2096451 fd Linux raid autodetect
- #If you are adding a hard disk directly on the server, you also need to execute a command.
- Partprobe – a
- #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:
- #Please take a look at the parameters of this command before the operation
- – C #Create Software RAID
- – l #Specify the RAID level
- – n # specifies the number of disks
- – x # specifies the number of spare devices
- Mdadm – C / dev / md1 – l 1 – n 2 / dev / sdb1 / dev / sdc1
- Mdadm : array / dev / md1 started . #提示你Created successfully
- #View the md1 device details just created
- Mdadm — detail / dev / md1
- / dev / md1 :
- Version : 1.2
- Creation Time : Wed Nov 12 16 : 19 : 53 2014 #Create time
- Raid Level : raid1 #RAID level
- Array Size : 2095360 ( 2046.59 MiB 2145.65 MB ) #RAID How much is the disk space?
- Used Dev Size : 2095360 ( 2046.59 MiB 2145.65 MB )
- Raid Devices : 2 #Number of disks
- Total Devices : 2
- Persistence : Superblock is persistent
- Update Time : Wed Nov 12 17 : 19 : 04 2014
- State : clean
- Active Devices : 2 #Number of active disks
- Working Devices : 2 #Number of disks in operation
- Failed Devices : 0 #Number of disks with errors
- Spare Devices : 0 #iPod spares
- Name : server1 : 1 ( local to host server1 )
- UUID : ae9a70dd : dc2917a7 : de515e04 : f82950a7
- Events : 21
- Number Major Minor RaidDevice State
- 0 8 17 0 active sync / dev / sdb1
- 1 8 33 1 active sync / dev / sdc1
Formatting and mounting
- Mkfs . ext4 / dev / md1 #Formatted to ext4 format
- Mkdir / raid1 #Create a directory to be mounted
- Mount / dev / MD1 / RAID1 # mount
- # Then set the device of the disk array to boot automatically.
- 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, get it, and get it done!
Comment disabled