例3:添加磁盘到一个镜像ZFS
$ zpool add mpool mirror c0t3d0 c1t3d0 $ zpool status mpool pool: mpool state: ONLINE scrub: none requested config: NAME STATE READ WRITE CKSUM mpool 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 0Added mirrored device. c0t3d0 ONLINE 0 0 0 c1t3d0 ONLINE 0 0 0 errors: No known data errors
例4:添加磁盘到一个RAID-Z配置中
$ zpool add rzpool raidz c2t2d0 c2t3d0 c2t4d0 $ zpool status rzpool pool: rzpool state: ONLINE scrub: none requested config: NAME STATE READ WRITE CKSUM rzpool ONLINE 0 0 0 raidz1-0 ONLINE 0 0 0 c1t2d0 ONLINE 0 0 0 c1t3d0 ONLINE 0 0 0 c1t4d0 ONLINE 0 0 0 raidz1-1 ONLINE 0 0 0Added RAID-Z device. c2t2d0 ONLINE 0 0 0 c2t3d0 ONLINE 0 0 0 c2t4d0 ONLINE 0 0 0 errors: No known data errors
例5:添加一个镜像的日志设备
$ zpool add newpool log mirror c0t6d0 c0t7d0 $ zpool status newpool pool: newpool state: ONLINE scrub: none requested config: NAME STATE READ WRITE CKSUM newpool ONLINE 0 0 0 mirror-0 ONLINE 0 0 0 c0t4d0 ONLINE 0 0 0 c0t5d0 ONLINE 0 0 0 logsAdded mirrored log device. mirror-1 ONLINE 0 0 0 c0t6d0 ONLINE 0 0 0 c0t7d0 ONLINE 0 0 0 errors: No known data errors
例6:添加缓存设备
$ zpool add system1 cache c2t5d0 c2t8d0 $ zpool status system1 pool: system1 state: ONLINE scrub: none requested config: NAME STATE READ WRITE CKSUM system1 ONLINE 0 0 0 mirror-0 ONLINE 0 0 0 c2t0d0 ONLINE 0 0 0 c2t1d0 ONLINE 0 0 0 c2t3d0 ONLINE 0 0 0 cacheAdded cache device. c2t5d0 ONLINE 0 0 0 c2t8d0 ONLINE 0 0 0 errors: No known data errors
例7:删除顶级虚拟数据设备
$ zpool remove mpool mirror-1 mirror-2 $ zpool status mpool pool: mpool state: ONLINE status: One or more devices is currently being removed. action: Wait for the resilver to complete. Run 'zpool status -v' to see device specific details. scan: resilver in progress since Mon Jul 7 18:19:35 2014 16.7G scanned 884M resilvered at 52.6M/s, 9.94% done, 0h1m to go config: NAME STATE READ WRITE CKSUM mpool ONLINE 0 0 0 mirror-0 ONLINE 0 0 0 c0t1d0 ONLINE 0 0 0 c1t1d0 ONLINE 0 0 0 mirror-1 REMOVING 0 0 0 c0t2d0 ONLINE 0 0 0 c1t2d0 ONLINE 0 0 0 mirror-2 REMOVING 0 0 0 c0t3d0 ONLINE 0 0 0 c1t3d0 ONLINE 0 0 0 + + errors: No known data errors $ zpool status mpool pool: mpool state: ONLINE scrub: none requested config: NAME STATE READ WRITE CKSUM mirror-0 ONLINE 0 0 0 c0t1d0 ONLINE 0 0 0 c1t1d0 ONLINE 0 0 0 errors: No known data errors
例8:删除镜像的日志设备
$ zpool remove newpool mirror-1 $ zpool status newpool pool: newpool state: ONLINE scrub: none requested config: NAME STATE READ WRITE CKSUM newpool ONLINE 0 0 0 mirror-0 ONLINE 0 0 0 c0t4d0 ONLINE 0 0 0 c0t5d0 ONLINE 0 0 0 errors: No known data errors
例9:删除缓存设备
$ zpool remove system1 c2t5d0 c2t8d0 $ zpool status system1 pool: system1 state: ONLINE scrub: none requested config: NAME STATE READ WRITE CKSUM system1 ONLINE 0 0 0 mirror-0 ONLINE 0 0 0 c2t0d0 ONLINE 0 0 0 c2t1d0 ONLINE 0 0 0 c2t3d0 ONLINE 0 0 0 errors: No known data errors
使用
例10:将一个双路镜像存储池转换成三路镜像池
$ zpool attach mpool c1t1d0 c2t1d0 $ zpool status mpool pool: mpool state: ONLINE scrub: resilver completed after 0h0m with 0 errors on Fri Jan 8 12:59:20 2010 config: NAME STATE READ WRITE CKSUM mpool ONLINE 0 0 0 mirror-0 ONLINE 0 0 0 c0t1d0 ONLINE 0 0 0 c1t1d0 ONLINE 0 0 0 c2t1d0 ONLINE 0 0 0592K resilveredAttached device creates a 3-way mirror pool errors: No known data errors
例11:将一个没有冗余的存储池转换成镜像池
$ zpool status system1 pool: system1 state: ONLINE scrub: none requested config: NAME STATE READ WRITE CKSUM system1 ONLINE 0 0 0 c0t1d0 ONLINE 0 0 0 errors: No known data errors $ zpool attach system1 c0t1d0 c1t1d0 $ zpool status system1 pool: system1 state: ONLINE scrub: resilver completed after 0h0m with 0 errors on Fri Jan 8 14:28:23 2010 config: NAME STATE READ WRITE CKSUM system1 ONLINE 0 0 0Pool becomes mirrored mirror-0 ONLINE 0 0 0 c0t1d0 ONLINE 0 0 0 c1t1d0 ONLINE 0 0 073.5K resilvered errors: No known data errors
如果没有指定设备,默认的会分离出池的虚拟设备中的最后一个设备,用它创建一个新池。
如果池有多个顶级虚拟设备,则这个命令会从每一个虚拟设备分离一个磁盘以创建新池。
如果是拆分一个含有三块硬盘的单一顶级设备,则从第三个硬盘创建的新池是没有冗余的。要将新池转换成冗余配置,需要连接新设备。
拆分镜像池之前应确保以下几点:
例12:分离一个镜像池
镜像存储池
$ zpool status poolA pool: poolA state: ONLINE scan: none requested config: NAME STATE READ WRITE CKSUM poolA ONLINE 0 0 0 mirror-0 ONLINE 0 0 0 c0t0d0 ONLINE 0 0 0 c0t1d0 ONLINE 0 0 0 c0t2d0 ONLINE 0 0 0 errors: No known data errors $ zpool split poolA poolB $ zpool import luna $ zpool status poolA poolB pool: luna state: ONLINE scan: none requested config: NAME STATE READ WRITE CKSUM poolB ONLINE 0 0 0 c0t2d0 ONLINE 0 0 0 errors: No known data errors pool: poolA state: ONLINE scan: none requested config: NAME STATE READ WRITE CKSUM poolA ONLINE 0 0 0 mirror-0 ONLINE 0 0 0 c0t0d0 ONLINE 0 0 0 c0t1d0 ONLINE 0 0 0 errors: No known data errors
$ zpool status system1 pool: system1 state: ONLINE scrub: none requested config: NAME STATE READ WRITE CKSUM system1 ONLINE 0 0 0 mirror ONLINE 0 0 0 c1t16d0 ONLINE 0 0 0 c1t17d0 ONLINE 0 0 0 $ zpool list system1 NAME SIZE ALLOC FREE CAP HEALTH ALTROOT system1 16.8G 76.5K 16.7G 0% ONLINE - $ zpool replace system1 c1t16d0 c1t1d0 $ zpool replace system1 c1t17d0 c1t2d0 $ zpool list system1 NAME SIZE ALLOC FREE CAP HEALTH ALTROOT system1 16.8G 88.5K 16.7G 0% ONLINE - $ zpool set autoexpand=on system1 $ zpool list system1 NAME SIZE ALLOC FREE CAP HEALTH ALTROOT system1 68.2G 117K 68.2G 0% ONLINE -
$ zpool status system1 mirror-1 DEGRADED 0 0 0 c0t5000C500335BD117d0 ONLINE 0 0 0 c0t5000C500335BA8C3d0 UNAVAIL 0 0 0Failed disk
$ zpool replace system1 c0t5000C500335BA8C3d0 $ zpool detach system1 c0t5000C500335E106Bd0 $ zpool status system1 mirror-1 ONLINE 0 0 0 c0t5000C500335BD117d0 ONLINE 0 0 0 c0t5000C500335DC60Fd0 ONLINE 0 0 0Replacement device spares c0t5000C500335E106Bd0 AVAILDeactivated spare $ fmadm faulty $ fmadm repaired zfs://pool=name/vdev=guid
$ zpool detach system1 c0t5000C500335BA8C3d0 $ zpool status system1 . . mirror-1 ONLINE 0 0 0 c0t5000C500335BD117d0 ONLINE 0 0 0 c0t5000C500335E106Bd0 ONLINE 0 0 0Spare replaces failed disk errors: No known data errors
$ zpool add system1 spare c0t5000C500335BA8C3d0 $ zpool status system1 . . mirror-1 ONLINE 0 0 0 c0t5000C500335BD117d0 ONLINE 0 0 0 c0t5000C500335E106Bd0 ONLINE 0 0 0Former spare spares c0t5000C500335BA8C3d0 AVAILRepaired disk as spare errors: No known data errors $ fmadm faulty $ fmadm repaired zfs://pool=name/vdev=guid
2021/12/10&11