扩大 ZFS 镜像

扩大 ZFS 镜像

我有一个 ZFS 池,其中有 6 个磁盘,采用 RAID 10 配置。

我想将其中一个镜像中的驱动器从 1TB 升级到 3TB。我已将所有驱动器安装在系统中。

我会比较喜欢不是通过更换一个驱动器、重新镀银、重复来做到这一点。有没有办法从现有镜像执行所有读取,同时保留我要移除的驱动器上的所有磨损?

root@e7-4860:~# zpool status
  pool: stuffpoll
 state: ONLINE
  scan: scrub repaired 0 in 6h50m with 0 errors on Sun Dec 10 07:14:34 2017
config:

    NAME                                               STATE     READ WRITE CKSUM
    stuffpoll                                          ONLINE       0     0     0
      mirror-0                                         ONLINE       0     0     0
        ata-HGST_HTS721010A9E630_JR10004M0LGN6E-part1  ONLINE       0     0     0
        ata-HGST_HTS721010A9E630_JR10004M0M17TE-part1  ONLINE       0     0     0
      mirror-1                                         ONLINE       0     0     0
        ata-HGST_HTS541010A9E680_JA1000102MG9UR-part1  ONLINE       0     0     0
        ata-HGST_HTS541010A9E680_JA1009C03158BP-part1  ONLINE       0     0     0
      mirror-2                                         ONLINE       0     0     0
        ata-HGST_HTS721010A9E630_JR100X6P2TJKVE        ONLINE       0     0     0
        ata-HGST_HTS721010A9E630_JR100Y4M01200M        ONLINE       0     0     0

errors: No known data errors


root@e7-4860:~# zpool list
NAME        SIZE  ALLOC   FREE  EXPANDSZ   FRAG    CAP  DEDUP  HEALTH  ALTROOT
stuffpoll  2.72T  2.47T   254G         -    48%    90%  1.00x  ONLINE  -


root@e7-4860:~# ls /dev/disk/by-id/ -1
ata-CT240BX200SSD1_1613F0194817
ata-CT240BX200SSD1_1613F0194817-part1
ata-HGST_HTS541010A9E680_JA1000102MG9UR
ata-HGST_HTS541010A9E680_JA1000102MG9UR-part1
ata-HGST_HTS541010A9E680_JA1000102MG9UR-part9
ata-HGST_HTS541010A9E680_JA1009C03158BP
ata-HGST_HTS541010A9E680_JA1009C03158BP-part1
ata-HGST_HTS541010A9E680_JA1009C03158BP-part9
ata-HGST_HTS721010A9E630_JR10004M0LGN6E
ata-HGST_HTS721010A9E630_JR10004M0LGN6E-part1
ata-HGST_HTS721010A9E630_JR10004M0LGN6E-part9
ata-HGST_HTS721010A9E630_JR10004M0M17TE
ata-HGST_HTS721010A9E630_JR10004M0M17TE-part1
ata-HGST_HTS721010A9E630_JR10004M0M17TE-part9
ata-HGST_HTS721010A9E630_JR100X6P2TJKVE
ata-HGST_HTS721010A9E630_JR100X6P2TJKVE-part1
ata-HGST_HTS721010A9E630_JR100X6P2TJKVE-part9
ata-HGST_HTS721010A9E630_JR100Y4M01200M
ata-HGST_HTS721010A9E630_JR100Y4M01200M-part1
ata-HGST_HTS721010A9E630_JR100Y4M01200M-part9
scsi-35000c50055fb009b
scsi-35000c50055fb395f

我最终希望用mirror-1scsi-35000c50055fb009b替换驱动器scsi-35000c50055fb395f

答案1

如果您想手动扩展卷,您只需使用该-e选项将其联机即可。

zpool online -e stuffpoll

您还可以切换自动扩展选项以使其自动发生。

zpool set autoexpand=on stuffpoll

假设您要向镜像 2 添加新驱动器,以便对其进行扩展。您需要使用现有设备名称之一作为目标来连接新驱动器。您可以在移除旧设备之前将两个新设备都添加到镜像中。

# zpool attach pool existing_vdev_member new_device
zpool attach stuffpoll ata-HGST_HTS721010A9E630_JR100X6P2TJKVE new_dev1
zpool attach stuffpoll ata-HGST_HTS721010A9E630_JR100X6P2TJKVE new_dev2

新设备同步完成后,您可以删除旧设备。

zpool detach stuffpoll ata-HGST_HTS721010A9E630_JR100X6P2TJKVE
zpool detach stuffpoll ata-HGST_HTS721010A9E630_JR100Y4M01200M

人zpool

zpool attach [-f] pool device new_device

Attaches new_device to an existing zpool device. The existing device
cannot be part of a raidz configuration. If device is not currently
part of a mirrored configuration, device automatically transforms
into a two-way mirror of device and new_device.  If device is part of
a two-way mirror, attaching new_device creates a three-way mirror,
and so on. In either case, new_device begins to resilver immediately.
...

zpool detach pool device

Detaches device from a mirror.  The operation is refused if there are
no other valid replicas of the data.  If device may be re-added to
the pool later on then consider the zpool offline command instead.
...

zpool online [-e] pool device ...

Brings the specified physical device online.
-e  Expand the device to use all available space. If the device
    is part of a mirror or raidz then all devices must be
    expanded before the new space will become available to the
    pool.

链接

另外,我想提醒大家。首先验证您的备份/恢复。总有可能发生不好的事情。还可以考虑在测试机器/虚拟机上构建 zfs 池并提前练习您的命令。

相关内容