如何处理损坏的 ZFS 池

如何处理损坏的 ZFS 池

一直在运行使用 ZFS 的 NAS 测试实例,如使用 ZFS RAIDZ 恢复 Ubuntu 服务器数据

本周我的一个磁盘坏了。应该没什么问题,对吧(RAID 的优点是弹性和性能)?

但我的 ZFS 池已损坏,如下所示:

andy@ubuntu:~$ sudo zpool status -v
  pool: tank
 state: UNAVAIL
status: One or more devices could not be used because the label is missing
        or invalid.  There are insufficient replicas for the pool to continue
        functioning.
action: Destroy and re-create the pool from
        a backup source.
   see: http://www.sun.com/msg/ZFS-8000-5E
  scan: none requested
config:

    NAME        STATE     READ WRITE CKSUM
    tank        UNAVAIL      0     0     0  insufficient replicas
      raidz1-0  UNAVAIL      0     0     0  insufficient replicas
        sdb     FAULTED      0     0     0  corrupted data
        sdc     FAULTED      0     0     0  corrupted data
        sdd     UNAVAIL      0     0     0

幸运的是,这是一个测试实例,所以我可以轻松地重新开始。但是,如果这个池包含重要数据怎么办?下一步该怎么做才能恢复数据并恢复 NAS 正常工作?或者 ZFS 会自动尝试所有可能的恢复方法,这样数据现在就完蛋了?

答案1

在@slashdot 的帮助下,我基本上解决了我的问题,但我真的不知道我做了什么。请检查以下线索并给我一些启发。

特别是下列哪些假设是正确的或者我遗漏了什么?

  1. 既没有zdb -u tankzdb -dcsv tank任何有用的事。
  2. zpool import -f tank第一个方法失败时第二个方法成功了,因为已经过去了足够的时间, zpool export tankZFS 才有机会自我修复。
  3. 整个事件与其中一个驱动器出现故障后标签自行改变有关(认为是 sdb 导致了 sdc>sdb 和 sdd>sdb)。

日志

andy@ubuntu:~$ zpool status
andy@ubuntu:~$ sudo zpool status
  pool: tank
 state: UNAVAIL
status: One or more devices could not be used because the label is missing
        or invalid.  There are insufficient replicas for the pool to continue
        functioning.
action: Destroy and re-create the pool from
        a backup source.
   see: http://www.sun.com/msg/ZFS-8000-5E
  scan: none requested
config:

        NAME        STATE     READ WRITE CKSUM
        tank        UNAVAIL      0     0     0  insufficient replicas
          raidz1-0  UNAVAIL      0     0     0  insufficient replicas
            sdb     FAULTED      0     0     0  corrupted data
            sdc     FAULTED      0     0     0  corrupted data
            sdd     UNAVAIL      0     0     0
andy@ubuntu:~$ sudo zdb -u tank
zdb: can't open 'tank': No such device or address
andy@ubuntu:~$ sudo zpool scrub tank
cannot scrub 'tank': pool is currently unavailable
andy@ubuntu:~$ sudo zdb -bcsv tank
zdb: can't open 'tank': No such device or address
andy@ubuntu:~$ sudo zpool export tank
andy@ubuntu:~$ sudo zpool import tank
cannot import 'tank': pool may be in use from other system
use '-f' to import anyway
andy@ubuntu:~$ sudo zpool import -f tank
cannot import 'tank': one or more devices is currently unavailable
andy@ubuntu:~$ sudo zpool status
no pools available
andy@ubuntu:~$ sudo zpool status -x
no pools available
andy@ubuntu:~$ sudo zpool import
  pool: tank
    id: 9117894036185671023
 state: UNAVAIL
status: One or more devices contains corrupted data.
action: The pool cannot be imported due to damaged devices or data.
   see: http://www.sun.com/msg/ZFS-8000-5E
config:

        tank        UNAVAIL  insufficient replicas
          raidz1-0  UNAVAIL  insufficient replicas
            sdb     FAULTED  corrupted data
            sdb     UNAVAIL
            sdc     ONLINE
andy@ubuntu:~$ sudo zpool import tank
cannot import 'tank': pool may be in use from other system
use '-f' to import anyway
andy@ubuntu:~$ sudo zpool import -f tank
andy@ubuntu:~$ sudo zpool status
      pool: tank
 state: DEGRADED
status: One or more devices could not be used because the label is missing or
        invalid.  Sufficient replicas exist for the pool to continue
        functioning in a degraded state.
action: Replace the device using 'zpool replace'.
   see: http://www.sun.com/msg/ZFS-8000-4J
  scan: scrub repaired 0 in 0h13m with 0 errors on Mon Nov 21 09:22:11 2011
config:

        NAME                      STATE     READ WRITE CKSUM
        tank                      DEGRADED     0     0     0
          raidz1-0                DEGRADED     0     0     0
            10820373921989571629  UNAVAIL      0     0     0  was /dev/sdb1
            sdb                   ONLINE       0     0     0
            sdc                   ONLINE       0     0     0

errors: No known data errors
andy@ubuntu:~$

答案2

我认为之前的发帖者已经强调了这个问题。可能的原因是指定磁盘的方式。

我的经验是在 Ubuntu 上使用 ZFS。虽然我也在 freenas 上使用 ZFS,但我从未深入研究过 bsd 实现。

当然对于 Ubuntu,强烈建议您通过 id 而不是描述符来指定您的设备:即 /dev/disk/by-id/scsi-SATA-long 字符串,它唯一地标识物理磁盘而不是 /dev/sda。

使用 by-id 设备可消除对磁盘所连接的特定 SATA 端口的任何依赖。

加雷思

答案3

看起来您的池实际上可能没有损坏。虽然从输出来看,似乎有多个设备可能存在问题。我猜想多个磁盘可能处于可疑状态,因此 sdb 和 sdc 处于故障状态。找出它们可能存在的问题,您的池可能会证明您错了。这看起来不像是池的致命状态。

答案4

您能混合磁盘吗?

有一次我混淆了磁盘,zpool 提示“磁盘包含损坏的数据”。我按照之前的顺序连接磁盘后,它开始工作了。

也许在您导入 tank 后,zpool 识别了正确的序列。

相关内容