[root@centos7 mnt]$ mdadm --zero-superblock /dev/sd{b1,e1,d1,c1} # 清空设置上的超级块信息
5.2 RAID10的实现
raid10 ,6个分区,2个一组raid1,3组raid0
5.2.1 案例分析
分析下,我们创建一个raid10设置,2个设备组成一个raid1,6个设备2个一组可以组成3个raid1, 然后把3个raid1组成一个raid0即可
5.2.2 先创建6个设备
[root@centos7 mnt]$ lsblk # 就是使用fdisk 创建的设备, 具体这里就不写了。 最终使用lsblk显示,我们可以看到sdb1,sdb2,sdd1,sde1一共6个磁盘
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 200G 0 disk
├─sda1 8:1 0 1G 0 part /boot
├─sda2 8:2 0 128G 0 part
├─sda3 8:3 0 48.8G 0 part /
├─sda4 8:4 0 512B 0 part
└─sda5 8:5 0 19.5G 0 part /app
sdb 8:16 0 100G 0 disk
├─sdb1 8:17 0 1G 0 part
└─sdb2 8:18 0 1G 0 part
sdc 8:32 0 20G 0 disk
├─sdc1 8:33 0 1G 0 part
└─sdc2 8:34 0 1G 0 part
sdd 8:48 0 20G 0 disk
└─sdd1 8:49 0 1G 0 part
sde 8:64 0 20G 0 disk
└─sde1 8:65 0 1G 0 part
sdf 8:80 0 20G 0 disk
sr0 11:0 1 8.1G 0 rom /run/media/root/CentOS 7 x86_64
5.2.3 创建raid
[root@centos7 mnt]$ mdadm -C /dev/md11 -a yes -l 1 -n 2 /dev/sd{b1,c1} # 创建第一个raid1
mdadm: /dev/sdb1 appears to be part of a raid array:
level=raid5 devices=3 ctime=Wed Dec 6 19:28:22 2017
mdadm: Note: this array has metadata at the start and
may not be suitable as a boot device. If you plan to
store '/boot' on this device please ensure that
your boot-loader understands md/v1.x metadata, or use
--metadata=0.90
mdadm: /dev/sdc1 appears to be part of a raid array:
level=raid5 devices=3 ctime=Wed Dec 6 19:28:22 2017
Continue creating array? y
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md11 started.
[root@centos7 mnt]$ mdadm -C /dev/md12 -a yes -l 1 -n 2 /dev/sd{b2,c2} #创建第二个raid1
mdadm: Note: this array has metadata at the start and
may not be suitable as a boot device. If you plan to
store '/boot' on this device please ensure that
your boot-loader understands md/v1.x metadata, or use
--metadata=0.90
Continue creating array? y
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md12 started.
[root@centos7 mnt]$ mdadm -C /dev/md13 -a yes -l 1 -n 2 /dev/sd{d1,e1} # 创建第三个raid1
mdadm: /dev/sdd1 appears to be part of a raid array:
level=raid5 devices=3 ctime=Wed Dec 6 19:28:22 2017
mdadm: Note: this array has metadata at the start and
may not be suitable as a boot device. If you plan to
store '/boot' on this device please ensure that
your boot-loader understands md/v1.x metadata, or use
--metadata=0.90
mdadm: /dev/sde1 appears to be part of a raid array:
level=raid5 devices=3 ctime=Wed Dec 6 19:28:22 2017
Continue creating array? y
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md13 started.
[root@centos7 mnt]$ mdadm -C /dev/md10 -a yes -l 0 -n 3 /dev/md{11,12,13} # 将3个raid1 合并为一个raid0
mdadm: /dev/md11 appears to contain an ext2fs file system
size=2095104K mtime=Wed Dec 6 19:29:45 2017
mdadm: /dev/md13 appears to contain an ext2fs file system
size=2095104K mtime=Wed Dec 6 19:29:45 2017
Continue creating array? y
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md10 started.
[root@centos7 mnt]$ mkfs.ext
mkfs.ext2 mkfs.ext3 mkfs.ext4
[root@centos7 mnt]$ mkfs.ext4 /dev/md10 # 创建文件系统
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=128 blocks, Stripe width=384 blocks
196224 inodes, 784896 blocks
39244 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=805306368
24 block groups
32768 blocks per group, 32768 fragments per group
8176 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912
Allocating group tables: done
Writing inode tables: done
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done
[root@centos7 mnt]$ mdadm -Ds # 查看配置信息
ARRAY /dev/md11 metadata=1.2 name=centos7.magedu.com:11 UUID=0ce2cd6c:cd21fab6:3e65cfb5:64bd86f3
ARRAY /dev/md12 metadata=1.2 name=centos7.magedu.com:12 UUID=8af31dff:efab06ed:48e2613b:a599c774
ARRAY /dev/md13 metadata=1.2 name=centos7.magedu.com:13 UUID=a8c99d60:2d0c61e7:97a76809:9396c020
ARRAY /dev/md10 metadata=1.2 name=centos7.magedu.com:10 UUID=50b2fa58:4ce65d67:8c50c853:fa175a28
[root@centos7 mnt]$ mdadm -Ds >> /etc/mdadm.conf # 写配置文件到mdadm的配置文件中
[root@centos7 mnt]$ mkdir /mnt/md10 # 创建挂载目录
[root@centos7 mnt]$ mount /dev/md10 /mnt/md10 # 挂载文件系统
[root@centos7 mnt]$ tail -n 1 /etc/mtab # 查看mtab文件中的最后一行, 也就是我们的md10挂载信息
/dev/md10 /mnt/md10 ext4 rw,seclabel,relatime,stripe=384,data=ordered 0 0
[root@centos7 mnt]$ tail -n 1 /etc/mtab >> /etc/fstab #添加到开机启动