Linux software RAID (redundant array of disks)

Source: Internet
Author: User

I. LVM vs. RAID features
LVM for dynamic capacity expansion RAID supports dynamic capacity expansion
LVM does not support disk acceleration RAID supports disk acceleration
LVM does not support redundancy (data backup) RAID Support Redundancy
Second, RAID (redundant array of disks) (1) Hardware: Disk array card, disk array cabinet (2) Software: Mdadm, RAID level (1) RAID 0: More than two hard drives, usually even disk number, disk capacity of multiple disks and (Fatal disadvantage: Data without redundancy), improve disk i/ O (read, write), do not allow disk corruption (2) RAID 1: More than two hard drives, usually even disk number, disk capacity of more than half of the disk, improve the reliability of the data (Fatal disadvantage: Disk waste is serious), allow the disk to break half (3) RAID 5: Three hard drive above, Typically an odd number of disks, disk capacity of multiple disks-1, to improve some disk speed and redundancy effect (fatal disadvantage: Generate checksum when the additional computing resources), allow damage to a piece of hard disk (4) RAID 6: More than four hard drives, usually even disk, disk capacity of multiple disks-2, the equivalent of RAID 5 Increased disk speed and redundancy (allows damage to two disks) (5) RAID 1+0: Four hard drives above, usually even disk, disk capacity of more than half of the disk, combined with RAID 0+raid 1 features (6) RAID 5+0: Six disk above, generally even disk, Disk capacity of three disks per 1, combined with RAID 5+raid 0 features (7) RAID 6+0: Eight disks or more, typically even disks, with a disk capacity of every four disks-2, combined with RAID 6+raid 0 features

Note : when composing a raid, the average disk capacity is equal

Iv. RAID 5 Case: 1. View the disk devices in the system fdisk-l

2. Create a RAID using the command Mdadm

If not, install the MDADM software package first ( rpm -qa |grep mdadm )

Command parameters

-A  =  --assemble      //激活-S  =  --stop           //停止-D  =  --detail          //查看raid详细信息-C  =  -- create         //建立raid设备-v  =  --verbose        //显示建立过程的详细信息-l  =  --level            //raid的级别-n  =  --raid-devices    //raid设备数-s  =  --scan            //扫描raid设备-f  =  --fail              //标示坏的硬盘-a  =  --add             //添加硬盘-r  =  -remove           //移除坏的硬盘

Note : This package is available on RHEL CDs

3. Create a RAID5 array
mdadm --create --auto=yes /dev/md0 --level=5 --raid-devices=3 --spare-devices=1 /dev/sd[b-e]可以缩写为:mdadm –C –a yes /dev/md0 –l5 –n3 –x1 /dev/sd[b-e]

parameter explanation :

-create               //表示要创建raid--auto=yes /dev/md0    //是否自动检测,新建立的软件磁盘陈列设备为md0,md序号可以为0-9--level=5               //磁盘阵列的等级,这里是raid5-raid-devices           //所需使用的磁盘数量--spare-devices          //添加作为预备(spare)磁盘的块数/dev/sd[b-e]           //磁盘阵列所使用的设备,还可以写成“/dev/sdb /dev/sdc /dev/sdd /dev/sde”
4. Check to see if the raid was successfully created or not running properly
(1)查看详细信息:mdadm  - -detail  /dev/md0命令查看RAID的详细信息

(2)较为简单的查看:可以直接查看cat  /proc/mdstat的文件看到RAID运行的情况

5. Format and mount and use the raid created
mkfs.exe4  /dev/md0             //格式化   raid5磁盘为 md0

mkdir  /raid

mount  /dev/md0  /raid      //将md0 挂载到/raid目录下查看一下挂载情况
df  –hT

Try a new raid is not available, write files to it

6. Set boot auto-start raid and auto Mount

let raid boot, riad configuration file name mdadm.conf This file does not exist by default, it should be built by itself. The main function of this profile is to automatically load soft raid when the system is started, and to manage it later. Note the following mdadm.conf files are mainly composed of:


Note : If this file is not created after the next power-on reboot,/DEV/MD0 will be automatically recognized by the system as a non-/dev/md0 name device, which is inconvenient for booting and using.
(1) First build/etc/mdadm.conf this file

mdadm  --detail  --scan > /etc/mdadm.conf  //将raid信息导入配置文件

(2) to make a change to this file: Append the device name composed RAID5 to the configuration file

(3) Automatic mount of RAID set

vim  /etc/fstab     //修改挂载文件/dev/md0   /raid     ext4     defaults    0   0     //在文件中添加

7. Simulating disk corruption in the RAID5

(1) Verify the function of the spare disk (in the RAID5 to allow the damage of a disk, that is, we set the spare disk will immediately replace the broken disk for RAID reconstruction, to ensure data security)

mdadm  --manage  /dev/md0  --fail /dev/sdd  //使用此命令设置sdd成为出错的状态(或可简写为mdadm  /dev/md0  -f  /dev/sdd)

(2) Check the disk information: Mdadm--detail/dev/md0

(3) A simple look at the raid situation

(4) The completion of the creation means that RAID5 has been automatically restored! Check to see if RAID5 is working properly!
To create a new file to write data, it can be found that RAID5 can also be used normally, no impact on the data

Active  sync  /dev/sdb1   # raid的真成员spare  /dev/sdc1            #raid备用成员

(5) Re-add/DEV/SDD into RAID5, can do the following actions:

mdadm  /dev/md0  --remove  /dev/sdd      //将坏掉的磁盘sdd从raid中移除

mdadm  /dev/md0  -a  /dev/sdd             //将/dev/sdd加入阵列

(6) View status

mdadm  --zero-superblock  --force  /dev/sdd(可选)    //可修复硬盘将模拟损坏的硬盘重新添加

(7) Re-simulate damage to a hard drive, verify that the hard drive is still functional

(8) Check the drive status again

8. How to turn off raid

Uninstall the/dev/md0 directly and comment out the configuration in the/etc/fstab file

umount  /dev/md0                  //解除挂接

vim  /etc/fstab                     //将fstab里面的开机自动挂载注释掉#/dev/md0     /var/www/html     ext4     defaults         0   0

pe_zmfuz3pozw5nagvpdgk= "alt=" Linux software RAID (redundant array of disks) "/>

mdadm --stop /dev/md0           //停止md0磁盘服务

Linux software RAID (redundant array of disks)

Related Article

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: 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.