1.准备4块磁盘
[root@localhost ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 20G 0 disk
├─sda1 8:1 0 1G 0 part /boot
└─sda2 8:2 0 19G 0 part
├─centos-root 253:0 0 17G 0 lvm /
└─centos-swap 253:1 0 2G 0 lvm [SWAP]
sdb 8:16 0 2G 0 disk
└─sdb1 8:17 0 400M 0 part /mnt/disk1
sdc 8:32 0 2G 0 disk
sdd 8:48 0 2G 0 disk
sde 8:64 0 2G 0 disk
sdf 8:80 0 2G 0 disk
sdg 8:96 0 2G 0 disk
我们用sdc\sdd\sde\sdf做raid5磁盘阵列
2.查找并安装raid工具
[root@localhost ~]# yum provides *bin/mdadm
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
mdadm-4.1-1.el7.x86_64 : The mdadm program controls Linux md devices (software RAID
: arrays)
源 :base
匹配来源:
文件名 :/usr/sbin/mdadm
[root@localhost ~]# yum -y install mdadm.x86_64
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
base | 3.6 kB 00:00:00
extras | 2.9 kB 00:00:00
nginx-stable | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
正在解决依赖关系
--> 正在检查事务
---> 软件包 mdadm.x86_64.0.4.1-1.el7 将被 安装
--> 正在处理依赖关系 libreport-filesystem,它被软件包 mdadm-4.1-1.el7.x86_64 需要
--> 正在检查事务
---> 软件包 libreport-filesystem.x86_64.0.2.1.11-43.el7.centos 将被 安装
--> 解决依赖关系完成
依赖关系解决
==========================================================================================
Package 架构 版本 源 大小
==========================================================================================
正在安装:
mdadm x86_64 4.1-1.el7 base 435 k
为依赖而安装:
libreport-filesystem x86_64 2.1.11-43.el7.centos base 40 k
事务概要
==========================================================================================
安装 1 软件包 (+1 依赖软件包)
总下载量:475 k
安装大小:1.0 M
Downloading packages:
(1/2): libreport-filesystem-2.1.11-43.el7.centos.x86_64.rpm | 40 kB 00:00:00
(2/2): mdadm-4.1-1.el7.x86_64.rpm | 435 kB 00:00:00
------------------------------------------------------------------------------------------
总计 1.6 MB/s | 475 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在安装 : libreport-filesystem-2.1.11-43.el7.centos.x86_64 1/2
正在安装 : mdadm-4.1-1.el7.x86_64 2/2
验证中 : mdadm-4.1-1.el7.x86_64 1/2
验证中 : libreport-filesystem-2.1.11-43.el7.centos.x86_64 2/2
已安装:
mdadm.x86_64 0:4.1-1.el7
作为依赖被安装:
libreport-filesystem.x86_64 0:2.1.11-43.el7.centos
3.创建raid5磁盘阵列,并查看
[root@localhost ~]# mdadm -C /dev/md0 -l5 -n3 -x1 /dev/sd{c,d,e,f}
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md0 started.
[root@localhost ~]# mdadm -D /dev/md0
/dev/md0:
Version : 1.2
Creation Time : Fri Apr 10 08:45:40 2020
Raid Level : raid5
Array Size : 4188160 (3.99 GiB 4.29 GB)
Used Dev Size : 2094080 (2045.00 MiB 2144.34 MB)
Raid Devices : 3
Total Devices : 4
Persistence : Superblock is persistent
Update Time : Fri Apr 10 08:45:44 2020
State : clean, degraded, recovering
Active Devices : 2
Working Devices : 4
Failed Devices : 0
Spare Devices : 2
Layout : left-symmetric
Chunk Size : 512K
Consistency Policy : resync
Rebuild Status : 42% complete
Name : localhost.localdomain:0 (local to host localhost.localdomain)
UUID : 118b7f20:1a49da7e:83552678:5cbe76c6
Events : 7
Number Major Minor RaidDevice State
0 8 32 0 active sync /dev/sdc
1 8 48 1 active sync /dev/sdd
4 8 64 2 spare rebuilding /dev/sde
3 8 80 - spare /dev/sdf
4.格式化并挂载到/mnt/
[root@localhost ~]# mkfs.ext4 /dev/md0
mke2fs 1.42.9 (28-Dec-2013)
文件系统标签=
OS type: Linux
块大小=4096 (log=2)
分块大小=4096 (log=2)
Stride=128 blocks, Stripe width=256 blocks
262144 inodes, 1047040 blocks
52352 blocks (5.00%) reserved for the super user
第一个数据块=0
Maximum filesystem blocks=1073741824
32 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736
Allocating group tables: 完成
正在写入inode表: 完成
Creating journal (16384 blocks): 完成
Writing superblocks and filesystem accounting information: 完成
[root@localhost ~]# mkdir /mnt/raid5
[root@localhost ~]# mount /dev/md0 /mnt/raid5/
再次查看磁盘阵列信息:
[root@localhost ~]# mdadm -D /dev/md0
/dev/md0:
Version : 1.2
Creation Time : Fri Apr 10 08:45:40 2020
Raid Level : raid5
Array Size : 4188160 (3.99 GiB 4.29 GB)
Used Dev Size : 2094080 (2045.00 MiB 2144.34 MB)
Raid Devices : 3
Total Devices : 4
Persistence : Superblock is persistent
Update Time : Fri Apr 10 08:59:58 2020
State : clean
Active Devices : 3
Working Devices : 4
Failed Devices : 0
Spare Devices : 1
Layout : left-symmetric
Chunk Size : 512K
Consistency Policy : resync
Name : localhost.localdomain:0 (local to host localhost.localdomain)
UUID : 118b7f20:1a49da7e:83552678:5cbe76c6
Events : 18
Number Major Minor RaidDevice State
0 8 32 0 active sync /dev/sdc
1 8 48 1 active sync /dev/sdd
4 8 64 2 active sync /dev/sde
3 8 80 - spare /dev/sdf
创建成功