文章目录
1. RAID
1.1 RAID磁盘陈列介绍
■ 是Redundant Array of Independent Disks的缩写,中文简称为独立冗余磁盘阵列
■ 把多块独立的物理硬盘按不同的方式组合起来形成一个硬盘组(逻辑硬盘),从而提供比单个硬盘更高的存储性能和提供数据备份技术
■ 组成磁盘阵列的不同方式称为RAID级别(RAID Levels)
常用的RAID级别
■ RAID0,RAID1,RAID5,RAID6,RAID1+0等
1.2 RAID 0(条带化存储)
● RAID 0连续以位或字节为单位分割数据,并行读/写于多个磁盘上,因此具有很高的数据传输率,但它没有数据冗余.
● RAID 0只是单纯地提高性能,并没有为数据的可靠性提供保证,而且其中的一个磁盘失效将影响到所有数据.
● RAID 0不能应用于数据安全性要求高的场合.
1.3 RAID 1(镜像存储)
● 通过磁盘数据镜像实现数据冗余,在成对的独立磁盘上产生互为备份的数据.
● 当原始数据繁忙时,可直接从镜像拷贝中读取数据,因此RAID 1可以提高读取性能.
● RAID 1是磁盘阵列中单位成本最高的,但提供了很高的数据安全性和可用性。当一个磁盘失效时,系统可以自动切换到镜像磁盘上读写,而不需要重组失效的数据.
1.4 RAID 5磁盘阵列介绍
RAID 5
● N(N>=3)块磁盘组成阵列,一份数据产生N-1个条带,同时还有1份校验数据,共N份数据在N块盘上循环均衡存储.
● N块盘同时读写,读性能很高,但由于有校验机制的问题,写性能相对不高.
● (N-1)/N磁盘利用率.
● 可靠性高,允许坏1块盘,不影响所有数据.
1.5 RAID 6磁盘陈列介绍
RAID 6
● N (N>=4)块盘组成阵列,(N-2)/N磁盘利用率.
● 与RAID 5相比,RAID 6增加了第二个独立的奇偶校验信息块.
● 两个独立的奇偶系统使用不同的算法,即使两块磁盘同时失效也不会影响数据的使用.
● 相对于RAID 5有更大的“写损失”,因此写性能较差.
1.6 RAID 1+0磁盘阵列介绍
RAID 1+0((先做镜象,再做条带)
● N(偶数,N>=4)块盘两两镜像后,再组合成一个RAID 0.
● N/2磁盘利用率.
● N/2块盘同时写入,N块盘同时读取.
● 性能高,可靠性高.
● 故障率为1/3.
RAID 0+1 (先做条带,再做镜象)
● 读写性能与RAID 10相同.
● 安全性低于RAID 10.
● 故障率为2/3.
1.7 阵列卡介绍
■ 阵列卡是用来实现RAID功能的板卡.
■ 通常是由I/O处理器、硬盘控制器、硬盘连接器和缓存等一系列组件构成的.
■ 不同的RAID卡支持的RAID功能不同.
● 例如支持RAID0、RAID1、RAID5、RAID10等.
■ RAID卡的接口类型.
● IDE接口、SCSI接口、SATA接口和SAS接口.
2.硬RAID创建磁盘阵列
创建RAID5,步骤如下所示:
(1)创建磁盘;
(2)快速初始化操作;
(3)做热备份盘;
补充:
ctrl +n/ctrl+p:实现左右切换.
3.软RAID创建磁盘阵列
3.1 实例:软创建RAID5
创建 RAID5磁盘阵列,步骤如下所示:
(1)检查是否已安装mdadm 软件包;
[root@clr ~]# rpm -q mdadm #查看是否已安装mdadm安装包
[root@clr ~]# yum install -y mdadm
[root@clr ~]# echo "- - -" > /sys/class/scsi_host/host0/scan #在线刷新启动硬盘
[root@clr ~]# echo "- - -" > /sys/class/scsi_host/host1/scan
[root@clr ~]# echo "- - -" > /sys/class/scsi_host/host2/scan
(2)使用fdisk工具将新磁盘设备/dev/sdb、/dev/sdc、/dev/sdd、/dev/sde划分出主分区sdb1、sdc1、sdd1、sde1,并且把分区类型的ID标记号改为“fd”;
[root@clr ~]# fdisk /dev/sdb
[root@clr ~]# fdisk /dev/sdc
[root@clr ~]# fdisk /dev/sdd
[root@clr ~]# fdisk /dev/sde
[root@clr ~]# echo -e 'n\n\n\n\n\nt\nfd\nw\n' | fdisk /dev/sdc #免交互方式将磁盘分区
[root@clr ~]# lsblk #查看磁盘划分的分区情况
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 60G 0 disk
├─sda1 8:1 0 37G 0 part /
├─sda2 8:2 0 1K 0 part
└─sda5 8:5 0 3.9G 0 part [SWAP]
sdb 8:16 0 20G 0 disk
└─sdb1 8:17 0 20G 0 part
sdc 8:32 0 20G 0 disk
└─sdc1 8:33 0 20G 0 part
sdd 8:48 0 20G 0 disk
└─sdd1 8:49 0 20G 0 part
sde 8:64 0 20G 0 disk
└─sde1 8:65 0 20G 0 part
sr0 11:0 1 4.4G 0 rom /run/media/root/CentOS 7 x86_64
查看raid分区类型的ID标记号为fd;
(3)创建RAID设备;
#创建RAID5
mdadm -C -v /dev/md0 [-a yes] -l5 -n3 /dev/sd[bcd]1 -x1 /dev/sde1
选项 | 功能作用 |
---|---|
-C | 表示新建 |
-v | 显示创建过程中的详细信息 |
/dev/md0 | 创建 RAID5 的名称 |
-a yes | - -auto,表示如果有什么设备文件没有存在的话就自动创建,可省略 |
-l(小写的英文l) | 指定 RAID 的级别,l5 表示创建 RAID5 |
-n | 指定使用几块硬盘创建 RAID,n3 表示使用3块硬盘创建 RAID |
/dev/sd[bcd]1 | 指定使用这3块磁盘分区去创建 RAID |
-x | 指定使用几块硬盘做RAID的热备用盘,x1表示保留1块空闲的硬盘作备用 |
/dev/sde1 | 指定用作于备用的磁盘 |
[root@clr ~]# mdadm -Cv /dev/md5 -l5 -n3 /dev/sd[bcd]1 -x1 /dev/sde1 #创建raid5并命名为md5
mdadm: layout defaults to left-symmetric
mdadm: layout defaults to left-symmetric
mdadm: chunk size defaults to 512K
mdadm: size set to 20953088K
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md5 started.
[root@clr ~]# mdadm -D /dev/md5 #查看创建过程
/dev/md5:
Version : 1.2
Creation Time : Thu Apr 6 21:52:16 2023
Raid Level : raid5
Array Size : 41906176 (39.96 GiB 42.91 GB)
Used Dev Size : 20953088 (19.98 GiB 21.46 GB)
Raid Devices : 3
Total Devices : 4
Persistence : Superblock is persistent
Update Time : Thu Apr 6 21:53:00 2023
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 : 27% complete
Name : clr:5 (local to host clr)
UUID : 014f444a:a42f81ca:4c8554f3:4a66d44d
Events : 5
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 spare rebuilding /dev/sdd1
3 8 65 - spare /dev/sde1
[root@clr ~]# cat /proc/mdstat #查看创建进程
Personalities : [raid6] [raid5] [raid4]
md5 : active raid5 sdd1[4] sde1[3](S) sdc1[1] sdb1[0]
41906176 blocks super 1.2 level 5, 512k chunk, algorithm 2 [3/2] [UU_]
[========>............] recovery = 43.7% (9167232/20953088) finish=1.6min speed=120373K/sec
unused devices: <none>
[root@clr ~]# watch -n 5 'cat /proc/mdstat' #每5秒钟监听一次,创建的过程
mdadm -E [分区设备名]:检查某个指定分区设备,是否做过raid;
[root@clr ~]# mdadm -E /dev/sdb1 #检查某个指定分区设备,是否做过raid
/dev/sdb1:
Magic : a92b4efc
Version : 1.2
Feature Map : 0x0
Array UUID : 014f444a:a42f81ca:4c8554f3:4a66d44d
Name : clr:5 (local to host clr)
Creation Time : Thu Apr 6 21:52:16 2023
Raid Level : raid5 #用于做raid5的磁盘阵列
Raid Devices : 3
Avail Dev Size : 41906176 sectors (19.98 GiB 21.46 GB)
Array Size : 41906176 KiB (39.96 GiB 42.91 GB)
Data Offset : 34816 sectors
Super Offset : 8 sectors
Unused Space : before=34664 sectors, after=0 sectors
State : clean
Device UUID : dff29ecc:4942ac37:a22d145f:a18c8b44
Update Time : Thu Apr 6 21:55:16 2023
Bad Block Log : 512 entries available at offset 136 sectors
Checksum : aedc2043 - correct
Events : 18
Layout : left-symmetric
Chunk Size : 512K
Device Role : Active device 0
Array State : AAA ('A' == active, '.' == missing, 'R' == replacing)
查看RAID磁盘详细信息
cat /proc/mdstat :还能查看创建RAID的进度
mdadm -D /dev/md0
用watch命令来每隔一段时间刷新 /proc/mdstat 的输出
watch -n 10 ‘cat /proc/mdstat’
检查磁盘是否已做RAID
mdadm -E /dev/sd[b-e]1
(4)创建并挂载文件系统;
[root@clr ~]# mkfs -t xfs /dev/md5 #将分区/dev/md5格式化为xfs类型
meta-data=/dev/md5 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
[root@clr ~]# mkdir /data
[root@clr ~]# mount /dev/md5 /data #将/dev/md5挂载到/data目录下
[root@clr ~]# df -hT
文件系统 类型 容量 已用 可用 已用% 挂载点
devtmpfs devtmpfs 2.0G 0 2.0G 0% /dev
tmpfs tmpfs 2.0G 0 2.0G 0% /dev/shm
tmpfs tmpfs 2.0G 13M 2.0G 1% /run
tmpfs tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup
/dev/sda1 xfs 38G 5.4G 32G 15% /
tmpfs tmpfs 394M 32K 394M 1% /run/user/0
/dev/sr0 iso9660 4.4G 4.4G 0 100% /run/media/root/CentOS 7 x86_64
/dev/md5 xfs 40G 33M 40G 1% /data #挂载成功
(5)实现故障恢复;
[root@clr ~]# mdadm /dev/md5 -f /dev/sdb1 #模拟raid5中的/dev/sdb1出现故障
mdadm: set /dev/sdb1 faulty in /dev/md5
[root@clr ~]# mdadm -D /dev/md5
/dev/md5:
Version : 1.2
Creation Time : Thu Apr 6 21:52:16 2023
Raid Level : raid5
Array Size : 41906176 (39.96 GiB 42.91 GB)
Used Dev Size : 20953088 (19.98 GiB 21.46 GB)
Raid Devices : 3
Total Devices : 4
Persistence : Superblock is persistent
Update Time : Thu Apr 6 22:11:14 2023
State : clean, degraded, recovering
Active Devices : 2
Working Devices : 3
Failed Devices : 1
Spare Devices : 1
Layout : left-symmetric
Chunk Size : 512K
Consistency Policy : resync
Rebuild Status : 9% complete #正在重新创建磁盘阵列
Name : clr:5 (local to host clr)
UUID : 014f444a:a42f81ca:4c8554f3:4a66d44d
Events : 21
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
[root@clr ~]# cat /proc/mdstat #查看创建进度
Personalities : [raid6] [raid5] [raid4]
md5 : active raid5 sdd1[4] sde1[3] sdc1[1] sdb1[0](F)
41906176 blocks super 1.2 level 5, 512k chunk, algorithm 2 [3/2] [_UU]
[============>........] recovery = 63.8% (13387776/20953088) finish=1.0min speed=125660K/sec
unused devices: <none>
[root@clr ~]# mdadm /dev/md5 -r /dev/sdb1 #将出现故障的坏盘/dev/sdb1移除磁盘阵列
mdadm: hot removed /dev/sdb1 from /dev/md5
[root@clr ~]# mdadm -D /dev/md5
/dev/md5:
Version : 1.2
Creation Time : Thu Apr 6 21:52:16 2023
Raid Level : raid5
Array Size : 41906176 (39.96 GiB 42.91 GB)
Used Dev Size : 20953088 (19.98 GiB 21.46 GB)
Raid Devices : 3
Total Devices : 3
Persistence : Superblock is persistent
Update Time : Thu Apr 6 22:14:02 2023
State : clean
Active Devices : 3
Working Devices : 3
Failed Devices : 0
Spare Devices : 0
Layout : left-symmetric
Chunk Size : 512K
Consistency Policy : resync
Name : clr:5 (local to host clr)
UUID : 014f444a:a42f81ca:4c8554f3:4a66d44d
Events : 38
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
[root@clr ~]# mdadm /dev/md5 -a /dev/sdb1 #将分区/dev/sdb1再次放回磁盘阵列
mdadm: added /dev/sdb1
[root@clr ~]# mdadm -D /dev/md5
/dev/md5:
Version : 1.2
Creation Time : Thu Apr 6 21:52:16 2023
Raid Level : raid5
Array Size : 41906176 (39.96 GiB 42.91 GB)
Used Dev Size : 20953088 (19.98 GiB 21.46 GB)
Raid Devices : 3
Total Devices : 4
Persistence : Superblock is persistent
Update Time : Thu Apr 6 22:14:28 2023
State : clean
Active Devices : 3
Working Devices : 4
Failed Devices : 0
Spare Devices : 1
Layout : left-symmetric
Chunk Size : 512K
Consistency Policy : resync
Name : clr:5 (local to host clr)
UUID : 014f444a:a42f81ca:4c8554f3:4a66d44d
Events : 39
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 #作为备份盘
mdadm命令其它常用选项
常用选项 | 功能作用 |
---|---|
-r | 移除设备 |
-a | 添加设备 |
-S | 停止RAID |
-A | 启动RAID |
(6)创建 /etc/mdadm.conf 配置文件,方便管理软RAID的配置,比如启动、停止;
[root@clr ~]# cd /data
[root@clr ~]# umount /data #先解挂载
[root@clr ~]# vim /etc/mdadm.conf
DEVICE /dev/sdb1 /dev/sdc1 /dev/sdd1 /dev/sde1
[root@clr /data]# mdadm --detail --scan >> /etc/mdadm.conf #从/etc/mdadm.conf这个配置文件中,详细扫描磁盘文件信息
[root@clr /data]# cat /etc/mdadm.conf
DEVICE /dev/sdb1 /dev/sdc1 /dev/sdd1 /dev/sde1
ARRAY /dev/md5 metadata=1.2 spares=1 name=clr:5 UUID=014f444a:a42f81ca:4c8554f3:4a66d44d
[root@clr /data]# mdadm -S /dev/md5 #停止raid5
mdadm: stopped /dev/md5
[root@clr /data]# ls /dev/md5
ls: 无法访问/dev/md5: 没有那个文件或目录
[root@clr /data]# mdadm -A -s /dev/md5 #再次启动raid5
mdadm: /dev/md5 has been started with 3 drives and 1 spare.
[root@clr /data]# ls /dev/md5
/dev/md5 #用于启动设备的配置文件
3.2 实例:软创建RAID10
(1)首先查看磁盘添加以及分区情况;
[root@clr ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 60G 0 disk
├─sda1 8:1 0 37G 0 part /
├─sda2 8:2 0 1K 0 part
└─sda5 8:5 0 3.9G 0 part [SWAP]
sdb 8:16 0 20G 0 disk
└─sdb1 8:17 0 20G 0 part
sdc 8:32 0 20G 0 disk
└─sdc1 8:33 0 20G 0 part
sdd 8:48 0 20G 0 disk
└─sdd1 8:49 0 20G 0 part
sde 8:64 0 20G 0 disk
└─sde1 8:65 0 20G 0 part
sr0 11:0 1 4.4G 0 rom /run/media/root/CentOS 7 x86_64
(2)创建RAID10(先做镜像raid1);
[root@clr ~]# mdadm -Cv /dev/md0 -l1 -n2 /dev/sd[bc]1 #做镜像raid1,由分区sdb1和sdc1组成,并命名为/dev/md0
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: size set to 20953088K
Continue creating array? y #继续创建磁盘
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md0 started.
[root@clr ~]# mdadm -Cv /dev/md1 -l1 -n2 /dev/sd[de]1 #做镜像raid1,由分区sdd1和sde1组成,并命名为/dev/md1
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: size set to 20953088K
Continue creating array? y
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md1 started.
[root@clr ~]# mdadm -D /dev/md0 #查看/dev/md0创建过程
/dev/md0:
Version : 1.2
Creation Time : Sun Apr 9 00:42:30 2023
Raid Level : raid1
Array Size : 20953088 (19.98 GiB 21.46 GB)
Used Dev Size : 20953088 (19.98 GiB 21.46 GB)
Raid Devices : 2
Total Devices : 2
Persistence : Superblock is persistent
Update Time : Sun Apr 9 00:43:30 2023
State : clean, resyncing
Active Devices : 2
Working Devices : 2
Failed Devices : 0
Spare Devices : 0
Consistency Policy : resync
Resync Status : 60% complete
Name : clr:0 (local to host clr)
UUID : bf6c1129:0d2dc4d2:ad8b8bab:e15f1d2a
Events : 9
Number Major Minor RaidDevice State
0 8 17 0 active sync /dev/sdb1
1 8 33 1 active sync /dev/sdc1
[root@clr ~]# mdadm -D /dev/md1 #查看/dev/md1创建过程
/dev/md1:
Version : 1.2
Creation Time : Sun Apr 9 00:43:24 2023
Raid Level : raid1
Array Size : 20953088 (19.98 GiB 21.46 GB)
Used Dev Size : 20953088 (19.98 GiB 21.46 GB)
Raid Devices : 2
Total Devices : 2
Persistence : Superblock is persistent
Update Time : Sun Apr 9 00:43:37 2023
State : clean, resyncing
Active Devices : 2
Working Devices : 2
Failed Devices : 0
Spare Devices : 0
Consistency Policy : resync
Resync Status : 17% complete
Name : clr:1 (local to host clr)
UUID : 4b68d596:7d1aa620:86e74e4f:656a4c4e
Events : 2
Number Major Minor RaidDevice State
0 8 49 0 active sync /dev/sdd1
1 8 65 1 active sync /dev/sde1
(3)创建RAID10(再做条带raid0);
[root@clr ~]# mdadm -Cv /dev/md10 -l0 -n2 /dev/md0 /dev/md1 #创建条带raid0,由镜像/dev/md0和/dev/md1组成,并命名为/dev/md10
mdadm: chunk size defaults to 512K
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md10 started.
[root@clr ~]# mdadm -D /dev/md10
/dev/md10:
Version : 1.2
Creation Time : Sun Apr 9 00:46:08 2023
Raid Level : raid0
Array Size : 41871360 (39.93 GiB 42.88 GB)
Raid Devices : 2
Total Devices : 2
Persistence : Superblock is persistent
Update Time : Sun Apr 9 00:46:08 2023
State : clean
Active Devices : 2
Working Devices : 2
Failed Devices : 0
Spare Devices : 0
Chunk Size : 512K
Consistency Policy : none
Name : clr:10 (local to host clr)
UUID : df79bdfb:70f7d0ac:2093e2d9:6ab5acc6
Events : 0
Number Major Minor RaidDevice State
0 9 0 0 active sync /dev/md0
1 9 1 1 active sync /dev/md1
[root@clr ~]# watch -n 5 'cat /proc/mdstat' #每5秒钟刷新文件/proc/mdstat的输出
(4)格式化,创建并挂载文件系统;
[root@clr ~]# mkfs -t xfs /dev/md10 #将/dev/md10格式化为xfs类型的文件系统
meta-data=/dev/md10 isize=512 agcount=16, agsize=654208 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0, sparse=0
data = bsize=4096 blocks=10467328, imaxpct=25
= sunit=128 swidth=256 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal log bsize=4096 blocks=5112, version=2
= sectsz=512 sunit=8 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
[root@clr ~]# mkdir /data
[root@clr ~]# mount /dev/md10 /data #将/dev/md10挂载到/data目录中
(5)创建/etc/mdadm.conf配置文件;
[root@clr ~]# echo 'DEVICE /dev/sdb1 /dev/sdc1 /dev/sdd1 /dev/sde1' > /etc/mdadm.conf #将设备分区信息写入/etc/mdadm.conf配置文件中
[root@clr ~]# mdadm --detail --scan >> /etc/mdadm.conf #细节扫描/etc/mdadm.conf配置文件
[root@clr ~]# umount /dev/md10 #解挂载/dev/md10设备分区
[root@clr ~]# mdadm -S /dev/md10 #停止raid10设备
mdadm: stopped /dev/md10
[root@clr ~]# ls /dev/md10
ls: 无法访问/dev/md10: 没有那个文件或目录
[root@clr ~]# mdadm -A /dev/md10 /dev/md0 /dev/md1 #再次启动raid10设备分区
mdadm: /dev/md10 has been started with 2 drives.
[root@clr ~]# ls /dev/md10 #查看raid10的配置文件
/dev/md10
(6)实现故障恢复;
[root@clr ~]# mdadm /dev/md0 -f /dev/sdb1 #模拟/dev/sdb1故障
mdadm: set /dev/sdb1 faulty in /dev/md0
[root@clr ~]# mdadm -D /dev/md0 #查看此时raid分区的创建情况
/dev/md0:
Version : 1.2
Creation Time : Sun Apr 9 00:42:30 2023
Raid Level : raid1
Array Size : 20953088 (19.98 GiB 21.46 GB)
Used Dev Size : 20953088 (19.98 GiB 21.46 GB)
Raid Devices : 2
Total Devices : 2
Persistence : Superblock is persistent
Update Time : Sun Apr 9 00:49:39 2023
State : clean, degraded
Active Devices : 1
Working Devices : 1
Failed Devices : 1
Spare Devices : 0
Consistency Policy : resync
Name : clr:0 (local to host clr)
UUID : bf6c1129:0d2dc4d2:ad8b8bab:e15f1d2a
Events : 19
Number Major Minor RaidDevice State
- 0 0 0 removed
1 8 33 1 active sync /dev/sdc1
0 8 17 - faulty /dev/sdb1
[root@clr ~]# mdadm -S /dev/md10 #停止raid10设备
mdadm: stopped /dev/md10
[root@clr ~]# mdadm -A /dev/md10 /dev/md0 /dev/md1 #再次启动raid10设备
mdadm: /dev/md10 has been started with 2 drives.
[root@clr ~]# ls /dev/md10
/dev/md10 #可以查看到/dev/md10的配置文件信息,也就是raid1中只坏一个设备分区时,raid10可以正常启动和使用
[root@clr ~]# mdadm /dev/md1 -f /dev/sdd1 #模拟/dev/md1中也坏掉另一个设备/dev/sdd1时
mdadm: set /dev/sdd1 faulty in /dev/md1
[root@clr ~]# mdadm -D /dev/md1
/dev/md1:
Version : 1.2
Creation Time : Sun Apr 9 00:43:24 2023
Raid Level : raid1
Array Size : 20953088 (19.98 GiB 21.46 GB)
Used Dev Size : 20953088 (19.98 GiB 21.46 GB)
Raid Devices : 2
Total Devices : 2
Persistence : Superblock is persistent
Update Time : Sun Apr 9 00:50:42 2023
State : clean, degraded
Active Devices : 1
Working Devices : 1
Failed Devices : 1
Spare Devices : 0
Consistency Policy : resync
Name : clr:1 (local to host clr)
UUID : 4b68d596:7d1aa620:86e74e4f:656a4c4e
Events : 19
Number Major Minor RaidDevice State
- 0 0 0 removed
1 8 65 1 active sync /dev/sde1
0 8 49 - faulty /dev/sdd1
[root@clr ~]# mdadm -S /dev/md10
mdadm: stopped /dev/md10
[root@clr ~]# mdadm -A /dev/md10 /dev/md0 /dev/md1
mdadm: /dev/md10 has been started with 2 drives.
[root@clr ~]# ls /dev/md10
/dev/md10 #可以查看到此时raid10设备可以正常启动和使用,也就是raid1中两组镜像中各坏一个设备分区的情况
[root@clr ~]# mdadm /dev/md0 -f /dev/sdc1 #模拟/dev/md0中再次坏掉另一个设备/dev/sdC1时,也就是raid0中两个设备同时坏掉的情况,此时系统模拟显示无法执行该操作
mdadm: set device faulty failed for /dev/sdc1: Device or resource busy
[root@clr ~]# mdadm -D /dev/md0
/dev/md0:
Version : 1.2
Creation Time : Sun Apr 9 00:42:30 2023
Raid Level : raid1
Array Size : 20953088 (19.98 GiB 21.46 GB)
Used Dev Size : 20953088 (19.98 GiB 21.46 GB)
Raid Devices : 2
Total Devices : 2
Persistence : Superblock is persistent
Update Time : Sun Apr 9 00:49:39 2023
State : clean, degraded
Active Devices : 1
Working Devices : 1
Failed Devices : 1
Spare Devices : 0
Consistency Policy : resync
Name : clr:0 (local to host clr)
UUID : bf6c1129:0d2dc4d2:ad8b8bab:e15f1d2a
Events : 19
Number Major Minor RaidDevice State
- 0 0 0 removed
1 8 33 1 active sync /dev/sdc1
0 8 17 - faulty /dev/sdb1