6.挂载使用。
[root@localhost ~]# mkdir /mnt/md5 [root@localhost ~]# mount /dev/md5 /mnt/md5/ [root@localhost ~]# df -hT Filesystem Type Size Used Avail Use% Mounted on /dev/mapper/centos-root xfs 17G 1014M 16G 6% / devtmpfs devtmpfs 901M 0 901M 0% /dev tmpfs tmpfs 912M 0 912M 0% /dev/shm tmpfs tmpfs 912M 8.7M 904M 1% /run tmpfs tmpfs 912M 0 912M 0% /sys/fs/cgroup /dev/sda1 xfs 1014M 143M 872M 15% /boot tmpfs tmpfs 183M 0 183M 0% /run/user/0 /dev/md5 xfs 40G 33M 40G 1% /mnt/md57.创建测试文件。
[root@localhost ~]# touch /mnt/md5/test{1..9}.txt [root@localhost ~]# ls /mnt/md5/ test1.txt test2.txt test3.txt test4.txt test5.txt test6.txt test7.txt test8.txt test9.txt8.故障模拟。
[root@localhost ~]# mdadm -f /dev/md5 /dev/sdb1 mdadm: set /dev/sdb1 faulty in /dev/md59.查看测试文件。
[root@localhost ~]# ls /mnt/md5/ test1.txt test2.txt test3.txt test4.txt test5.txt test6.txt test7.txt test8.txt test9.txt10.查看状态。
[root@localhost ~]# 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 = 21.0% (4411136/20953088) finish=1.3min speed=210054K/sec unused devices: <none> [root@localhost ~]# mdadm -D /dev/md5 /dev/md5: Version : 1.2 Creation Time : Sun Aug 25 16:13:44 2019 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 : Sun Aug 25 16:21:31 2019 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 : 12% complete Name : localhost:5 (local to host localhost) UUID : a055094e:9adaff79:2edae9b9:0dcc3f1b Events : 23 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/sdb111.再次查看状态。
[root@localhost ~]# 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/3] [UUU] unused devices: <none> [root@localhost ~]# mdadm -D /dev/md5 /dev/md5: Version : 1.2 Creation Time : Sun Aug 25 16:13:44 2019 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 : Sun Aug 25 16:23:09 2019 State : clean Active Devices : 3 Working Devices : 3 Failed Devices : 1 Spare Devices : 0 Layout : left-symmetric Chunk Size : 512K Consistency Policy : resync Name : localhost:5 (local to host localhost) UUID : a055094e:9adaff79:2edae9b9:0dcc3f1b 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 0 8 17 - faulty /dev/sdb112.移除损坏的磁盘。
[root@localhost ~]# mdadm -r /dev/md5 /dev/sdb1 mdadm: hot removed /dev/sdb1 from /dev/md5 [root@localhost ~]# mdadm -D /dev/md5 /dev/md5: Version : 1.2 Creation Time : Sun Aug 25 16:13:44 2019 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 : Sun Aug 25 16:25:01 2019 State : clean Active Devices : 3 Working Devices : 3 Failed Devices : 0 Spare Devices : 0 Layout : left-symmetric Chunk Size : 512K Consistency Policy : resync Name : localhost:5 (local to host localhost) UUID : a055094e:9adaff79:2edae9b9:0dcc3f1b Events : 40 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/sdd113.重新添加热备份盘。
[root@localhost ~]# mdadm -a /dev/md5 /dev/sdb1 mdadm: added /dev/sdb1 [root@localhost ~]# mdadm -D /dev/md5 /dev/md5: Version : 1.2 Creation Time : Sun Aug 25 16:13:44 2019 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 : Sun Aug 25 16:25:22 2019 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:5 (local to host localhost) UUID : a055094e:9adaff79:2edae9b9:0dcc3f1b Events : 41 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 RAID6#