8.格式化。
[root@localhost ~]# mkfs.xfs /dev/md10 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=09.挂载使用。
[root@localhost ~]# mkdir /mnt/md10 [root@localhost ~]# mount /dev/md10 /mnt/md10/ [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 903M 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/md10 xfs 40G 33M 40G 1% /mnt/md1010.创建测试文件。
[root@localhost ~]# touch /mnt/md10/test{1..9}.txt [root@localhost ~]# ls /mnt/md10/ test1.txt test2.txt test3.txt test4.txt test5.txt test6.txt test7.txt test8.txt test9.txt11.故障模拟。
[root@localhost ~]# mdadm -f /dev/md101 /dev/sdb1 mdadm: set /dev/sdb1 faulty in /dev/md101 [root@localhost ~]# mdadm -f /dev/md102 /dev/sdd1 mdadm: set /dev/sdd1 faulty in /dev/md10212.查看测试文件。
[root@localhost ~]# ls /mnt/md10/ test1.txt test2.txt test3.txt test4.txt test5.txt test6.txt test7.txt test8.txt test9.txt13.查看状态。
[root@localhost ~]# cat /proc/mdstat Personalities : [raid1] [raid0] md10 : active raid0 md102[1] md101[0] 41871360 blocks super 1.2 512k chunks md102 : active raid1 sde1[1] sdd1[0](F) 20953088 blocks super 1.2 [2/1] [_U] md101 : active raid1 sdc1[1] sdb1[0](F) 20953088 blocks super 1.2 [2/1] [_U] unused devices: <none> [root@localhost ~]# mdadm -D /dev/md101 /dev/md101: Version : 1.2 Creation Time : Sun Aug 25 16:53:00 2019 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 Aug 25 17:01:11 2019 State : clean, degraded Active Devices : 1 Working Devices : 1 Failed Devices : 1 Spare Devices : 0 Consistency Policy : resync Name : localhost:101 (local to host localhost) UUID : 80bb4fc5:1a628936:275ba828:17f23330 Events : 23 Number Major Minor RaidDevice State - 0 0 0 removed 1 8 33 1 active sync /dev/sdc1 0 8 17 - faulty /dev/sdb1 [root@localhost ~]# mdadm -D /dev/md102 /dev/md102: Version : 1.2 Creation Time : Sun Aug 25 16:53:23 2019 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 Aug 25 17:00:43 2019 State : clean, degraded Active Devices : 1 Working Devices : 1 Failed Devices : 1 Spare Devices : 0 Consistency Policy : resync Name : localhost:102 (local to host localhost) UUID : 38abac72:74fa8a53:3a21b5e4:01ae64cd 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@localhost ~]# mdadm -D /dev/md10 /dev/md10: Version : 1.2 Creation Time : Sun Aug 25 16:56:08 2019 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 Aug 25 16:56:08 2019 State : clean Active Devices : 2 Working Devices : 2 Failed Devices : 0 Spare Devices : 0 Chunk Size : 512K Consistency Policy : none Name : localhost:10 (local to host localhost) UUID : 23c6abac:b131a049:db25cac8:686fb045 Events : 0 Number Major Minor RaidDevice State 0 9 101 0 active sync /dev/md101 1 9 102 1 active sync /dev/md10214.移除损坏的磁盘。
[root@localhost ~]# mdadm -r /dev/md101 /dev/sdb1 mdadm: hot removed /dev/sdb1 from /dev/md101 [root@localhost ~]# mdadm -r /dev/md102 /dev/sdd1 mdadm: hot removed /dev/sdd1 from /dev/md102 [root@localhost ~]# mdadm -D /dev/md101 /dev/md101: Version : 1.2 Creation Time : Sun Aug 25 16:53:00 2019 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 : 1 Persistence : Superblock is persistent Update Time : Sun Aug 25 17:04:59 2019 State : clean, degraded Active Devices : 1 Working Devices : 1 Failed Devices : 0 Spare Devices : 0 Consistency Policy : resync Name : localhost:101 (local to host localhost) UUID : 80bb4fc5:1a628936:275ba828:17f23330 Events : 26 Number Major Minor RaidDevice State - 0 0 0 removed 1 8 33 1 active sync /dev/sdc1 [root@localhost ~]# mdadm -D /dev/md102 /dev/md102: Version : 1.2 Creation Time : Sun Aug 25 16:53:23 2019 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 : 1 Persistence : Superblock is persistent Update Time : Sun Aug 25 17:05:07 2019 State : clean, degraded Active Devices : 1 Working Devices : 1 Failed Devices : 0 Spare Devices : 0 Consistency Policy : resync Name : localhost:102 (local to host localhost) UUID : 38abac72:74fa8a53:3a21b5e4:01ae64cd Events : 20 Number Major Minor RaidDevice State - 0 0 0 removed 1 8 65 1 active sync /dev/sde115.重新添加热备份盘。
[root@localhost ~]# mdadm -a /dev/md101 /dev/sdb1 mdadm: added /dev/sdb1 [root@localhost ~]# mdadm -a /dev/md102 /dev/sdd1 mdadm: added /dev/sdd1