ZFS 存储池 - attach / detach

好风 发表于 2016-11-18T06:12:27.523072Z
引用地址:https://plus.ooclab.com/note/article/1299

前言

实验环境请参看 ZFS 学习 中的描述。

attach / detach

使用方法:

attach [-f] [-o property=value] <pool> <device> <new-device>
detach <pool> <device>

创建存储池 stor1 ,含2个 mirror 虚拟设备(vdev) ( vdb、vdc 组成 mirror-0; vdd、vde 组成 mirror-1 ) :

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

        NAME        STATE     READ WRITE CKSUM
        stor1       ONLINE       0     0     0
          mirror-0  ONLINE       0     0     0
            vdb     ONLINE       0     0     0
            vdc     ONLINE       0     0     0
          mirror-1  ONLINE       0     0     0
            vdd     ONLINE       0     0     0
            vde     ONLINE       0     0     0

errors: No known data errors

detach 磁盘 vde :

[root@ooclab ~]# zpool detach stor1 vde
[root@ooclab ~]# zpool status
  pool: stor1
 state: ONLINE
  scan: none requested
config:

        NAME        STATE     READ WRITE CKSUM
        stor1       ONLINE       0     0     0
          mirror-0  ONLINE       0     0     0
            vdb     ONLINE       0     0     0
            vdc     ONLINE       0     0     0
          vdd       ONLINE       0     0     0

errors: No known data errors

attach vde 到 mirror-0 (使用 sdb 或 sdc 作为前导盘皆可):

[root@ooclab ~]# zpool attach stor1 vdb vde
[root@ooclab ~]# zpool status
  pool: stor1
 state: ONLINE
  scan: resilvered 23.5K in 0h0m with 0 errors on Fri Nov 18 07:29:40 2016
config:

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

errors: No known data errors

detach vde 并 attach 到 vdd 上:

[root@ooclab ~]# zpool detach stor1 vde
[root@ooclab ~]# zpool attach stor1 vdd vde
[root@ooclab ~]# zpool status
  pool: stor1
 state: ONLINE
  scan: resilvered 49.5K in 0h0m with 0 errors on Fri Nov 18 07:30:46 2016
config:

        NAME        STATE     READ WRITE CKSUM
        stor1       ONLINE       0     0     0
          mirror-0  ONLINE       0     0     0
            vdb     ONLINE       0     0     0
            vdc     ONLINE       0     0     0
          mirror-1  ONLINE       0     0     0
            vdd     ONLINE       0     0     0
            vde     ONLINE       0     0     0

errors: No known data errors