[root@RHEL7 ~]# date
Fri Aug 19 21:55:01 CST 2016
准备3个盘
[root@RHEL7 ~]# fdisk /dev/sdb
[root@RHEL7 ~]# fdisk /dev/sdc
[root@RHEL7 ~]# fdisk /dev/sdd
[root@RHEL7 ~]# mdadm -C -v /dev/md5 -l 5 -n 3 /dev/sdb1 /dev/sdc1 /dev/sdd1
mdadm: layout defaults to left-symmetric
mdadm: layout defaults to left-symmetric
mdadm: chunk size defaults to 512K
mdadm: /dev/sdc appears to be part of a raid array:
level=raid0 devices=0 ctime=Thu Jan 1 08:00:00 1970
mdadm: partition table exists on /dev/sdc but will be lost or
meaningless after creating array
mdadm: size set to 5237248K
Continue creating array? y
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md5 started.
[root@RHEL7 ~]# mdadm -C -v /dev/md5 -l 5 -n 3 -x 1 /dev/sdb1 /dev/sdc1 /dev/sdd1
-x 指定热备盘数量
[root@RHEL7 ~]# mdadm -D /dev/md5
/dev/md5:
Version : 1.2
Creation Time : Fri Aug 19 21:06:32 2016
Raid Level : raid5
Array Size : 10474496 (9.99 GiB 10.73 GB)
Used Dev Size : 5237248 (4.99 GiB 5.36 GB)
Raid Devices : 3
Total Devices : 3
Persistence : Superblock is persistent
Update Time : Fri Aug 19 21:06:59 2016
State : clean
Active Devices : 3
Working Devices : 3
Failed Devices : 0
Spare Devices : 0
Layout : left-symmetric
Chunk Size : 512K
Name : RHEL7.2:5 (local to host RHEL7.2)
UUID : 34f81bee:05f28fb2:a45ff119:930b98cc
Events : 18
Number Major Minor RaidDevice State
0 8 17 0 active sync /dev/sdb1
1 8 32 1 active sync /dev/sdc1
3 8 49 2 active sync /dev/sdd1
创建配置文件
[root@RHEL7 raid5]# mdadm -Dsv
ARRAY /dev/md5 level=raid5 num-devices=3 metadata=1.2 name=RHEL7.2:5 UUID=34f81bee:05f28fb2:a45ff119:930b98cc
devices=/dev/sdb1,/dev/sdc,/dev/sdd1
[root@RHEL7 raid5]# mdadm -Dsv >> /etc/mdadm.conf
[root@RHEL7 ~]# mkfs -t xfs /dev/md5
log stripe unit (524288 bytes) is too large (maximum is 256KiB)
log stripe unit adjusted to 32KiB
meta-data=/dev/md5 isize=256 agcount=16, agsize=163712 blks
= sectsz=512 attr=2, projid32bit=1
= crc=0
data = bsize=4096 blocks=2618624, imaxpct=25
= sunit=128 swidth=256 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=0
log =internal log bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=8 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
创建文件系统挂载测试
[root@RHEL7 ~]# mkdir /raid5
[root@RHEL7 ~]# mount /dev/md5 /raid5/
[root@RHEL7 ~]# mount /dev/md5 /raid5/
[root@RHEL7 ~]# cd /raid5/
[root@RHEL7 raid5]# ls
[root@RHEL7 raid5]# dd if=/dev/zero of=aa bs=2M count=200
200+0 records in
200+0 records out
419430400 bytes (419 MB) copied, 4.18005 s, 100 MB/s
[root@RHEL7 raid5]# df /raid5
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/md5 10464256 442912 10021344 5% /raid5
[root@RHEL7 raid5]# du /raid5
409600 /raid5
开机自动挂载
[root@RHEL7 raid5]# echo "/dev/md5 /raid5 xfs defaults 0 0" >> /etc/fstab
[root@RHEL7 raid5]# tail -1 /etc/fstab
/dev/md5 /raid5 xfs defaults 0 0
清除磁盘信息再添加到RAID里去
[root@RHEL7 ~]# umount /dev/md5
[root@RHEL7 ~]# mdadm -S /dev/md5
mdadm: stopped /dev/md5
[root@RHEL7 ~]# mdadm --zero-superblock /dev/sdb1
[root@RHEL7 ~]# mdadm /dev/md5 --add /dev/sdb1
[root@RHEL7 ~]# mdadm -As
mdadm: /dev/md5 assembled from 1 drive - not enough to start the array.
[root@RHEL7 ~]#删除配置文件后清除RAID
[root@RHEL7 ~]# mdadm -rf /etc/mdadm.conf
RAID10:两种方法,
四块盘直接做RAID10,,第二种先做RAID1,再做RAID0
[root@RHEL7 ~]# mdadm -C -v /dev/md10 -l 10 -n 4 /dev/sdb1 /dev/sdc1 /dev/sdd1 /dev/sde1
mdadm: layout defaults to n2
mdadm: layout defaults to n2
mdadm: chunk size defaults to 512K
mdadm: size set to 3142144K
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md10 started.
[root@RHEL7 ~]# cat /dev/md10
^C[root@RHEL7 ~]# cat /proc/mdstat
Personalities : [raid10]
md10 : active raid10 sde1[3] sdd1[2] sdc1[1] sdb1[0]
6284288 blocks super 1.2 512K chunks 2 near-copies [4/4] [UUUU]
unused devices: <none>
本文转自 OpenStack2015 51CTO博客,原文链接:http://blog.51cto.com/andyliu/1840449,如需转载请自行联系原作者