Linux 常见 RAID 及软 RAID 创建

2023-11-21 04:59
文章标签 linux 常见 创建 raid 及软

本文主要是介绍Linux 常见 RAID 及软 RAID 创建,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

CentOS-Logo

RAID可以大幅度的提高磁盘性能,以及可靠性,这么好的技术怎么能不掌握呢!此篇介绍一些常见RAID,及其在Linux上的软RAID创建方法。


mdadm

  • 创建软RAID
mdadm -C -v /dev/创建的设备名 -l级别 -n数量 添加的磁盘 [-x数量 添加的热备份盘]

-C:创建一个新的阵列--create
-v:显示细节--verbose
-l:设定RAID级别--level=
-n:指定阵列中可用device数目--raid-devices=
-x:指定初始阵列的富余device数目--spare-devices=,空闲盘(热备磁盘)能在工作盘损坏后自动顶替

  • 查看详细信息
mdadm -D /dev/设备名

-D:打印一个或多个md device的详细信息--detail

  • 查看RAID的状态
cat /proc/mdstat
  • 模拟损坏
mdadm -f /dev/设备名 磁盘

-f:模拟损坏fail

  • 移除损坏
mdadm -r /dev/设备名 磁盘

-r:移除remove

  • 添加新硬盘作为热备份盘
mdadm -a /dev/设备名 磁盘

-a:添加add


RAID0

RAID0俗称条带,它将两个或多个硬盘组成一个逻辑硬盘,容量是所有硬盘之和,因为是多个硬盘组合成一个,故可并行写操作,写入速度提高,但此方式硬盘数据没有冗余,没有容错,一旦一个物理硬盘损坏,则所有数据均丢失。因而,RAID0适合于对数据量大,但安全性要求不高的场景,比如音像、视频文件的存储等。

RAID0

实验RAID0创建,格式化,挂载使用。

1.添加220G的硬盘,分区,类型IDfd

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

2.创建RAID0

[root@localhost ~]# mdadm -C -v /dev/md0 -l0 -n2 /dev/sd{b,c}1
mdadm: chunk size defaults to 512K
mdadm: Fail create md0 when using /sys/module/md_mod/parameters/new_array
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md0 started.

3.查看raidstat状态。

[root@localhost ~]# cat /proc/mdstat
Personalities : [raid0]
md0 : active raid0 sdc1[1] sdb1[0]41906176 blocks super 1.2 512k chunksunused devices: <none>

4.查看RAID0的详细信息。

[root@localhost ~]# mdadm -D /dev/md0
/dev/md0:Version : 1.2Creation Time : Sun Aug 25 15:28:13 2019Raid Level : raid0Array Size : 41906176 (39.96 GiB 42.91 GB)Raid Devices : 2Total Devices : 2Persistence : Superblock is persistentUpdate Time : Sun Aug 25 15:28:13 2019State : cleanActive Devices : 2Working Devices : 2Failed Devices : 0Spare Devices : 0Chunk Size : 512KConsistency Policy : noneName : localhost:0  (local to host localhost)UUID : 7ff54c57:b99a59da:6b56c6d5:a4576ccfEvents : 0Number   Major   Minor   RaidDevice State0       8       17        0      active sync   /dev/sdb11       8       33        1      active sync   /dev/sdc1

5.格式化。

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

6.挂载使用。

[root@localhost ~]# mkdir /mnt/md0
[root@localhost ~]# mount /dev/md0 /mnt/md0/
[root@localhost ~]# df -hT
Filesystem              Type      Size  Used Avail Use% Mounted on
/dev/mapper/centos-root xfs        17G 1013M   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/md0                xfs        40G   33M   40G   1% /mnt/md0

RAID1

RAID1俗称镜像,它最少由两个硬盘组成,且两个硬盘上存储的数据均相同,以实现数据冗余。RAID1读操作速度有所提高,写操作理论上与单硬盘速度一样,但由于数据需要同时写入所有硬盘,实际上稍为下降。容错性是所有组合方式里最好的,只要有一块硬盘正常,则能保持正常工作。但它对硬盘容量的利用率则是最低,只有50%,因而成本也是最高。RAID1适合对数据安全性要求非常高的场景,比如存储数据库数据文件之类。

RAID1

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

1.添加320G的硬盘,分区,类型IDfd

[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

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 andmay not be suitable as a boot device.  If you plan tostore '/boot' on this device please ensure thatyour 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/secunused 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.2Creation Time : Sun Aug 25 15:38:44 2019Raid Level : raid1Array Size : 20953088 (19.98 GiB 21.46 GB)Used Dev Size : 20953088 (19.98 GiB 21.46 GB)Raid Devices : 2Total Devices : 3Persistence : Superblock is persistentUpdate Time : Sun Aug 25 15:39:24 2019State : clean, resyncingActive Devices : 2Working Devices : 3Failed Devices : 0Spare Devices : 1Consistency Policy : resyncResync Status : 40% completeName : localhost:1  (local to host localhost)UUID : b921e8b3:a18e2fc9:11706ba4:ed633dfdEvents : 6Number   Major   Minor   RaidDevice State0       8       17        0      active sync   /dev/sdb11       8       33        1      active sync   /dev/sdc12       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/secunused devices: <none>
[root@localhost ~]# mdadm -D /dev/md1
/dev/md1:Version : 1.2Creation Time : Sun Aug 25 15:38:44 2019Raid Level : raid1Array Size : 20953088 (19.98 GiB 21.46 GB)Used Dev Size : 20953088 (19.98 GiB 21.46 GB)Raid Devices : 2Total Devices : 3Persistence : Superblock is persistentUpdate Time : Sun Aug 25 15:47:57 2019State : active, degraded, recoveringActive Devices : 1Working Devices : 2Failed Devices : 1Spare Devices : 1Consistency Policy : resyncRebuild Status : 17% completeName : localhost:1  (local to host localhost)UUID : b921e8b3:a18e2fc9:11706ba4:ed633dfdEvents : 22Number   Major   Minor   RaidDevice State2       8       49        0      spare rebuilding   /dev/sdd11       8       33        1      active sync   /dev/sdc10       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.2Creation Time : Sun Aug 25 15:38:44 2019Raid Level : raid1Array Size : 20953088 (19.98 GiB 21.46 GB)Used Dev Size : 20953088 (19.98 GiB 21.46 GB)Raid Devices : 2Total Devices : 3Persistence : Superblock is persistentUpdate Time : Sun Aug 25 15:49:28 2019State : activeActive Devices : 2Working Devices : 2Failed Devices : 1Spare Devices : 0Consistency Policy : resyncName : localhost:1  (local to host localhost)UUID : b921e8b3:a18e2fc9:11706ba4:ed633dfdEvents : 37Number   Major   Minor   RaidDevice State2       8       49        0      active sync   /dev/sdd11       8       33        1      active sync   /dev/sdc10       8       17        -      faulty   /dev/sdb1

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.2Creation Time : Sun Aug 25 15:38:44 2019Raid Level : raid1Array Size : 20953088 (19.98 GiB 21.46 GB)Used Dev Size : 20953088 (19.98 GiB 21.46 GB)Raid Devices : 2Total Devices : 2Persistence : Superblock is persistentUpdate Time : Sun Aug 25 15:52:57 2019State : activeActive Devices : 2Working Devices : 2Failed Devices : 0Spare Devices : 0Consistency Policy : resyncName : localhost:1  (local to host localhost)UUID : b921e8b3:a18e2fc9:11706ba4:ed633dfdEvents : 38Number   Major   Minor   RaidDevice State2       8       49        0      active sync   /dev/sdd11       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.2Creation Time : Sun Aug 25 15:38:44 2019Raid Level : raid1Array Size : 20953088 (19.98 GiB 21.46 GB)Used Dev Size : 20953088 (19.98 GiB 21.46 GB)Raid Devices : 2Total Devices : 3Persistence : Superblock is persistentUpdate Time : Sun Aug 25 15:53:32 2019State : activeActive Devices : 2Working Devices : 3Failed Devices : 0Spare Devices : 1Consistency Policy : resyncName : localhost:1  (local to host localhost)UUID : b921e8b3:a18e2fc9:11706ba4:ed633dfdEvents : 39Number   Major   Minor   RaidDevice State2       8       49        0      active sync   /dev/sdd11       8       33        1      active sync   /dev/sdc13       8       17        -      spare   /dev/sdb1

RAID5

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

RAID5

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

1.添加420G的硬盘,分区,类型IDfd

[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/secunused 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.2Creation Time : Sun Aug 25 16:13:44 2019Raid Level : raid5Array Size : 41906176 (39.96 GiB 42.91 GB)Used Dev Size : 20953088 (19.98 GiB 21.46 GB)Raid Devices : 3Total Devices : 4Persistence : Superblock is persistentUpdate Time : Sun Aug 25 16:15:29 2019State : cleanActive Devices : 3Working Devices : 4Failed Devices : 0Spare Devices : 1Layout : left-symmetricChunk Size : 512KConsistency Policy : resyncName : localhost:5  (local to host localhost)UUID : a055094e:9adaff79:2edae9b9:0dcc3f1bEvents : 18Number   Major   Minor   RaidDevice State0       8       17        0      active sync   /dev/sdb11       8       33        1      active sync   /dev/sdc14       8       49        2      active sync   /dev/sdd13       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

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/md5

7.创建测试文件。

[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.txt

8.故障模拟。

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

9.查看测试文件。

[root@localhost ~]# ls /mnt/md5/
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 : [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/secunused devices: <none>
[root@localhost ~]# mdadm -D /dev/md5
/dev/md5:Version : 1.2Creation Time : Sun Aug 25 16:13:44 2019Raid Level : raid5Array Size : 41906176 (39.96 GiB 42.91 GB)Used Dev Size : 20953088 (19.98 GiB 21.46 GB)Raid Devices : 3Total Devices : 4Persistence : Superblock is persistentUpdate Time : Sun Aug 25 16:21:31 2019State : clean, degraded, recoveringActive Devices : 2Working Devices : 3Failed Devices : 1Spare Devices : 1Layout : left-symmetricChunk Size : 512KConsistency Policy : resyncRebuild Status : 12% completeName : localhost:5  (local to host localhost)UUID : a055094e:9adaff79:2edae9b9:0dcc3f1bEvents : 23Number   Major   Minor   RaidDevice State3       8       65        0      spare rebuilding   /dev/sde11       8       33        1      active sync   /dev/sdc14       8       49        2      active sync   /dev/sdd10       8       17        -      faulty   /dev/sdb1

11.再次查看状态。

[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.2Creation Time : Sun Aug 25 16:13:44 2019Raid Level : raid5Array Size : 41906176 (39.96 GiB 42.91 GB)Used Dev Size : 20953088 (19.98 GiB 21.46 GB)Raid Devices : 3Total Devices : 4Persistence : Superblock is persistentUpdate Time : Sun Aug 25 16:23:09 2019State : cleanActive Devices : 3Working Devices : 3Failed Devices : 1Spare Devices : 0Layout : left-symmetricChunk Size : 512KConsistency Policy : resyncName : localhost:5  (local to host localhost)UUID : a055094e:9adaff79:2edae9b9:0dcc3f1bEvents : 39Number   Major   Minor   RaidDevice State3       8       65        0      active sync   /dev/sde11       8       33        1      active sync   /dev/sdc14       8       49        2      active sync   /dev/sdd10       8       17        -      faulty   /dev/sdb1

12.移除损坏的磁盘。

[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.2Creation Time : Sun Aug 25 16:13:44 2019Raid Level : raid5Array Size : 41906176 (39.96 GiB 42.91 GB)Used Dev Size : 20953088 (19.98 GiB 21.46 GB)Raid Devices : 3Total Devices : 3Persistence : Superblock is persistentUpdate Time : Sun Aug 25 16:25:01 2019State : cleanActive Devices : 3Working Devices : 3Failed Devices : 0Spare Devices : 0Layout : left-symmetricChunk Size : 512KConsistency Policy : resyncName : localhost:5  (local to host localhost)UUID : a055094e:9adaff79:2edae9b9:0dcc3f1bEvents : 40Number   Major   Minor   RaidDevice State3       8       65        0      active sync   /dev/sde11       8       33        1      active sync   /dev/sdc14       8       49        2      active sync   /dev/sdd1

13.重新添加热备份盘。

[root@localhost ~]# mdadm -a /dev/md5 /dev/sdb1
mdadm: added /dev/sdb1
[root@localhost ~]# mdadm -D /dev/md5
/dev/md5:Version : 1.2Creation Time : Sun Aug 25 16:13:44 2019Raid Level : raid5Array Size : 41906176 (39.96 GiB 42.91 GB)Used Dev Size : 20953088 (19.98 GiB 21.46 GB)Raid Devices : 3Total Devices : 4Persistence : Superblock is persistentUpdate Time : Sun Aug 25 16:25:22 2019State : cleanActive Devices : 3Working Devices : 4Failed Devices : 0Spare Devices : 1Layout : left-symmetricChunk Size : 512KConsistency Policy : resyncName : localhost:5  (local to host localhost)UUID : a055094e:9adaff79:2edae9b9:0dcc3f1bEvents : 41Number   Major   Minor   RaidDevice State3       8       65        0      active sync   /dev/sde11       8       33        1      active sync   /dev/sdc14       8       49        2      active sync   /dev/sdd15       8       17        -      spare   /dev/sdb1

RAID6

RAID6是在RAID5的基础上改良而成的,RAID6再将数据校验位增加一位,所以允许损坏的硬盘数量也由 RAID5的一个增加到二个。由于同一阵列中两个硬盘同时损坏的概率非常少,所以,RAID6用增加一块硬盘的代价,换来了比RAID5更高的数据安全性。

RAID6

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

1.添加620G的硬盘,分区,类型IDfd

[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
/dev/sdf1            2048    41943039    20970496   fd  Linux raid autodetect
/dev/sdg1            2048    41943039    20970496   fd  Linux raid autodetect

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

[root@localhost ~]# mdadm -C -v /dev/md6 -l6 -n4 /dev/sd[b-e]1 -x2 /dev/sd[f-g]1
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 md6 when using /sys/module/md_mod/parameters/new_array
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md6 started.

3.查看raidstat状态。

[root@localhost ~]# cat /proc/mdstat
Personalities : [raid6] [raid5] [raid4]
md6 : active raid6 sdg1[5](S) sdf1[4](S) sde1[3] sdd1[2] sdc1[1] sdb1[0]41906176 blocks super 1.2 level 6, 512k chunk, algorithm 2 [4/4] [UUUU][===>.................]  resync = 18.9% (3962940/20953088) finish=1.3min speed=208575K/secunused devices: <none>
[root@localhost ~]# cat /proc/mdstat
Personalities : [raid6] [raid5] [raid4]
md6 : active raid6 sdg1[5](S) sdf1[4](S) sde1[3] sdd1[2] sdc1[1] sdb1[0]41906176 blocks super 1.2 level 6, 512k chunk, algorithm 2 [4/4] [UUUU]unused devices: <none>

4.查看RAID6的详细信息。

[root@localhost ~]# mdadm -D /dev/md6
/dev/md6:Version : 1.2Creation Time : Sun Aug 25 16:34:36 2019Raid Level : raid6Array Size : 41906176 (39.96 GiB 42.91 GB)Used Dev Size : 20953088 (19.98 GiB 21.46 GB)Raid Devices : 4Total Devices : 6Persistence : Superblock is persistentUpdate Time : Sun Aug 25 16:34:43 2019State : clean, resyncingActive Devices : 4Working Devices : 6Failed Devices : 0Spare Devices : 2Layout : left-symmetricChunk Size : 512KConsistency Policy : resyncResync Status : 10% completeName : localhost:6  (local to host localhost)UUID : 7c3d15a2:4066f2c6:742f3e4c:82aae1bbEvents : 1Number   Major   Minor   RaidDevice State0       8       17        0      active sync   /dev/sdb11       8       33        1      active sync   /dev/sdc12       8       49        2      active sync   /dev/sdd13       8       65        3      active sync   /dev/sde14       8       81        -      spare   /dev/sdf15       8       97        -      spare   /dev/sdg1

5.格式化。

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

6.挂载使用。

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

7.创建测试文件。

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

8.故障模拟。

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

9.查看测试文件。

[root@localhost ~]# ls /mnt/md6/
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 : [raid6] [raid5] [raid4]
md6 : active raid6 sdg1[5] sdf1[4] sde1[3] sdd1[2] sdc1[1](F) sdb1[0](F)41906176 blocks super 1.2 level 6, 512k chunk, algorithm 2 [4/2] [__UU][====>................]  recovery = 23.8% (4993596/20953088) finish=1.2min speed=208066K/secunused devices: <none>
[root@localhost ~]# mdadm -D /dev/md6
/dev/md6:Version : 1.2Creation Time : Sun Aug 25 16:34:36 2019Raid Level : raid6Array Size : 41906176 (39.96 GiB 42.91 GB)Used Dev Size : 20953088 (19.98 GiB 21.46 GB)Raid Devices : 4Total Devices : 6Persistence : Superblock is persistentUpdate Time : Sun Aug 25 16:41:09 2019State : clean, degraded, recoveringActive Devices : 2Working Devices : 4Failed Devices : 2Spare Devices : 2Layout : left-symmetricChunk Size : 512KConsistency Policy : resyncRebuild Status : 13% completeName : localhost:6  (local to host localhost)UUID : 7c3d15a2:4066f2c6:742f3e4c:82aae1bbEvents : 27Number   Major   Minor   RaidDevice State5       8       97        0      spare rebuilding   /dev/sdg14       8       81        1      spare rebuilding   /dev/sdf12       8       49        2      active sync   /dev/sdd13       8       65        3      active sync   /dev/sde10       8       17        -      faulty   /dev/sdb11       8       33        -      faulty   /dev/sdc1

11.再次查看状态。

[root@localhost ~]# cat /proc/mdstat
Personalities : [raid6] [raid5] [raid4]
md6 : active raid6 sdg1[5] sdf1[4] sde1[3] sdd1[2] sdc1[1](F) sdb1[0](F)41906176 blocks super 1.2 level 6, 512k chunk, algorithm 2 [4/4] [UUUU]unused devices: <none>
[root@localhost ~]# mdadm -D /dev/md6
/dev/md6:Version : 1.2Creation Time : Sun Aug 25 16:34:36 2019Raid Level : raid6Array Size : 41906176 (39.96 GiB 42.91 GB)Used Dev Size : 20953088 (19.98 GiB 21.46 GB)Raid Devices : 4Total Devices : 6Persistence : Superblock is persistentUpdate Time : Sun Aug 25 16:42:42 2019State : cleanActive Devices : 4Working Devices : 4Failed Devices : 2Spare Devices : 0Layout : left-symmetricChunk Size : 512KConsistency Policy : resyncName : localhost:6  (local to host localhost)UUID : 7c3d15a2:4066f2c6:742f3e4c:82aae1bbEvents : 46Number   Major   Minor   RaidDevice State5       8       97        0      active sync   /dev/sdg14       8       81        1      active sync   /dev/sdf12       8       49        2      active sync   /dev/sdd13       8       65        3      active sync   /dev/sde10       8       17        -      faulty   /dev/sdb11       8       33        -      faulty   /dev/sdc1

12.移除损坏的磁盘。

[root@localhost ~]# mdadm -r /dev/md6 /dev/sd{b,c}1
mdadm: hot removed /dev/sdb1 from /dev/md6
mdadm: hot removed /dev/sdc1 from /dev/md6
[root@localhost ~]# mdadm -D /dev/md6
/dev/md6:Version : 1.2Creation Time : Sun Aug 25 16:34:36 2019Raid Level : raid6Array Size : 41906176 (39.96 GiB 42.91 GB)Used Dev Size : 20953088 (19.98 GiB 21.46 GB)Raid Devices : 4Total Devices : 4Persistence : Superblock is persistentUpdate Time : Sun Aug 25 16:43:43 2019State : cleanActive Devices : 4Working Devices : 4Failed Devices : 0Spare Devices : 0Layout : left-symmetricChunk Size : 512KConsistency Policy : resyncName : localhost:6  (local to host localhost)UUID : 7c3d15a2:4066f2c6:742f3e4c:82aae1bbEvents : 47Number   Major   Minor   RaidDevice State5       8       97        0      active sync   /dev/sdg14       8       81        1      active sync   /dev/sdf12       8       49        2      active sync   /dev/sdd13       8       65        3      active sync   /dev/sde1

13.重新添加热备份盘。

[root@localhost ~]# mdadm -a /dev/md6 /dev/sd{b,c}1
mdadm: added /dev/sdb1
mdadm: added /dev/sdc1
[root@localhost ~]# mdadm -D /dev/md6
/dev/md6:Version : 1.2Creation Time : Sun Aug 25 16:34:36 2019Raid Level : raid6Array Size : 41906176 (39.96 GiB 42.91 GB)Used Dev Size : 20953088 (19.98 GiB 21.46 GB)Raid Devices : 4Total Devices : 6Persistence : Superblock is persistentUpdate Time : Sun Aug 25 16:44:01 2019State : cleanActive Devices : 4Working Devices : 6Failed Devices : 0Spare Devices : 2Layout : left-symmetricChunk Size : 512KConsistency Policy : resyncName : localhost:6  (local to host localhost)UUID : 7c3d15a2:4066f2c6:742f3e4c:82aae1bbEvents : 49Number   Major   Minor   RaidDevice State5       8       97        0      active sync   /dev/sdg14       8       81        1      active sync   /dev/sdf12       8       49        2      active sync   /dev/sdd13       8       65        3      active sync   /dev/sde16       8       17        -      spare   /dev/sdb17       8       33        -      spare   /dev/sdc1

RAID10

RAID10是先将数据进行镜像操作,然后再对数据进行分组,RAID1在这里就是一个冗余的备份阵列,而RAID0则负责数据的读写阵列。至少要四块盘,两两组合做RAID1,然后做RAID0RAID10对存储容量的利用率和RAID1一样低,只有50%Raid10方案造成了50%的磁盘浪费,但是它提供了200%的速度和单磁盘损坏的数据安全性,并且当同时损坏的磁盘不在同一RAID1中,就能保证数据安全性,RAID10能提供比RAID5更好的性能。这种新结构的可扩充性不好,使用此方案比较昂贵。

RAID10

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

1.添加420G的硬盘,分区,类型IDfd

[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.创建两个RAID1,不添加热备份盘。

[root@localhost ~]# mdadm -C -v /dev/md101 -l1 -n2 /dev/sd{b,c}1
mdadm: Note: this array has metadata at the start andmay not be suitable as a boot device.  If you plan tostore '/boot' on this device please ensure thatyour boot-loader understands md/v1.x metadata, or use--metadata=0.90
mdadm: size set to 20953088K
Continue creating array? y
mdadm: Fail create md101 when using /sys/module/md_mod/parameters/new_array
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md101 started.
[root@localhost ~]# mdadm -C -v /dev/md102 -l1 -n2 /dev/sd{d,e}1
mdadm: Note: this array has metadata at the start andmay not be suitable as a boot device.  If you plan tostore '/boot' on this device please ensure thatyour boot-loader understands md/v1.x metadata, or use--metadata=0.90
mdadm: size set to 20953088K
Continue creating array? y
mdadm: Fail create md102 when using /sys/module/md_mod/parameters/new_array
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md102 started.

3.查看raidstat状态。

[root@localhost ~]# cat /proc/mdstat
Personalities : [raid1]
md102 : active raid1 sde1[1] sdd1[0]20953088 blocks super 1.2 [2/2] [UU][=========>...........]  resync = 48.4% (10148224/20953088) finish=0.8min speed=200056K/secmd101 : active raid1 sdc1[1] sdb1[0]20953088 blocks super 1.2 [2/2] [UU][=============>.......]  resync = 69.6% (14604672/20953088) finish=0.5min speed=200052K/secunused devices: <none>
[root@localhost ~]# cat /proc/mdstat
Personalities : [raid1]
md102 : active raid1 sde1[1] sdd1[0]20953088 blocks super 1.2 [2/2] [UU]md101 : active raid1 sdc1[1] sdb1[0]20953088 blocks super 1.2 [2/2] [UU]unused devices: <none>

4.查看两个RAID1的详细信息。

[root@localhost ~]# mdadm -D /dev/md101
/dev/md101:Version : 1.2Creation Time : Sun Aug 25 16:53:00 2019Raid Level : raid1Array Size : 20953088 (19.98 GiB 21.46 GB)Used Dev Size : 20953088 (19.98 GiB 21.46 GB)Raid Devices : 2Total Devices : 2Persistence : Superblock is persistentUpdate Time : Sun Aug 25 16:53:58 2019State : clean, resyncingActive Devices : 2Working Devices : 2Failed Devices : 0Spare Devices : 0Consistency Policy : resyncResync Status : 62% completeName : localhost:101  (local to host localhost)UUID : 80bb4fc5:1a628936:275ba828:17f23330Events : 9Number   Major   Minor   RaidDevice State0       8       17        0      active sync   /dev/sdb11       8       33        1      active sync   /dev/sdc1
[root@localhost ~]# mdadm -D /dev/md102
/dev/md102:Version : 1.2Creation Time : Sun Aug 25 16:53:23 2019Raid Level : raid1Array Size : 20953088 (19.98 GiB 21.46 GB)Used Dev Size : 20953088 (19.98 GiB 21.46 GB)Raid Devices : 2Total Devices : 2Persistence : Superblock is persistentUpdate Time : Sun Aug 25 16:54:02 2019State : clean, resyncingActive Devices : 2Working Devices : 2Failed Devices : 0Spare Devices : 0Consistency Policy : resyncResync Status : 42% completeName : localhost:102  (local to host localhost)UUID : 38abac72:74fa8a53:3a21b5e4:01ae64cdEvents : 6Number   Major   Minor   RaidDevice State0       8       49        0      active sync   /dev/sdd11       8       65        1      active sync   /dev/sde1

5.创建RAID10

[root@localhost ~]# mdadm -C -v /dev/md10 -l0 -n2 /dev/md10{1,2}
mdadm: chunk size defaults to 512K
mdadm: Fail create md10 when using /sys/module/md_mod/parameters/new_array
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md10 started.

6.查看raidstat状态。

[root@localhost ~]# cat /proc/mdstat
Personalities : [raid1] [raid0]
md10 : active raid0 md102[1] md101[0]41871360 blocks super 1.2 512k chunksmd102 : active raid1 sde1[1] sdd1[0]20953088 blocks super 1.2 [2/2] [UU]md101 : active raid1 sdc1[1] sdb1[0]20953088 blocks super 1.2 [2/2] [UU]unused devices: <none>

7.查看RAID10的详细信息。

[root@localhost ~]# mdadm -D /dev/md10
/dev/md10:Version : 1.2Creation Time : Sun Aug 25 16:56:08 2019Raid Level : raid0Array Size : 41871360 (39.93 GiB 42.88 GB)Raid Devices : 2Total Devices : 2Persistence : Superblock is persistentUpdate Time : Sun Aug 25 16:56:08 2019State : cleanActive Devices : 2Working Devices : 2Failed Devices : 0Spare Devices : 0Chunk Size : 512KConsistency Policy : noneName : localhost:10  (local to host localhost)UUID : 23c6abac:b131a049:db25cac8:686fb045Events : 0Number   Major   Minor   RaidDevice State0       9      101        0      active sync   /dev/md1011       9      102        1      active sync   /dev/md102

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=0

9.挂载使用。

[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/md10

10.创建测试文件。

[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.txt

11.故障模拟。

[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/md102

12.查看测试文件。

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

13.查看状态。

[root@localhost ~]# cat /proc/mdstat
Personalities : [raid1] [raid0]
md10 : active raid0 md102[1] md101[0]41871360 blocks super 1.2 512k chunksmd102 : 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.2Creation Time : Sun Aug 25 16:53:00 2019Raid Level : raid1Array Size : 20953088 (19.98 GiB 21.46 GB)Used Dev Size : 20953088 (19.98 GiB 21.46 GB)Raid Devices : 2Total Devices : 2Persistence : Superblock is persistentUpdate Time : Sun Aug 25 17:01:11 2019State : clean, degradedActive Devices : 1Working Devices : 1Failed Devices : 1Spare Devices : 0Consistency Policy : resyncName : localhost:101  (local to host localhost)UUID : 80bb4fc5:1a628936:275ba828:17f23330Events : 23Number   Major   Minor   RaidDevice State-       0        0        0      removed1       8       33        1      active sync   /dev/sdc10       8       17        -      faulty   /dev/sdb1
[root@localhost ~]# mdadm -D /dev/md102
/dev/md102:Version : 1.2Creation Time : Sun Aug 25 16:53:23 2019Raid Level : raid1Array Size : 20953088 (19.98 GiB 21.46 GB)Used Dev Size : 20953088 (19.98 GiB 21.46 GB)Raid Devices : 2Total Devices : 2Persistence : Superblock is persistentUpdate Time : Sun Aug 25 17:00:43 2019State : clean, degradedActive Devices : 1Working Devices : 1Failed Devices : 1Spare Devices : 0Consistency Policy : resyncName : localhost:102  (local to host localhost)UUID : 38abac72:74fa8a53:3a21b5e4:01ae64cdEvents : 19Number   Major   Minor   RaidDevice State-       0        0        0      removed1       8       65        1      active sync   /dev/sde10       8       49        -      faulty   /dev/sdd1
[root@localhost ~]# mdadm -D /dev/md10
/dev/md10:Version : 1.2Creation Time : Sun Aug 25 16:56:08 2019Raid Level : raid0Array Size : 41871360 (39.93 GiB 42.88 GB)Raid Devices : 2Total Devices : 2Persistence : Superblock is persistentUpdate Time : Sun Aug 25 16:56:08 2019State : cleanActive Devices : 2Working Devices : 2Failed Devices : 0Spare Devices : 0Chunk Size : 512KConsistency Policy : noneName : localhost:10  (local to host localhost)UUID : 23c6abac:b131a049:db25cac8:686fb045Events : 0Number   Major   Minor   RaidDevice State0       9      101        0      active sync   /dev/md1011       9      102        1      active sync   /dev/md102

14.移除损坏的磁盘。

[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.2Creation Time : Sun Aug 25 16:53:00 2019Raid Level : raid1Array Size : 20953088 (19.98 GiB 21.46 GB)Used Dev Size : 20953088 (19.98 GiB 21.46 GB)Raid Devices : 2Total Devices : 1Persistence : Superblock is persistentUpdate Time : Sun Aug 25 17:04:59 2019State : clean, degradedActive Devices : 1Working Devices : 1Failed Devices : 0Spare Devices : 0Consistency Policy : resyncName : localhost:101  (local to host localhost)UUID : 80bb4fc5:1a628936:275ba828:17f23330Events : 26Number   Major   Minor   RaidDevice State-       0        0        0      removed1       8       33        1      active sync   /dev/sdc1
[root@localhost ~]# mdadm -D /dev/md102
/dev/md102:Version : 1.2Creation Time : Sun Aug 25 16:53:23 2019Raid Level : raid1Array Size : 20953088 (19.98 GiB 21.46 GB)Used Dev Size : 20953088 (19.98 GiB 21.46 GB)Raid Devices : 2Total Devices : 1Persistence : Superblock is persistentUpdate Time : Sun Aug 25 17:05:07 2019State : clean, degradedActive Devices : 1Working Devices : 1Failed Devices : 0Spare Devices : 0Consistency Policy : resyncName : localhost:102  (local to host localhost)UUID : 38abac72:74fa8a53:3a21b5e4:01ae64cdEvents : 20Number   Major   Minor   RaidDevice State-       0        0        0      removed1       8       65        1      active sync   /dev/sde1

15.重新添加热备份盘。

[root@localhost ~]# mdadm -a /dev/md101 /dev/sdb1
mdadm: added /dev/sdb1
[root@localhost ~]# mdadm -a /dev/md102 /dev/sdd1
mdadm: added /dev/sdd1

16.再次查看状态。

[root@localhost ~]# cat /proc/mdstat
Personalities : [raid1] [raid0]
md10 : active raid0 md102[1] md101[0]41871360 blocks super 1.2 512k chunksmd102 : active raid1 sdd1[2] sde1[1]20953088 blocks super 1.2 [2/1] [_U][====>................]  recovery = 23.8% (5000704/20953088) finish=1.2min speed=208362K/secmd101 : active raid1 sdb1[2] sdc1[1]20953088 blocks super 1.2 [2/1] [_U][======>..............]  recovery = 32.0% (6712448/20953088) finish=1.1min speed=203407K/secunused devices: <none>
[root@localhost ~]# cat /proc/mdstat
Personalities : [raid1] [raid0]
md10 : active raid0 md102[1] md101[0]41871360 blocks super 1.2 512k chunksmd102 : active raid1 sdd1[2] sde1[1]20953088 blocks super 1.2 [2/2] [UU]md101 : active raid1 sdb1[2] sdc1[1]20953088 blocks super 1.2 [2/2] [UU]unused devices: <none>
[root@localhost ~]# mdadm -D /dev/md101
/dev/md101:Version : 1.2Creation Time : Sun Aug 25 16:53:00 2019Raid Level : raid1Array Size : 20953088 (19.98 GiB 21.46 GB)Used Dev Size : 20953088 (19.98 GiB 21.46 GB)Raid Devices : 2Total Devices : 2Persistence : Superblock is persistentUpdate Time : Sun Aug 25 17:07:28 2019State : cleanActive Devices : 2Working Devices : 2Failed Devices : 0Spare Devices : 0Consistency Policy : resyncName : localhost:101  (local to host localhost)UUID : 80bb4fc5:1a628936:275ba828:17f23330Events : 45Number   Major   Minor   RaidDevice State2       8       17        0      active sync   /dev/sdb11       8       33        1      active sync   /dev/sdc1
[root@localhost ~]# mdadm -D /dev/md102
/dev/md102:Version : 1.2Creation Time : Sun Aug 25 16:53:23 2019Raid Level : raid1Array Size : 20953088 (19.98 GiB 21.46 GB)Used Dev Size : 20953088 (19.98 GiB 21.46 GB)Raid Devices : 2Total Devices : 2Persistence : Superblock is persistentUpdate Time : Sun Aug 25 17:07:36 2019State : cleanActive Devices : 2Working Devices : 2Failed Devices : 0Spare Devices : 0Consistency Policy : resyncName : localhost:102  (local to host localhost)UUID : 38abac72:74fa8a53:3a21b5e4:01ae64cdEvents : 39Number   Major   Minor   RaidDevice State2       8       49        0      active sync   /dev/sdd11       8       65        1      active sync   /dev/sde1

常用 RAID 间比较

名称硬盘数量容量/利用率读性能写性能数据冗余
RAID0NN块总和N倍N倍无,一个故障,丢失所有数据
RAID1N(偶数)50%写两个设备,允许一个故障
RAID5N≥3(N-1)/N↑↑计算校验,允许一个故障
RAID6N≥4(N-2)/N↑↑↓↓双重校验,允许两个故障
RAID10N(偶数,N≥4)50%(N/2)倍(N/2)倍允许基组中的磁盘各损坏一个

一些话

此篇涉及到的操作很简单,但是,有很多的查看占用了大量的篇幅,看关键点,过程都是一个套路,都是重复的。

转载于:https://www.cnblogs.com/llife/p/11408941.html

这篇关于Linux 常见 RAID 及软 RAID 创建的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/399956

相关文章

JAVA中整型数组、字符串数组、整型数和字符串 的创建与转换的方法

《JAVA中整型数组、字符串数组、整型数和字符串的创建与转换的方法》本文介绍了Java中字符串、字符数组和整型数组的创建方法,以及它们之间的转换方法,还详细讲解了字符串中的一些常用方法,如index... 目录一、字符串、字符数组和整型数组的创建1、字符串的创建方法1.1 通过引用字符数组来创建字符串1.2

Linux磁盘分区、格式化和挂载方式

《Linux磁盘分区、格式化和挂载方式》本文详细介绍了Linux系统中磁盘分区、格式化和挂载的基本操作步骤和命令,包括MBR和GPT分区表的区别、fdisk和gdisk命令的使用、常见的文件系统格式以... 目录一、磁盘分区表分类二、fdisk命令创建分区1、交互式的命令2、分区主分区3、创建扩展分区,然后

Linux中chmod权限设置方式

《Linux中chmod权限设置方式》本文介绍了Linux系统中文件和目录权限的设置方法,包括chmod、chown和chgrp命令的使用,以及权限模式和符号模式的详细说明,通过这些命令,用户可以灵活... 目录设置基本权限命令:chmod1、权限介绍2、chmod命令常见用法和示例3、文件权限详解4、ch

Linux内核之内核裁剪详解

《Linux内核之内核裁剪详解》Linux内核裁剪是通过移除不必要的功能和模块,调整配置参数来优化内核,以满足特定需求,裁剪的方法包括使用配置选项、模块化设计和优化配置参数,图形裁剪工具如makeme... 目录简介一、 裁剪的原因二、裁剪的方法三、图形裁剪工具四、操作说明五、make menuconfig

Linux使用nohup命令在后台运行脚本

《Linux使用nohup命令在后台运行脚本》在Linux或类Unix系统中,后台运行脚本是一项非常实用的技能,尤其适用于需要长时间运行的任务或服务,本文我们来看看如何使用nohup命令在后台... 目录nohup 命令简介基本用法输出重定向& 符号的作用后台进程的特点注意事项实际应用场景长时间运行的任务服

什么是cron? Linux系统下Cron定时任务使用指南

《什么是cron?Linux系统下Cron定时任务使用指南》在日常的Linux系统管理和维护中,定时执行任务是非常常见的需求,你可能需要每天执行备份任务、清理系统日志或运行特定的脚本,而不想每天... 在管理 linux 服务器的过程中,总有一些任务需要我们定期或重复执行。就比如备份任务,通常会选在服务器资

C语言线程池的常见实现方式详解

《C语言线程池的常见实现方式详解》本文介绍了如何使用C语言实现一个基本的线程池,线程池的实现包括工作线程、任务队列、任务调度、线程池的初始化、任务添加、销毁等步骤,感兴趣的朋友跟随小编一起看看吧... 目录1. 线程池的基本结构2. 线程池的实现步骤3. 线程池的核心数据结构4. 线程池的详细实现4.1 初

手把手教你idea中创建一个javaweb(webapp)项目详细图文教程

《手把手教你idea中创建一个javaweb(webapp)项目详细图文教程》:本文主要介绍如何使用IntelliJIDEA创建一个Maven项目,并配置Tomcat服务器进行运行,过程包括创建... 1.启动idea2.创建项目模板点击项目-新建项目-选择maven,显示如下页面输入项目名称,选择

Linux限制ip访问的解决方案

《Linux限制ip访问的解决方案》为了修复安全扫描中发现的漏洞,我们需要对某些服务设置访问限制,具体来说,就是要确保只有指定的内部IP地址能够访问这些服务,所以本文给大家介绍了Linux限制ip访问... 目录背景:解决方案:使用Firewalld防火墙规则验证方法深度了解防火墙逻辑应用场景与扩展背景:

Linux下MySQL8.0.26安装教程

《Linux下MySQL8.0.26安装教程》文章详细介绍了如何在Linux系统上安装和配置MySQL,包括下载、解压、安装依赖、启动服务、获取默认密码、设置密码、支持远程登录以及创建表,感兴趣的朋友... 目录1.找到官网下载位置1.访问mysql存档2.下载社区版3.百度网盘中2.linux安装配置1.