RAID0实现
RAID1实现
RAID5实现
RAID1+0实现
RAID0+1实现
总结:
创建磁盘阵列
1、这里我们演示创建RAID5,由于RAID5需要N>=3所以我们要创建4块新的硬盘,并将文件格式改为fd
/dev/sdb1 2048 41943039 20970496 fd Linux raid autodetect
/dev/sdc1 2048 41943039 20970496 fd Linux raid autodetect
/dev/sde1 2048 41943039 20970496 fd Linux raid autodetect
/dev/sdd1 2048 41943039 20970496 fd Linux raid autodetect
2、创建RAID5,输入命令
mdadm -C -v /dev/md0 -l5 -n3 /dev/sd[bcd]1 -x1 /dev/sde1
-C :表示新建
-v :显示创建过程详细信息
/dev/md0 :表示创建RAID5的名称
-l5 :表示RAID的级别,l5表示RAID5
-n3 :表示几块硬盘创建,n3指三块硬盘
/dev/sd[bcd]1 :/dev/sd [bcd]1: 指定使用这3块磁盘分区去创建RAID
x1 :指定使用几块硬盘做RAID的热备用盘,x1表示保留1块空闲的硬盘作备用
/dev/sde1 :指定用作于备用的磁盘
3、格式化磁盘并查看RAID详细信息
输入格式化命令
[root@localhost ~]# mkfs.xfs /dev/md0
meta-data=/dev/md0 isize=512 agcount=16, agsize=654720 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0, sparse=0
data = bsize=4096 blocks=10475520, imaxpct=25
= sunit=128 swidth=256 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal log bsize=4096 blocks=5120, version=2
= sectsz=512 sunit=8 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
输入命令查看RAID详细信息
[root@localhost ~]# mdadm -D /dev/md0
/dev/md0:
Version : 1.2
Creation Time : Tue Aug 17 01:29:25 2021
Raid Level : raid5
Array Size : 41908224 (39.97 GiB 42.91 GB)
Used Dev Size : 20954112 (19.98 GiB 21.46 GB)
Raid Devices : 3
Total Devices : 4
Persistence : Superblock is persistent
Update Time : Tue Aug 17 01:36:42 2021
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 : 7aec178a:264d5f0f:4ca621b8:dbbe97a3
Events : 18
Number Major Minor RaidDevice State
0 8 17 0 active sync /dev/sdb1
1 8 33 1 active sync /dev/sdc1
4 8 49 2 active sync /dev/sdd1
3 8 65 - spare /dev/sde1
这里可以清楚的看到bcd的1盘为存储盘,e1盘为备用盘
4、模拟故障,查看备用盘是否启用
[root@localhost ~]# mdadm /dev/md0 -f /dev/sdb1 (模拟sdb1磁盘故障)
mdadm: set /dev/sdb1 faulty in /dev/md0
mdadm -D /dev/md0 (查看备用盘是否启用)
Number Major Minor RaidDevice State
3 8 65 0 spare rebuilding /dev/sde1 (备用盘成功启用)
1 8 33 1 active sync /dev/sdc1
4 8 49 2 active sync /dev/sdd1
0 8 17 - faulty /dev/sdb1
5、消除故障恢复磁盘
mdadm /dev/md0 -a /dev/sdb1 消除故障盘
mdadm: added /dev/sdb1
[root@localhost ~]# mdadm /dev/md0 -a /dev/sdb1 重新将sdb1添加到阵列,sde1重回备用盘
[root@localhost ~]# mdadm -D /dev/md0
Number Major Minor RaidDevice State
3 8 65 0 active sync /dev/sde1
1 8 33 1 active sync /dev/sdc1
4 8 49 2 active sync /dev/sdd1
5 8 17 - spare /dev/sdb1
标签:RAID,sdb1,sync,dev,active,md0,mdadm,磁盘阵列
From: https://blog.csdn.net/m0_67501353/article/details/137202331