如果池元数据发生损坏,并且该损坏导致池无法打开或导入,则可以使用以下选项:
可以尝试使用 zpool clear –F 命令或 zpool import – F 命令恢复池。这些命令尝试回滚最后几次池事务,使其回到运行状态。可以使用 zpool status 命令查看损坏的池和建议的恢复步骤。例如:
# zpool status pool: tpool state: UNAVAIL status: The pool metadata is corrupted and the pool cannot be opened. action: Recovery is possible, but will result in some data loss. Returning the pool to its state as of Fri Jun 29 17:22:49 2012 should correct the problem. Approximately 5 seconds of data must be discarded, irreversibly. Recovery can be attempted by executing 'zpool clear -F tpool'. A scrub of the pool is strongly recommended after recovery. see: http://support.oracle.com/msg/ZFS-8000-72 scrub: none requested config: NAME STATE READ WRITE CKSUM tpool UNAVAIL 0 0 1 corrupted data c1t1d0 ONLINE 0 0 2 c1t3d0 ONLINE 0 0 4
前面的输出中描述的恢复过程要使用以下命令:
# zpool clear -F tpool
如果您尝试导入损坏的存储池,将会看到类似如下的消息:
# zpool import tpool cannot import 'tpool': I/O error Recovery is possible, but will result in some data loss. Returning the pool to its state as of Fri Jun 29 17:22:49 2012 should correct the problem. Approximately 5 seconds of data must be discarded, irreversibly. Recovery can be attempted by executing 'zpool import -F tpool'. A scrub of the pool is strongly recommended after recovery.
前面的输出中描述的恢复过程要使用以下命令:
# zpool import -F tpool Pool tpool returned to its state as of Fri Jun 29 17:22:49 2012. Discarded approximately 5 seconds of transactions
如果损坏的池位于 zpool.cache 文件中,则系统引导时会发现该问题,并通过 zpool status 命令报告损坏的池。如果该池不在 zpool.cache 文件中,它将无法成功导入或打开,当您尝试导入该池时,会看到池受损消息。
您可以在只读模式下导入受损的池。此方法使您可以导入该池,从而可以访问数据。例如:
# zpool import -o readonly=on tpool
有关在只读模式下导入池的更多信息,请参见在只读模式下导入池。
您可以使用 zpool import –m 命令导入缺少日志设备的池。有关更多信息,请参见导入缺少日志设备的池。
如果无法使用上述池恢复方法恢复池,则必须从备份副本中恢复池及其所有数据。所用的机制通常随池配置和备份策略的不同而有很大差别。首先,保存 zpool status 命令所显示的配置,以便在销毁池后可以重新创建它。然后,使用 zpool destroy –f 命令销毁池。
此外,将描述数据集布局以及各个本地设置的属性的文件保存在某个安全位置,否则如果池出现无法访问的情况,将无法访问这些信息。使用池配置和数据集布局,可以在销毁池后重新构造完整的配置。然后可以使用任何备份或恢复策略填充数据。