Linux 常见 RAID 及软 RAID 创建(2)

2.创建RAID1,并添加1个热备份盘。

[root@localhost ~]# mdadm -C -v /dev/md1 -l1 -n2 /dev/sd{b,c}1 -x1 /dev/sdd1 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: Fail create md1 when using /sys/module/md_mod/parameters/new_array mdadm: Defaulting to version 1.2 metadata mdadm: array /dev/md1 started.

3.查看raidstat状态。

[root@localhost ~]# cat /proc/mdstat Personalities : [raid1] md1 : active raid1 sdd1[2](S) sdc1[1] sdb1[0] 20953088 blocks super 1.2 [2/2] [UU] [========>............] resync = 44.6% (9345792/20953088) finish=0.9min speed=203996K/sec unused devices: <none> [root@localhost ~]# cat /proc/mdstat Personalities : [raid1] md1 : active raid1 sdd1[2](S) sdc1[1] sdb1[0] 20953088 blocks super 1.2 [2/2] [UU] unused devices: <none>

4.查看RAID1的详细信息。

[root@localhost ~]# mdadm -D /dev/md1 /dev/md1: Version : 1.2 Creation Time : Sun Aug 25 15:38:44 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 : 3 Persistence : Superblock is persistent Update Time : Sun Aug 25 15:39:24 2019 State : clean, resyncing Active Devices : 2 Working Devices : 3 Failed Devices : 0 Spare Devices : 1 Consistency Policy : resync Resync Status : 40% complete Name : localhost:1 (local to host localhost) UUID : b921e8b3:a18e2fc9:11706ba4:ed633dfd Events : 6 Number Major Minor RaidDevice State 0 8 17 0 active sync /dev/sdb1 1 8 33 1 active sync /dev/sdc1 2 8 49 - spare /dev/sdd1

5.格式化。

[root@localhost ~]# mkfs.xfs /dev/md1 meta-data=/dev/md1 isize=512 agcount=4, agsize=1309568 blks = sectsz=512 attr=2, projid32bit=1 = crc=1 finobt=0, sparse=0 data = bsize=4096 blocks=5238272, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0 ftype=1 log =internal log bsize=4096 blocks=2560, version=2 = sectsz=512 sunit=0 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0

6.挂载使用。

[root@localhost ~]# mkdir /mnt/md1 [root@localhost ~]# mount /dev/md1 /mnt/md1/ [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/md1 xfs 20G 33M 20G 1% /mnt/md1

7.创建测试文件。

[root@localhost ~]# touch /mnt/md1/test{1..9}.txt [root@localhost ~]# ls /mnt/md1/ test1.txt test2.txt test3.txt test4.txt test5.txt test6.txt test7.txt test8.txt test9.txt

8.故障模拟。

[root@localhost ~]# mdadm -f /dev/md1 /dev/sdb1 mdadm: set /dev/sdb1 faulty in /dev/md1

9.查看测试文件。

[root@localhost ~]# ls /mnt/md1/ test1.txt test2.txt test3.txt test4.txt test5.txt test6.txt test7.txt test8.txt test9.txt

10.查看状态。

[root@localhost ~]# cat /proc/mdstat Personalities : [raid1] md1 : active raid1 sdd1[2] sdc1[1] sdb1[0](F) 20953088 blocks super 1.2 [2/1] [_U] [=====>...............] recovery = 26.7% (5600384/20953088) finish=1.2min speed=200013K/sec unused devices: <none> [root@localhost ~]# mdadm -D /dev/md1 /dev/md1: Version : 1.2 Creation Time : Sun Aug 25 15:38:44 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 : 3 Persistence : Superblock is persistent Update Time : Sun Aug 25 15:47:57 2019 State : active, degraded, recovering Active Devices : 1 Working Devices : 2 Failed Devices : 1 Spare Devices : 1 Consistency Policy : resync Rebuild Status : 17% complete Name : localhost:1 (local to host localhost) UUID : b921e8b3:a18e2fc9:11706ba4:ed633dfd Events : 22 Number Major Minor RaidDevice State 2 8 49 0 spare rebuilding /dev/sdd1 1 8 33 1 active sync /dev/sdc1 0 8 17 - faulty /dev/sdb1

11.再次查看状态。

[root@localhost ~]# cat /proc/mdstat Personalities : [raid1] md1 : active raid1 sdd1[2] sdc1[1] sdb1[0](F) 20953088 blocks super 1.2 [2/2] [UU] unused devices: <none> [root@localhost ~]# mdadm -D /dev/md1 /dev/md1: Version : 1.2 Creation Time : Sun Aug 25 15:38:44 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 : 3 Persistence : Superblock is persistent Update Time : Sun Aug 25 15:49:28 2019 State : active Active Devices : 2 Working Devices : 2 Failed Devices : 1 Spare Devices : 0 Consistency Policy : resync Name : localhost:1 (local to host localhost) UUID : b921e8b3:a18e2fc9:11706ba4:ed633dfd Events : 37 Number Major Minor RaidDevice State 2 8 49 0 active sync /dev/sdd1 1 8 33 1 active sync /dev/sdc1 0 8 17 - faulty /dev/sdb1

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/11780.html