建立删除卷
1 2 3 4 5 6 | [root @cahesi ~] zpool create testzpool raidz -f vda vdb [root @cahesi ~] # zpool list NAME SIZE ALLOC FREE EXPANDSZ FRAG CAP DEDUP HEALTH ALTROOT testzpool 59.5G 128K 59.5G - 0% 0% 1.00x ONLINE - [root @cahesi ~] zfs destroy testzpool |
追加硬盘
1 2 3 4 5 | [root @cahesi ~] # zpool add testzpool vdc -f [root @cahesi ~] # [root @cahesi ~] # zpool list NAME SIZE ALLOC FREE EXPANDSZ FRAG CAP DEDUP HEALTH ALTROOT testzpool 89.2G 200K 89.2G - 0% 0% 1.00x ONLINE - |
看目前池状态
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | [root @cahesi ~] # zpool status pool: testzpool state: ONLINE scan: none requested config: NAME STATE READ WRITE CKSUM testzpool ONLINE 0 0 0 raidz1-0 ONLINE 0 0 0 vda ONLINE 0 0 0 vdb ONLINE 0 0 0 vdc ONLINE 0 0 0 errors: No known data errors |
查看健康状况
1 2 3 4 5 6 7 8 9 10 11 | [root @cahesi ~] # zpool status -x all pools are healthy [root @cahesi ~] # zpool list -o name,size NAME SIZE testzpool 89.2G [root @cahesi ~] # zfs list -o name,sharenfs,mountpoint NAME SHARENFS MOUNTPOINT testzpool off /testzpool |
查看存储迟IO情况
1 2 3 4 5 | [root @cahesi ~] # zpool iostat capacity operations bandwidth pool alloc free read write read write ---------- ----- ----- ----- ----- ----- ----- testzpool 128K 59.5G 0 0 0 68 |
每2秒中显示一次tank迟IO情况
1 | [root @cahesi ~] # zpool iostat testzpool 2 |
显示虚拟设备IO情况
1 2 3 4 5 6 7 8 | [root @cahesi ~] # zpool iostat -v capacity operations bandwidth pool used avail read write read write ---------- ----- ----- ----- ----- ----- ----- tank 30.2M 149M 0 1 387 47.0K c2t0d0 16.1M 73.4M 0 2 654 111K c2t1d0 14.1M 75.4M 0 0 253 23.6K ---------- ----- ----- ----- ----- ----- ----- |
每两秒显示虚拟设备IO情况
1 | [root @cahesi ~] # zpool iostat -v 2 |
消除设备错误计数
迁移ZFS存储池
导出池
1 | [root @cahesi ~] # zpool export tank |
查看池
1 2 3 4 5 6 7 8 9 10 11 | [root @cahesi ~] # zpool import pool: testzpool id: 12510319395011747835 state: ONLINE action: The pool can be imported using its name or numeric identifier. config: testzpool ONLINE raidz1-0 ONLINE vda ONLINE vdb ONLINE |
导入池
1 2 | [root @cahesi ~] # zpool import testzpool (如果池名与目前有冲突可以使用新命名来导入如:zpool import tank tanker) |
查看ZFS自动安装点属性
1 2 3 | [root @cahesi ~] # zfs get mountpoint testzpool NAME PROPERTY VALUE SOURCE testzpool mountpoint /testzpool default |
查看是否自动安装上
1 2 3 | [root @cahesi ~] # zfs get mounted testzpool NAME PROPERTY VALUE SOURCE testzpool mounted yes - |
手工改变安装点
1 2 3 4 5 6 7 8 | [root @cahesi ~] # zfs set mountpoint=/cahesi testzpool [root @cahesi ~] # zfs get mountpoint testzpool NAME PROPERTY VALUE SOURCE testzpool mountpoint /cahesi local mountpoint 属性更改时,文件系统将自动从旧挂载点取消挂载,并重新挂载到新挂载点。根据需要,可 创建挂载点目录。如果ZFS 由于处于活动状态而无法取消挂载文件系统,则会报告错误,并需要强制进行 手动取消挂载。 |
显示当前挂接ZFS的情况
1 | [root @cahesi ~] # zfs mount |
恢复已删除的池
删除池
1 2 3 | [root @cahesi ~] # zpool destroy testzpool [root @cahesi ~] # zpool list no pools available |
zpool import已经无法发现tank池(使用-D参数可看到已经删除的池)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | [root @cahesi ~] # zpool import no pools available to import [root @cahesi ~] # zpool import -D pool: testzpool id: 12510319395011747835 state: FAULTED (DESTROYED) status: The pool metadata is corrupted. action: The pool cannot be imported due to damaged devices or data. The pool was destroyed, but can be imported using the '-Df' flags. see: http://zfsonlinux.org/msg/ZFS-8000-72 config: testzpool FAULTED corrupted data vdc ONLINE pool: testzpool id: 16891872618171120764 state: ONLINE (DESTROYED) action: The pool can be imported using its name or numeric identifier. config: testzpool ONLINE raidz1-0 ONLINE vda ONLINE vdb ONLINE |
如果有重名pool 则需要根据id来删除。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | [root @cahesi ~] # zpool import -Df testzpool cannot import 'testzpool' : more than one matching pool import by numeric ID instead [root @cahesi ~] # zpool import -Df 16891872618171120764 [root @cahesi ~] # zpool import -D pool: testzpool id: 12510319395011747835 state: FAULTED (DESTROYED) status: The pool metadata is corrupted. action: The pool cannot be imported due to damaged devices or data. The pool was destroyed, but can be imported using the '-Df' flags. see: http://zfsonlinux.org/msg/ZFS-8000-72 config: testzpool FAULTED corrupted data vdc ONLINE |
给已存在的zpool增加cache 盘
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | [root @cahesi /] # zpool status pool: testzpool state: ONLINE scan: none requested config: NAME STATE READ WRITE CKSUM testzpool ONLINE 0 0 0 raidz1-0 ONLINE 0 0 0 vda ONLINE 0 0 0 vdb ONLINE 0 0 0 errors: No known data errors [root @cahesi /] # zpool add testzpool cache vdc [root @cahesi /] # zpool status pool: testzpool state: ONLINE scan: none requested config: NAME STATE READ WRITE CKSUM testzpool ONLINE 0 0 0 raidz1-0 ONLINE 0 0 0 vda ONLINE 0 0 0 vdb ONLINE 0 0 0 cache vdc ONLINE 0 0 0 errors: No known data errors |