ZFS 存储池 - 替换坏/旧设备

好风 发表于 2016-11-18T08:08:55.852756Z
引用地址:https://plus.ooclab.com/note/article/1301

替换设备

准备实验环境

创建存储池:

[root@ooclab ~]# zpool create stor1 raidz2 vdb vdc vdd vde vdf
[root@ooclab ~]# zpool status
  pool: stor1
 state: ONLINE
  scan: none requested
config:

        NAME        STATE     READ WRITE CKSUM
        stor1       ONLINE       0     0     0
          raidz2-0  ONLINE       0     0     0
            vdb     ONLINE       0     0     0
            vdc     ONLINE       0     0     0
            vdd     ONLINE       0     0     0
            vde     ONLINE       0     0     0
            vdf     ONLINE       0     0     0

errors: No known data errors

操作示例

假设 /dev/vde 磁盘损坏,需要替换新盘(插槽不变)

第一步:设置 vde 为 offline :

[root@ooclab ~]# zpool offline stor1 vde
[root@ooclab ~]# zpool status
  pool: stor1
 state: DEGRADED
status: One or more devices has been taken offline by the administrator.
        Sufficient replicas exist for the pool to continue functioning in a
        degraded state.
action: Online the device using 'zpool online' or replace the device with
        'zpool replace'.
  scan: none requested
config:

        NAME        STATE     READ WRITE CKSUM
        stor1       DEGRADED     0     0     0
          raidz2-0  DEGRADED     0     0     0
            vdb     ONLINE       0     0     0
            vdc     ONLINE       0     0     0
            vdd     ONLINE       0     0     0
            vde     OFFLINE      0     0     0
            vdf     ONLINE       0     0     0

errors: No known data errors

第二步:拔出就的 vde 盘,插入新盘(KVM只要关系,重新创建磁盘文件即可)

第三步:运行 replace 命令

zpool replace -f stor1 vde

如果数据量大, zpool status 能看到 resilvering

等待完成:

[root@localhost ~]# zpool status
  pool: stor1
 state: ONLINE
  scan: resilvered 31.5K in 0h0m with 0 errors on Fri Nov 18 08:07:09 2016
config:

        NAME        STATE     READ WRITE CKSUM
        stor1       ONLINE       0     0     0
          raidz2-0  ONLINE       0     0     0
            vdb     ONLINE       0     0     0
            vdc     ONLINE       0     0     0
            vdd     ONLINE       0     0     0
            vde     ONLINE       0     0     0
            vdf     ONLINE       0     0     0

errors: No known data errors