我的一个朋友有一个带有 9 个磁盘的 mdadm-raid5,它不再重新组装。
查看系统日志后,我发现磁盘 sdi 被从阵列中踢出:
Jul 6 08:43:25 nasty kernel: [ 12.952194] md: bind<sdc>
Jul 6 08:43:25 nasty kernel: [ 12.952577] md: bind<sdd>
Jul 6 08:43:25 nasty kernel: [ 12.952683] md: bind<sde>
Jul 6 08:43:25 nasty kernel: [ 12.952784] md: bind<sdf>
Jul 6 08:43:25 nasty kernel: [ 12.952885] md: bind<sdg>
Jul 6 08:43:25 nasty kernel: [ 12.952981] md: bind<sdh>
Jul 6 08:43:25 nasty kernel: [ 12.953078] md: bind<sdi>
Jul 6 08:43:25 nasty kernel: [ 12.953169] md: bind<sdj>
Jul 6 08:43:25 nasty kernel: [ 12.953288] md: bind<sda>
Jul 6 08:43:25 nasty kernel: [ 12.953308] md: kicking non-fresh sdi from array!
Jul 6 08:43:25 nasty kernel: [ 12.953314] md: unbind<sdi>
Jul 6 08:43:25 nasty kernel: [ 12.960603] md: export_rdev(sdi)
Jul 6 08:43:25 nasty kernel: [ 12.969675] raid5: device sda operational as raid disk 0
Jul 6 08:43:25 nasty kernel: [ 12.969679] raid5: device sdj operational as raid disk 8
Jul 6 08:43:25 nasty kernel: [ 12.969682] raid5: device sdh operational as raid disk 6
Jul 6 08:43:25 nasty kernel: [ 12.969684] raid5: device sdg operational as raid disk 5
Jul 6 08:43:25 nasty kernel: [ 12.969687] raid5: device sdf operational as raid disk 4
Jul 6 08:43:25 nasty kernel: [ 12.969689] raid5: device sde operational as raid disk 3
Jul 6 08:43:25 nasty kernel: [ 12.969692] raid5: device sdd operational as raid disk 2
Jul 6 08:43:25 nasty kernel: [ 12.969694] raid5: device sdc operational as raid disk 1
Jul 6 08:43:25 nasty kernel: [ 12.970536] raid5: allocated 9542kB for md127
Jul 6 08:43:25 nasty kernel: [ 12.973975] 0: w=1 pa=0 pr=9 m=1 a=2 r=9 op1=0 op2=0
Jul 6 08:43:25 nasty kernel: [ 12.973980] 8: w=2 pa=0 pr=9 m=1 a=2 r=9 op1=0 op2=0
Jul 6 08:43:25 nasty kernel: [ 12.973983] 6: w=3 pa=0 pr=9 m=1 a=2 r=9 op1=0 op2=0
Jul 6 08:43:25 nasty kernel: [ 12.973986] 5: w=4 pa=0 pr=9 m=1 a=2 r=9 op1=0 op2=0
Jul 6 08:43:25 nasty kernel: [ 12.973989] 4: w=5 pa=0 pr=9 m=1 a=2 r=9 op1=0 op2=0
Jul 6 08:43:25 nasty kernel: [ 12.973992] 3: w=6 pa=0 pr=9 m=1 a=2 r=9 op1=0 op2=0
Jul 6 08:43:25 nasty kernel: [ 12.973996] 2: w=7 pa=0 pr=9 m=1 a=2 r=9 op1=0 op2=0
Jul 6 08:43:25 nasty kernel: [ 12.973999] 1: w=8 pa=0 pr=9 m=1 a=2 r=9 op1=0 op2=0
Jul 6 08:43:25 nasty kernel: [ 12.974002] raid5: raid level 5 set md127 active with 8 out of 9 devices, algorithm 2
Run Code Online (Sandbox Code Playgroud)
不幸的是,这未被识别,现在另一个驱动器被踢(sde):
Jul 14 08:02:45 nasty kernel: [ 12.918556] md: bind<sdc>
Jul 14 08:02:45 nasty kernel: [ 12.919043] md: bind<sdd>
Jul 14 08:02:45 nasty kernel: [ 12.919158] md: bind<sde>
Jul 14 08:02:45 nasty kernel: [ 12.919260] md: bind<sdf>
Jul 14 08:02:45 nasty kernel: [ 12.919361] md: bind<sdg>
Jul 14 08:02:45 nasty kernel: [ 12.919461] md: bind<sdh>
Jul 14 08:02:45 nasty kernel: [ 12.919556] md: bind<sdi>
Jul 14 08:02:45 nasty kernel: [ 12.919641] md: bind<sdj>
Jul 14 08:02:45 nasty kernel: [ 12.919756] md: bind<sda>
Jul 14 08:02:45 nasty kernel: [ 12.919775] md: kicking non-fresh sdi from array!
Jul 14 08:02:45 nasty kernel: [ 12.919781] md: unbind<sdi>
Jul 14 08:02:45 nasty kernel: [ 12.928177] md: export_rdev(sdi)
Jul 14 08:02:45 nasty kernel: [ 12.928187] md: kicking non-fresh sde from array!
Jul 14 08:02:45 nasty kernel: [ 12.928198] md: unbind<sde>
Jul 14 08:02:45 nasty kernel: [ 12.936064] md: export_rdev(sde)
Jul 14 08:02:45 nasty kernel: [ 12.943900] raid5: device sda operational as raid disk 0
Jul 14 08:02:45 nasty kernel: [ 12.943904] raid5: device sdj operational as raid disk 8
Jul 14 08:02:45 nasty kernel: [ 12.943907] raid5: device sdh operational as raid disk 6
Jul 14 08:02:45 nasty kernel: [ 12.943909] raid5: device sdg operational as raid disk 5
Jul 14 08:02:45 nasty kernel: [ 12.943911] raid5: device sdf operational as raid disk 4
Jul 14 08:02:45 nasty kernel: [ 12.943914] raid5: device sdd operational as raid disk 2
Jul 14 08:02:45 nasty kernel: [ 12.943916] raid5: device sdc operational as raid disk 1
Jul 14 08:02:45 nasty kernel: [ 12.944776] raid5: allocated 9542kB for md127
Jul 14 08:02:45 nasty kernel: [ 12.944861] 0: w=1 pa=0 pr=9 m=1 a=2 r=9 op1=0 op2=0
Jul 14 08:02:45 nasty kernel: [ 12.944864] 8: w=2 pa=0 pr=9 m=1 a=2 r=9 op1=0 op2=0
Jul 14 08:02:45 nasty kernel: [ 12.944867] 6: w=3 pa=0 pr=9 m=1 a=2 r=9 op1=0 op2=0
Jul 14 08:02:45 nasty kernel: [ 12.944871] 5: w=4 pa=0 pr=9 m=1 a=2 r=9 op1=0 op2=0
Jul 14 08:02:45 nasty kernel: [ 12.944874] 4: w=5 pa=0 pr=9 m=1 a=2 r=9 op1=0 op2=0
Jul 14 08:02:45 nasty kernel: [ 12.944877] 2: w=6 pa=0 pr=9 m=1 a=2 r=9 op1=0 op2=0
Jul 14 08:02:45 nasty kernel: [ 12.944879] 1: w=7 pa=0 pr=9 m=1 a=2 r=9 op1=0 op2=0
Jul 14 08:02:45 nasty kernel: [ 12.944882] raid5: not enough operational devices for md127 (2/9 failed)
Run Code Online (Sandbox Code Playgroud)
现在阵列不再启动。然而,似乎每个磁盘都包含 raid 元数据:
/dev/sda:
Magic : a92b4efc
Version : 1.2
Feature Map : 0x0
Array UUID : b8a04dbb:0b5dffda:601eb40d:d2dc37c9
Name : nasty:stuff (local to host nasty)
Creation Time : Sun Mar 16 02:37:47 2014
Raid Level : raid5
Raid Devices : 9
Avail Dev Size : 7814035120 (3726.02 GiB 4000.79 GB)
Array Size : 62512275456 (29808.18 GiB 32006.29 GB)
Used Dev Size : 7814034432 (3726.02 GiB 4000.79 GB)
Data Offset : 2048 sectors
Super Offset : 8 sectors
State : clean
Device UUID : 8600bda9:18845be8:02187ecc:1bfad83a
Update Time : Mon Jul 14 00:45:35 2014
Checksum : e38d46e8 - correct
Events : 123132
Layout : left-symmetric
Chunk Size : 512K
Device Role : Active device 0
Array State : AAA.AAA.A ('A' == active, '.' == missing)
/dev/sdc:
Magic : a92b4efc
Version : 1.2
Feature Map : 0x0
Array UUID : b8a04dbb:0b5dffda:601eb40d:d2dc37c9
Name : nasty:stuff (local to host nasty)
Creation Time : Sun Mar 16 02:37:47 2014
Raid Level : raid5
Raid Devices : 9
Avail Dev Size : 7814035120 (3726.02 GiB 4000.79 GB)
Array Size : 62512275456 (29808.18 GiB 32006.29 GB)
Used Dev Size : 7814034432 (3726.02 GiB 4000.79 GB)
Data Offset : 2048 sectors
Super Offset : 8 sectors
State : clean
Device UUID : fe612c05:f7a45b0a:e28feafe:891b2bda
Update Time : Mon Jul 14 00:45:35 2014
Checksum : 32bb628e - correct
Events : 123132
Layout : left-symmetric
Chunk Size : 512K
Device Role : Active device 1
Array State : AAA.AAA.A ('A' == active, '.' == missing)
/dev/sdd:
Magic : a92b4efc
Version : 1.2
Feature Map : 0x0
Array UUID : b8a04dbb:0b5dffda:601eb40d:d2dc37c9
Name : nasty:stuff (local to host nasty)
Creation Time : Sun Mar 16 02:37:47 2014
Raid Level : raid5
Raid Devices : 9
Avail Dev Size : 7814035120 (3726.02 GiB 4000.79 GB)
Array Size : 62512275456 (29808.18 GiB 32006.29 GB)
Used Dev Size : 7814034432 (3726.02 GiB 4000.79 GB)
Data Offset : 2048 sectors
Super Offset : 8 sectors
State : clean
Device UUID : 1d14616c:d30cadc7:6d042bb3:0d7f6631
Update Time : Mon Jul 14 00:45:35 2014
Checksum : 62bd5499 - correct
Events : 123132
Layout : left-symmetric
Chunk Size : 512K
Device Role : Active device 2
Array State : AAA.AAA.A ('A' == active, '.' == missing)
/dev/sde:
Magic : a92b4efc
Version : 1.2
Feature Map : 0x0
Array UUID : b8a04dbb:0b5dffda:601eb40d:d2dc37c9
Name : nasty:stuff (local to host nasty)
Creation Time : Sun Mar 16 02:37:47 2014
Raid Level : raid5
Raid Devices : 9
Avail Dev Size : 7814035120 (3726.02 GiB 4000.79 GB)
Array Size : 62512275456 (29808.18 GiB 32006.29 GB)
Used Dev Size : 7814034432 (3726.02 GiB 4000.79 GB)
Data Offset : 2048 sectors
Super Offset : 8 sectors
State : active
Device UUID : a2babca3:1283654a:ef8075b5:aaf5d209
Update Time : Mon Jul 14 00:45:07 2014
Checksum : f78d6456 - correct
Events : 123123
Layout : left-symmetric
Chunk Size : 512K
Device Role : Active device 3
Array State : AAAAAAA.A ('A' == active, '.' == missing)
/dev/sdf:
Magic : a92b4efc
Version : 1.2
Feature Map : 0x0
Array UUID : b8a04dbb:0b5dffda:601eb40d:d2dc37c9
Name : nasty:stuff (local to host nasty)
Creation Time : Sun Mar 16 02:37:47 2014
Raid Level : raid5
Raid Devices : 9
Avail Dev Size : 7814035120 (3726.02 GiB 4000.79 GB)
Array Size : 62512275456 (29808.18 GiB 32006.29 GB)
Used Dev Size : 7814034432 (3726.02 GiB 4000.79 GB)
Data Offset : 2048 sectors
Super Offset : 8 sectors
State : clean
Device UUID : e67d566d:92aaafb4:24f5f16e:5ceb0db7
Update Time : Mon Jul 14 00:45:35 2014
Checksum : 9223b929 - correct
Events : 123132
Layout : left-symmetric
Chunk Size : 512K
Device Role : Active device 4
Array State : AAA.AAA.A ('A' == active, '.' == missing)
/dev/sdg:
Magic : a92b4efc
Version : 1.2
Feature Map : 0x0
Array UUID : b8a04dbb:0b5dffda:601eb40d:d2dc37c9
Name : nasty:stuff (local to host nasty)
Creation Time : Sun Mar 16 02:37:47 2014
Raid Level : raid5
Raid Devices : 9
Avail Dev Size : 7814035120 (3726.02 GiB 4000.79 GB)
Array Size : 62512275456 (29808.18 GiB 32006.29 GB)
Used Dev Size : 7814034432 (3726.02 GiB 4000.79 GB)
Data Offset : 2048 sectors
Super Offset : 8 sectors
State : clean
Device UUID : 2cee1d71:16c27acc:43e80d02:1da74eeb
Update Time : Mon Jul 14 00:45:35 2014
Checksum : 7512efd4 - correct
Events : 123132
Layout : left-symmetric
Chunk Size : 512K
Device Role : Active device 5
Array State : AAA.AAA.A ('A' == active, '.' == missing)
/dev/sdh:
Magic : a92b4efc
Version : 1.2
Feature Map : 0x0
Array UUID : b8a04dbb:0b5dffda:601eb40d:d2dc37c9
Name : nasty:stuff (local to host nasty)
Creation Time : Sun Mar 16 02:37:47 2014
Raid Level : raid5
Raid Devices : 9
Avail Dev Size : 7814035120 (3726.02 GiB 4000.79 GB)
Array Size : 62512275456 (29808.18 GiB 32006.29 GB)
Used Dev Size : 7814034432 (3726.02 GiB 4000.79 GB)
Data Offset : 2048 sectors
Super Offset : 8 sectors
State : clean
Device UUID : c239f0ad:336cdb88:62c5ff46:c36ea5f8
Update Time : Mon Jul 14 00:45:35 2014
Checksum : c08e8a4d - correct
Events : 123132
Layout : left-symmetric
Chunk Size : 512K
Device Role : Active device 6
Array State : AAA.AAA.A ('A' == active, '.' == missing)
/dev/sdi:
Magic : a92b4efc
Version : 1.2
Feature Map : 0x0
Array UUID : b8a04dbb:0b5dffda:601eb40d:d2dc37c9
Name : nasty:stuff (local to host nasty)
Creation Time : Sun Mar 16 02:37:47 2014
Raid Level : raid5
Raid Devices : 9
Avail Dev Size : 7814035120 (3726.02 GiB 4000.79 GB)
Array Size : 62512275456 (29808.18 GiB 32006.29 GB)
Used Dev Size : 7814034432 (3726.02 GiB 4000.79 GB)
Data Offset : 2048 sectors
Super Offset : 8 sectors
State : active
Device UUID : d06c58f8:370a0535:b7e51073:f121f58c
Update Time : Mon Jul 14 00:45:07 2014
Checksum : 77844dcc - correct
Events : 0
Layout : left-symmetric
Chunk Size : 512K
Device Role : spare
Array State : AAAAAAA.A ('A' == active, '.' == missing)
/dev/sdj:
Magic : a92b4efc
Version : 1.2
Feature Map : 0x0
Array UUID : b8a04dbb:0b5dffda:601eb40d:d2dc37c9
Name : nasty:stuff (local to host nasty)
Creation Time : Sun Mar 16 02:37:47 2014
Raid Level : raid5
Raid Devices : 9
Avail Dev Size : 7814035120 (3726.02 GiB 4000.79 GB)
Array Size : 62512275456 (29808.18 GiB 32006.29 GB)
Used Dev Size : 7814034432 (3726.02 GiB 4000.79 GB)
Data Offset : 2048 sectors
Super Offset : 8 sectors
State : clean
Device UUID : f2de262f:49d17fea:b9a475c1:b0cad0b7
Update Time : Mon Jul 14 00:45:35 2014
Checksum : dd0acfd9 - correct
Events : 123132
Layout : left-symmetric
Chunk Size : 512K
Device Role : Active device 8
Array State : AAA.AAA.A ('A' == active, '.' == missing)
Run Code Online (Sandbox Code Playgroud)
但是正如您所看到的,两个驱动器(sde、sdi)都处于活动状态(但 raid 已停止)而 sdi 是备用驱动器。虽然 sde 的 Events-count 比大多数其他驱动器(123123 而不是 123132)略低,但 sdi 的 Events-count 为 0。所以我认为 sde 几乎是最新的。但是sdi不是...
现在我们在网上读到,硬关机可能会导致这些“踢非新鲜”消息。事实上,我的朋友导致硬断电一两次。所以我们按照我们在网上找到的说明,尝试将 sde 重新添加到数组中:
$ mdadm /dev/md127 --add /dev/sde
mdadm: add new device failed for /dev/sde as 9: Invalid argument
Run Code Online (Sandbox Code Playgroud)
但这失败了,现在mdadm --examine /dev/sdesde 的 Events-count 也显示为 0(+ 它现在像 sdi 一样是备用的):
/dev/sde:
Magic : a92b4efc
Version : 1.2
Feature Map : 0x0
Array UUID : b8a04dbb:0b5dffda:601eb40d:d2dc37c9
Name : nasty:stuff (local to host nasty)
Creation Time : Sun Mar 16 02:37:47 2014
Raid Level : raid5
Raid Devices : 9
Avail Dev Size : 7814035120 (3726.02 GiB 4000.79 GB)
Array Size : 62512275456 (29808.18 GiB 32006.29 GB)
Used Dev Size : 7814034432 (3726.02 GiB 4000.79 GB)
Data Offset : 2048 sectors
Super Offset : 8 sectors
State : clean
Device UUID : 689e0030:142122ae:7ab37935:c80ab400
Update Time : Mon Jul 14 00:45:35 2014
Checksum : 5e6c4cf7 - correct
Events : 0
Layout : left-symmetric
Chunk Size : 512K
Device Role : spare
Array State : AAA.AAA.A ('A' == active, '.' == missing)
Run Code Online (Sandbox Code Playgroud)
我们知道,2 个故障驱动器通常意味着raid5 的死亡。但是,有没有办法至少将 sde 添加到 raid 中,以便可以保存数据?
好的,看起来我们现在可以访问突袭了。至少第一个检查的文件看起来不错。所以这是我们所做的:
在RAID重建的文章在kernel.org维基提出了我们的问题,有两种可能的解决方案:
使用--assemble --force(也被derobert提到)
文章说:
[...] 如果事件计数相差小于 50,则驱动器上的信息可能仍然没问题。[...] 如果事件计数紧密匹配但不完全匹配,请使用“mdadm --assemble --force /dev/mdX”强制 mdadm 组装数组 [...]。如果驱动器的事件计数远远超出 [...],则该驱动器 [...] 不应包含在程序集中。
在我们的例子中,驱动器sde的事件差异为 9。所以很有可能--force会起作用。然而,在我们执行--add命令后,事件计数下降到 0,驱动器被标记为备用。
所以我们最好不要使用--force.
重新创建数组
此解决方案被明确标记为危险,因为如果您做错了什么,您可能会丢失数据。然而,这似乎是我们唯一的选择。
这个想法是在现有的raid设备上创建一个新的raid(即覆盖设备的超级块),使用与旧raid相同的配置,并明确告诉mdadm该raid已经存在并且应该被假定为干净的。
由于事件计数差异仅为 9,唯一的问题是我们丢失了超级块,sde因为编写新的超级块很有可能让我们访问我们的数据......它奏效了 :-)
注意:此解决方案专门针对我们的问题,可能不适用于您的设置。您应该记下这些笔记以了解如何完成工作。但是你需要研究什么是最适合你的情况。
备份
我们已经丢失了一个超级块。所以这次我们sd[acdefghij]在进行raid 之前使用dd保存了每个raid 设备( )的第一个和最后一个GB 。我们为每个 RAID 设备执行了此操作:
# save the first gigabyte of sda
dd if=/dev/sda of=bak_sda_start bs=4096 count=262144
# determine the size of the device
fdisk -l /dev/sda
# In this case the size was 4000787030016 byte.
# To get the last gigabyte we need to skip everything except the last gigabyte.
# So we need to skip: 4000787030016 byte - 1073741824 byte = 3999713288000 byte
# Since we read blocks auf 4096 byte we need to skip 3999713288000/4096=976492502 blocks.
dd if=/dev/sda of=bak_sda_end bs=4096 skip=976492502
Run Code Online (Sandbox Code Playgroud)
收集信息
重新创建raid 时,使用与旧raid 相同的配置很重要。如果您想使用不同的 mdadm 版本在另一台机器上重新创建阵列,这一点尤其重要。在这种情况下,mdadm 的默认值可能会有所不同,并且可能会创建不适合现有团队的超级块(请参阅 wiki 文章)。
在我们的例子中,我们使用同一台机器(因此使用相同的 mdadm 版本)来重新创建数组。然而,该阵列首先是由第 3 方工具创建的。所以我们不想在这里依赖默认值,而不得不收集一些关于现有突袭的信息。
从mdadm --examine /dev/sd[acdefghij]我们的输出中,我们获得了以下有关突袭的信息(注意:sdb 是包含操作系统的 ssd,而不是突袭的一部分):
Raid Level : raid5
Raid Devices : 9
Used Dev Size : 7814034432 (3726.02 GiB 4000.79 GB)
Data Offset : 2048 sectors
Super Offset : 8 sectors
Layout : left-symmetric
Chunk Size : 512K
Device Role : Active device 0
Run Code Online (Sandbox Code Playgroud)
的Used Dev Size是在512字节的块计价。您可以检查一下:
7814034432*512/1000000000 ~= 4000.79
但是 mdadm 需要以 Kibibytes 为单位的大小:7814034432*512/1024 = 3907017216
重要的是Device Role. 在新的raid 中,每个设备都必须具有与以前相同的角色。在我们的例子中:
device role
------ ----
sda 0
sdc 1
sdd 2
sde 3
sdf 4
sdg 5
sdh 6
sdi spare
sdj 8
Run Code Online (Sandbox Code Playgroud)
注意:重新启动后驱动器号(以及顺序)可以更改!
下一步我们还需要布局和块大小。
重新创建raid
我们现在可以使用上一步的信息重新创建数组:
mdadm --create --assume-clean --level=5 --raid-devices=9 --size=3907017216 \
--chunk=512 --layout=left-symmetric /dev/md127 /dev/sda /dev/sdc /dev/sdd \
/dev/sde /dev/sdf /dev/sdg /dev/sdh missing /dev/sdj
Run Code Online (Sandbox Code Playgroud)
以正确的顺序传递设备很重要!
此外,我们没有添加,sdi因为它的事件计数太低。所以我们将第 7 个突袭插槽设置为missing。因此,raid5 包含 9 个设备中的 8 个,并将以降级模式组装。并且因为它缺少备用设备,所以不会自动开始重建。
然后我们用来--examine检查新的超级块是否适合我们的旧超级块。它确实做到了 :-) 我们能够挂载文件系统并读取数据。下一步是备份数据,然后重新添加sdi并开始重建。
| 归档时间: |
|
| 查看次数: |
4368 次 |
| 最近记录: |