确定可以替换设备后,可以使用 zpool replace 命令替换设备。如果要用不同的设备替换损坏的设备,请使用类似以下的语法:
# zpool replace tank c1t1d0 c2t0d0 |
此命令将数据从损坏的设备或从池中的其他设备(如果处于冗余配置中)迁移到新设备。此命令完成后,将从配置中拆离损坏的设备,此时可以将该设备从系统中移除。如果已移除设备并在同一位置中将它替换为新设备,请使用命令的单设备形式。例如:
# zpool replace tank c1t1d0 |
此命令接受未格式化的磁盘,适当地将它格式化,然后重新同步其余配置中的数据。
有关 zpool replace 命令的更多信息,请参见替换存储池中的设备。
以下示例说明如何替换 Oracle Sun Fire x4500 系统上的镜像存储池 tank 中的设备 (c1t3d0)。要在同一位置将磁盘 c1t3d0 替换为新磁盘 (c1t3d0),尝试替换磁盘之前必须取消磁盘配置。基本步骤如下:
使要替换的磁盘 (c1t3d0) 脱机。您不能取消配置当前正在使用的磁盘。
使用 cfgadm 命令确定要取消配置的磁盘 (c1t3d0) 并取消其配置。如果磁盘在此镜像配置中脱机,该池将降级,但该池将继续可用。
物理替换磁盘 (c1t3d0)。在物理移除故障驱动器之前,请确保蓝色的可以移除 LED 指示灯亮起。
重新配置磁盘 (c1t3d0)。
使新磁盘 (c1t3d0) 联机。
运行 zpool replace 命令以替换磁盘 (c1t3d0)。
如果先前将池属性 autoreplace 设置为 on,则会自动对在先前属于池的设备的同一物理位置处找到的任何新设备进行格式化和替换,而无需使用 zpool replace 命令。此功能可能并不是在所有硬件上都受支持。
如果已使用热备件自动替换了故障磁盘,则您可能需要在替换故障磁盘后分离该热备件。例如,如果替换故障磁盘后,c2t4d0 仍为活动热备件,则对其进行分离。
# zpool detach tank c2t4d0 |
以下示例分步显示了替换 ZFS 存储池中的磁盘的过程。
# zpool offline tank c1t3d0 # cfgadm | grep c1t3d0 sata1/3::dsk/c1t3d0 disk connected configured ok # cfgadm -c unconfigure sata1/3 Unconfigure the device at: /devices/pci@0,0/pci1022,7458@2/pci11ab,11ab@1:3 This operation will suspend activity on the SATA device Continue (yes/no)? yes # cfgadm | grep sata1/3 sata1/3 disk connected unconfigured ok <Physically replace the failed disk c1t3d0> # cfgadm -c configure sata1/3 # cfgadm | grep sata1/3 sata1/3::dsk/c1t3d0 disk connected configured ok # zpool online tank c1t3d0 # zpool replace tank c1t3d0 # zpool status tank pool: tank state: ONLINE scrub: resilver completed after 0h0m with 0 errors on Tue Feb 2 13:17:32 2010 config: NAME STATE READ WRITE CKSUM tank ONLINE 0 0 0 mirror-0 ONLINE 0 0 0 c0t1d0 ONLINE 0 0 0 c1t1d0 ONLINE 0 0 0 mirror-1 ONLINE 0 0 0 c0t2d0 ONLINE 0 0 0 c1t2d0 ONLINE 0 0 0 mirror-2 ONLINE 0 0 0 c0t3d0 ONLINE 0 0 0 c1t3d0 ONLINE 0 0 0 errors: No known data errors |
请注意,上述 zpool output 可能会在 replacing 标题下显示新磁盘和旧磁盘。例如:
replacing DEGRADED 0 0 0 c1t3d0s0/o FAULTED 0 0 0 c1t3d0 ONLINE 0 0 0 |
此文本表示替换过程正在进行,且新磁盘正在重新同步。
如果您打算将一个磁盘 (c1t3d0) 替换为另一个磁盘 (c4t3d0),则只需运行 zpool replace 命令。例如:
# zpool replace tank c1t3d0 c4t3d0 # zpool status pool: tank state: DEGRADED scrub: resilver completed after 0h0m with 0 errors on Tue Feb 2 13:35:41 2010 config: NAME STATE READ WRITE CKSUM tank DEGRADED 0 0 0 mirror-0 ONLINE 0 0 0 c0t1d0 ONLINE 0 0 0 c1t1d0 ONLINE 0 0 0 mirror-1 ONLINE 0 0 0 c0t2d0 ONLINE 0 0 0 c1t2d0 ONLINE 0 0 0 mirror-2 DEGRADED 0 0 0 c0t3d0 ONLINE 0 0 0 replacing DEGRADED 0 0 0 c1t3d0 OFFLINE 0 0 0 c4t3d0 ONLINE 0 0 0 errors: No known data errors |
磁盘替换完成之前,您可能需要多次运行 zpool status 命令。
# zpool status tank pool: tank state: ONLINE scrub: resilver completed after 0h0m with 0 errors on Tue Feb 2 13:35:41 2010 config: NAME STATE READ WRITE CKSUM tank ONLINE 0 0 0 mirror-0 ONLINE 0 0 0 c0t1d0 ONLINE 0 0 0 c1t1d0 ONLINE 0 0 0 mirror-1 ONLINE 0 0 0 c0t2d0 ONLINE 0 0 0 c1t2d0 ONLINE 0 0 0 mirror-2 ONLINE 0 0 0 c0t3d0 ONLINE 0 0 0 c4t3d0 ONLINE 0 0 0 |
以下示例说明如何从存储池 (pool) 中出现故障的日志设备 (c0t5d0) 进行恢复。基本步骤如下:
查看 zpool status -x 输出和 FMA 诊断消息。有关说明,请参见以下页面:
物理更换出现故障的日志设备。
使新日志设备联机。
清除池的错误状态。
# zpool status -x pool: pool state: FAULTED status: One or more of the intent logs could not be read. Waiting for adminstrator intervention to fix the faulted pool. action: Either restore the affected device(s) and run 'zpool online', or ignore the intent log records by running 'zpool clear'. scrub: none requested config: NAME STATE READ WRITE CKSUM pool FAULTED 0 0 0 bad intent log mirror ONLINE 0 0 0 c0t1d0 ONLINE 0 0 0 c0t4d0 ONLINE 0 0 0 logs FAULTED 0 0 0 bad intent log c0t5d0 UNAVAIL 0 0 0 cannot open <Physically replace the failed log device> # zpool online pool c0t5d0 # zpool clear pool |
# zpool status -x pool: pool state: FAULTED status: One or more of the intent logs could not be read. Waiting for adminstrator intervention to fix the faulted pool. action: Either restore the affected device(s) and run 'zpool online', or ignore the intent log records by running 'zpool clear'. scrub: none requested config: NAME STATE READ WRITE CKSUM pool FAULTED 0 0 0 bad intent log mirror-0 ONLINE 0 0 0 c0t1d0 ONLINE 0 0 0 c0t4d0 ONLINE 0 0 0 logs FAULTED 0 0 0 bad intent log c0t5d0 UNAVAIL 0 0 0 cannot open <Physically replace the failed log device> # zpool online pool c0t5d0 # zpool clear pool |