尽管有位图,为什么 mdadm 的 RAID-1 会从头开始重新同步?

Vi.*_*Vi. 6 raid mdadm

# cat /proc/mdstat 
Personalities : [raid1] 
md0 : active raid1 nbd0[3] sda10[0]
      53246315 blocks super 1.2 [3/1] [U__]
      [>....................]  recovery =  1.0% (537088/53246315) finish=203.0min speed=4326K/sec
      bitmap: 1/1 pages [4KB], 65536KB chunk

unused devices: <none>

# nbd-client -d /dev/nbd0
Disconnecting: que, disconnect, sock, done

# cat /proc/mdstat 
Personalities : [raid1] 
md0 : active raid1 nbd0[3](F) sda10[0]
      53246315 blocks super 1.2 [3/1] [U__]
      bitmap: 1/1 pages [4KB], 65536KB chunk

unused devices: <none>

# mdadm /dev/md/raidy --remove /dev/nbd0
mdadm: hot removed /dev/nbd0 from /dev/md/raidy

# nbd-client 10.99.99.250 7777 /dev/nbd0
Negotiation: ..size = 53247411KB
bs=1024, sz=53247411

# mdadm --incremental --run /dev/nbd0
mdadm: /dev/nbd0 attached to /dev/md/raidy which is already active.

# cat /proc/mdstat 
Personalities : [raid1] 
md0 : active raid1 nbd0[3] sda10[0]
      53246315 blocks super 1.2 [3/1] [U__]
      [>....................]  recovery =  0.0% (31616/53246315) finish=196.2min speed=4516K/sec
      bitmap: 1/1 pages [4KB], 65536KB chunk

unused devices: <none>

# uname -a
Linux vi-notebook 2.6.35-zen2-08220-g2c56b9e #14 ZEN PREEMPT Thu Oct 21 02:48:18 EEST 2010 i686 GNU/Linux

# mdadm --version
mdadm - v3.1.4 - 31
Run Code Online (Sandbox Code Playgroud)

如何正确断开并重新连接设备到 RAID-1 以利用写意图位图?

再次实验:

Personalities : [raid1] 
md0 : active raid1 nbd0[3] sda10[0]
      53246315 blocks super 1.2 [3/2] [UU_]
      bitmap: 1/1 pages [4KB], 65536KB chunk

unused devices: <none>

    /dev/md/raidy:
        Version : 1.2
  Creation Time : Tue Mar 30 05:42:53 2010
     Raid Level : raid1
     Array Size : 53246315 (50.78 GiB 54.52 GB)
  Used Dev Size : 53246315 (50.78 GiB 54.52 GB)
   Raid Devices : 3
  Total Devices : 2
    Persistence : Superblock is persistent

  Intent Bitmap : Internal

    Update Time : Mon Jan 31 18:18:03 2011
          State : active, degraded
 Active Devices : 2
Working Devices : 2
 Failed Devices : 0
  Spare Devices : 0

           Name : vi-notebook:0  (local to host vi-notebook)
           UUID : bc325b24:fa0a4957:47820c56:fc818fa3
         Events : 2661551

    Number   Major   Minor   RaidDevice State
       0       8       10        0      active sync   /dev/sda10
       3      43        0        1      active sync   /dev/nbd0
       2       0        0        2      removed
Run Code Online (Sandbox Code Playgroud)

现在删除其中一个设备:

# mdadm /dev/md/raidy --fail /dev/nbd0 
mdadm: set /dev/nbd0 faulty in /dev/md/raidy
# mdadm /dev/md/raidy --remove /dev/nbd0 
mdadm: hot removed /dev/nbd0 from /dev/md/raidy
Run Code Online (Sandbox Code Playgroud)

现在重新添加它:

mdadm --incremental --run /dev/nbd0
Run Code Online (Sandbox Code Playgroud)

它从头开始重新同步:

Personalities : [raid1] 
md0 : active raid1 nbd0[3] sda10[0]
      53246315 blocks super 1.2 [3/1] [U__]
      [>....................]  recovery =  0.4% (244480/53246315) finish=289.5min speed=3050K/sec
      bitmap: 1/1 pages [4KB], 65536KB chunk

unused devices: <none>


/dev/md/raidy:
        Version : 1.2
  Creation Time : Tue Mar 30 05:42:53 2010
     Raid Level : raid1
     Array Size : 53246315 (50.78 GiB 54.52 GB)
  Used Dev Size : 53246315 (50.78 GiB 54.52 GB)
   Raid Devices : 3
  Total Devices : 2
    Persistence : Superblock is persistent

  Intent Bitmap : Internal

    Update Time : Mon Jan 31 18:22:07 2011
          State : active, degraded, recovering
 Active Devices : 1
Working Devices : 2
 Failed Devices : 0
  Spare Devices : 1

 Rebuild Status : 0% complete

           Name : vi-notebook:0  (local to host vi-notebook)
           UUID : bc325b24:fa0a4957:47820c56:fc818fa3
         Events : 2661666

    Number   Major   Minor   RaidDevice State
       0       8       10        0      active sync   /dev/sda10
       3      43        0        1      spare rebuilding   /dev/nbd0
       2       0        0        2      removed
Run Code Online (Sandbox Code Playgroud)

Chr*_*ell 2

嗯。查看上面的输出,并不清楚您首先是否有多个同步磁盘。看起来有一个正在同步的磁盘发生故障,该磁盘已被删除,然后重新添加,然后再次重新同步。我从来没有看到过显示 2 个磁盘已完全同步的显示屏。

我会确保两个磁盘都处于活动状态,让它们完全同步,只有在验证之后我才会尝试删除磁盘并重新添加它。

请注意,写意图位图仅有助于快速重新同步两个已经几乎同步的磁盘(即在系统崩溃后,或在短时间内移除磁盘时)。它不适用于长期删除或尚未完全同步的磁盘。