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

12.移除损坏的磁盘

[root@localhost ~]# mdadm -r /dev/md1 /dev/sdb1 mdadm: hot removed /dev/sdb1 from /dev/md1 [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 : 2 Persistence : Superblock is persistent Update Time : Sun Aug 25 15:52:57 2019 State : active Active Devices : 2 Working Devices : 2 Failed Devices : 0 Spare Devices : 0 Consistency Policy : resync Name : localhost:1 (local to host localhost) UUID : b921e8b3:a18e2fc9:11706ba4:ed633dfd Events : 38 Number Major Minor RaidDevice State 2 8 49 0 active sync /dev/sdd1 1 8 33 1 active sync /dev/sdc1

13.重新添加热备份盘。

[root@localhost ~]# mdadm -a /dev/md1 /dev/sdb1 mdadm: added /dev/sdb1 [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:53:32 2019 State : active Active Devices : 2 Working Devices : 3 Failed Devices : 0 Spare Devices : 1 Consistency Policy : resync Name : localhost:1 (local to host localhost) UUID : b921e8b3:a18e2fc9:11706ba4:ed633dfd Events : 39 Number Major Minor RaidDevice State 2 8 49 0 active sync /dev/sdd1 1 8 33 1 active sync /dev/sdc1 3 8 17 - spare /dev/sdb1 RAID5#

RAID5最少由三个硬盘组成,它将数据分散存储于阵列中的每个硬盘,并且还伴有一个数据校验位,数据位与校验位通过算法能相互验证,当丢失其中的一位时,RAID控制器能通过算法,利用其它两位数据将丢失的数据进行计算还原。因而RAID5最多能允许一个硬盘损坏,有容错性。RAID5相对于其它的组合方式,在容错与成本方面有一个平衡,因而受到大多数使用者的欢迎。一般的磁盘阵列,最常使用的就是RAID5这种方式。

RAID5

实验:RAID5创建,格式化,挂载使用,故障模拟,重新添加热备份。

1.添加4块20G的硬盘,分区,类型ID为fd。

[root@localhost ~]# fdisk -l | grep raid /dev/sdb1 2048 41943039 20970496 fd Linux raid autodetect /dev/sdc1 2048 41943039 20970496 fd Linux raid autodetect /dev/sdd1 2048 41943039 20970496 fd Linux raid autodetect /dev/sde1 2048 41943039 20970496 fd Linux raid autodetect

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

[root@localhost ~]# mdadm -C -v /dev/md5 -l5 -n3 /dev/sd[b-d]1 -x1 /dev/sde1 mdadm: layout defaults to left-symmetric mdadm: layout defaults to left-symmetric mdadm: chunk size defaults to 512K mdadm: size set to 20953088K mdadm: Fail create md5 when using /sys/module/md_mod/parameters/new_array mdadm: Defaulting to version 1.2 metadata mdadm: array /dev/md5 started.

3.查看raidstat状态。

[root@localhost ~]# 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 = 24.1% (5057340/20953088) finish=1.3min speed=202293K/sec unused devices: <none> [root@localhost ~]# 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/3] [UUU] unused devices: <none>

4.查看RAID5的详细信息。

[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:15:29 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 : 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

5.格式化。

[root@localhost ~]# mkfs.xfs /dev/md5 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

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

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