其他分享
首页 > 其他分享> > zfs存储池的磁盘管理,镜像盘拆成两个单盘(容量翻倍),两块单盘做成镜像盘(镜像数据)

zfs存储池的磁盘管理,镜像盘拆成两个单盘(容量翻倍),两块单盘做成镜像盘(镜像数据)

作者:互联网

mirror镜像盘拆成两个单盘:detach之后再add原来那个pool就行了。

单盘做成镜像:remove之后attach原有的磁盘。

简单讲讲4个命令的用途:

add和remove相对,从pool中添加和移除一个盘(准确的说是分区,下同)。

attach和detach相对,attach,不仅加入了同一个组,还组成镜像了。detach就是从镜像组中抽出了1个盘。

 

怎么理解?add,简单地物理地放在一起。attach,有接触地在一起,attach之后的两个磁盘。

 

所以,镜像盘拆成两个单盘的操作就是:detach + add;两个单盘改成镜像盘,就是:remove + attach

root@pve1:~# zpool status
  pool: rpool
 state: ONLINE
  scan: resilvered 1.19G in 00:00:09 with 0 errors on Wed Jun  1 12:38:57 2022
remove: Removal of vdev 2 copied 308K in 0h0m, completed on Wed Jun  1 12:38:24 2022
    1.52K memory used for removed device mappings
config:

    NAME          STATE     READ WRITE CKSUM
    rpool         ONLINE       0     0     0
      mirror-0    ONLINE       0     0     0
        sda3      ONLINE       0     0     0
        sdb3      ONLINE       0     0     0

errors: No known data errors
root@pve1:~# zpool detach rpool sdb3
root@pve1:~# zpool add rpool sdb3
root@pve1:~# zpool status
  pool: rpool
 state: ONLINE
  scan: resilvered 1.19G in 00:00:09 with 0 errors on Wed Jun  1 12:38:57 2022
remove: Removal of vdev 2 copied 308K in 0h0m, completed on Wed Jun  1 12:38:24 2022
    1.52K memory used for removed device mappings
config:

    NAME          STATE     READ WRITE CKSUM
    rpool         ONLINE       0     0     0
      sda3        ONLINE       0     0     0
      sdb3        ONLINE       0     0     0

errors: No known data errors

此时的磁盘大小,就是sda3和sdb3两个分区加起来的大小了

root@pve1:~# df -h /
Filesystem        Size  Used Avail Use% Mounted on
rpool/ROOT/pve-1  123G  1.2G  121G   1% /
root@pve1:~# zpool list
NAME    SIZE  ALLOC   FREE  CKPOINT  EXPANDSZ   FRAG    CAP  DEDUP    HEALTH  ALTROOT
rpool   126G  1.15G   125G        -         -     0%     0%  1.00x    ONLINE  -

再组合回去作镜像?

root@pve1:~# zpool remove rpool sdb3
root@pve1:~# zpool attach rpool sda3 sdb3
root@pve1:~# zpool status
  pool: rpool
 state: ONLINE
status: One or more devices is currently being resilvered.  The pool will
    continue to function, possibly in a degraded state.
action: Wait for the resilver to complete.
  scan: resilver in progress since Wed Jun  1 13:02:59 2022
    1.15G scanned at 294M/s, 621M issued at 155M/s, 1.15G total
    635M resilvered, 52.72% done, 00:00:03 to go
remove: Removal of vdev 4 copied 64K in 0h0m, completed on Wed Jun  1 13:02:27 2022
    2.37K memory used for removed device mappings
config:

    NAME          STATE     READ WRITE CKSUM
    rpool         ONLINE       0     0     0
      mirror-0    ONLINE       0     0     0
        sda3      ONLINE       0     0     0
        sdb3      ONLINE       0     0     0  (resilvering)

errors: No known data errors

attach回去的时候要指定attach(镜像)的是哪块盘,我上面的是sda3。

稍稍等待,它自动同步数据,已完成。

root@pve1:~# zpool status
  pool: rpool
 state: ONLINE
  scan: resilvered 1.19G in 00:00:08 with 0 errors on Wed Jun  1 13:03:07 2022
remove: Removal of vdev 4 copied 64K in 0h0m, completed on Wed Jun  1 13:02:27 2022
    2.37K memory used for removed device mappings
config:

    NAME          STATE     READ WRITE CKSUM
    rpool         ONLINE       0     0     0
      mirror-0    ONLINE       0     0     0
        sda3      ONLINE       0     0     0
        sdb3      ONLINE       0     0     0

errors: No known data errors

打完收工。

另外补充一点:

如果你当初安装pve时填写的邮箱是真实的话,mirror数据同步完成之后,你会收到一封已完成的邮件,比如这样的:

 

标签:拆成,rpool,errors,单盘,pve1,ONLINE,镜像,root
来源: https://www.cnblogs.com/Levo8561/p/16333943.html