zpool - 配置 ZFS 存储池
zpool [-?]
zpool help command | help | property property-name
zpool help -l properties
zpool add [-f] [-o property=value] ... [-n [-l]] pool vdev ...
zpool attach [-f] pool device new_device
zpool clear [-nF [-f]] pool [device]
zpool create [-f] [-n [-l]] [-B] [-N] [-o property=value] ... [-O file-system-property=value] ... [-m mountpoint] [-R root] pool vdev ...
zpool destroy [-f] pool
zpool detach pool device
zpool export [-f] pool ...
zpool get [-Hp] [-o all | field[,...]] [-s source[,...]] all | property[,...] pool ...
zpool history [-il] [pool] ...
zpool import [-d path ... | -c cachefile] [-D] [-l] [-S section[,...]] [-s all | field[,...]]
zpool import [-d path ... |-c cachefile] [-D] [-F [-n]] pool|id
zpool import [-o mntopts] [-o property=value] ... [-d path ... | -c cachefile] [-D] [-f] [-m] [-N] [-R root] [-F [-n]] -a pool|id [newpool]
zpool import [-o mntopts] [-o property=value] ... [-d path ... | -c cachefile] [-D] [-f] [-m] [-N] [-R root] [-F [-n [-l]]] [-t tmppool] pool|id [newpool]
zpool iostat [-T d|u] [-v [-l]] [pool] ... [interval [count]]
zpool label [-d path ... | -c cachefile] -C ...
zpool label [-d path ... | -c cachefile] -R ...
zpool list [-H] [-o property[,...]] [-T d|u] [pool] ... [interval [count]]
zpool monitor -t provider [-T d|u] [[-p] -o field[,...]] [pool] ... [interval [count]]
zpool offline [-t] pool device ...
zpool online [-e] pool device ...
zpool reguid pool
zpool remove pool device ...
zpool remove -s pool
zpool replace [-f] pool device [new_device]
zpool retained [-euanr] [-A | -f | [-p] -o field[,...]] [pool] ...
zpool scrub [-s] pool ...
zpool set property=value pool
zpool split [-n [-l]] [-R altroot] [-o mntopts] [-o property= value] pool newpool [device ...]
zpool status [-S section[,...]] [-s all | field[,...]] [-l] [-v] [ -x] [-T d|u] [pool] ... [ interval [count]]
zpool upgrade
zpool upgrade -v
zpool upgrade [-n] [-V version [-f]] -a | pool ...
zpool 命令配置 ZFS 存储池。存储池是一种设备集合,提供 ZFS 数据集的物理存储和数据复制。
存储池内的所有数据集共享同一个空间。有关管理数据集的信息,请参见 zfs(8)。
虚拟设备描述的是单个设备或者按特定的性能和故障特征组织的设备集合。支持的虚拟设备如下:
一种块设备,通常位于 /dev/dsk 下。ZFS 可以使用单个分片或分区,但推荐的操作模式是使用整个磁盘。可以通过全路径指定磁盘,也可以使用缩略名称(/dev/dsk 下的相对路径部分)。通过省略分片或分区部分,可以指定整个磁盘。或者,可以使用描述磁盘当前位置的 /dev/chassis/.../disk 路径指定整个磁盘。如果指定整个磁盘,ZFS 会在必要时自动为磁盘添加标签。
一种常规文件。强烈建议不要使用文件作为后备存储。它主要是为试验目的而设计的,因为文件的容错能力与其所属的文件系统相同。必须用全路径指定文件。
两个或更多设备的镜像。数据以完全相同的方式在一个镜像的所有组件之间进行复制。包含 N 个大小为 X 的磁盘的镜像可以存放 X 字节,并可承受 (N-1) 个设备故障而不会损害数据完整性。
RAID-5 的一种变体,可以更好地分配奇偶校验,消除“RAID-5 写入漏洞”(在这种漏洞中,数据和奇偶校验会在断电后变得不一致)。数据和奇偶校验在 raidz 组内的所有磁盘间呈条带分布。
A raidz group can have single-, double-, or triple parity, meaning that the raidz group can sustain one, two, or three failures, respectively, without losing any data.raidz1 vdev 类型指定单一奇偶校验 raidz 组,raidz2 vdev 类型指定双重奇偶校验 raidz 组,raidz3 vdev 类型指定三重奇偶校验 raidz 组。raidz vdev 类型是 raidz1 的一个别名。
一个包含 N 个大小为 X 的 raidz 组(其中有 P 个奇偶校验磁盘)可以存放大约 (N-P)*X 字节,并可承受 P 个设备故障而不会损害数据完整性。一个 raidz 组中的设备数量至少比奇偶校验磁盘数多一个。推荐的数量在 3 到 9 个之间,这有助于提高性能。
一种特殊的伪 vdev,可以跟踪池的可用热备件。有关更多信息,请参见“热备件”部分。
独立意图日志设备。如果指定了多个日志设备,则将在设备之间进行写负载平衡。可以镜像日志设备。但是,意图日志不支持 raidz vdev 类型。有关更多信息,请参见“意图日志”部分。
一种设备,用于优化某些类型的 ZFS 元数据(特别是重复数据删除条目)的读取。如果指定了多个元设备,则将在这些设备之间对操作进行负载平衡。元设备可以进行镜像。但是,不支持 raidz vdev 类型。有关更多信息,请参见“元设备”部分。
用于高速缓存存储池数据的设备。不能将高速缓存设备配置为镜像或 raidz 组。有关更多信息,请参见“高速缓存设备”部分。
虚拟设备不能嵌套,因此镜像或 raidz 虚拟设备只能包含文件或磁盘。不允许有镜像的镜像(或其他组合)。
A pool can have any number of virtual devices at the top of the configuration (known as top-level vdevs).数据在所有顶层设备间动态分布,以平衡设备间的数据。添加新的虚拟设备时,ZFS 自动将数据放在新近可用的设备上。
虚拟设备在命令行上是逐次指定的,多个虚拟设备间用空格分隔。关键字 mirror 和 raidz 用于区分一个组的结束和另一个组的开始。For example, the following creates two top-level vdevs, each a mirror of two disks:
# zpool create mypool mirror c0t0d0 c0t1d0 mirror c1t0d0 c1t1d0
或者,可以使用以下命令:
# zpool create tank \ mirror \ /dev/chassis/RACK29.U01-04/DISK_00/disk \ /dev/chassis/RACK29.U05-08/DISK_00/disk \ mirror \ /dev/chassis/RACK29.U01-04/DISK_01/disk \ /dev/chassis/RACK29.U05-08/DISK_01/disk
ZFS 支持一套丰富的机制,用于处理设备故障和数据损坏。会对所有元数据和数据进行校验和计算,在检测到数据损坏时,ZFS 会自动根据好的副本修复坏数据。
为了利用这些功能,池必须采用某种形式的冗余(使用镜像组或 raidz 组)。While ZFS supports running in a non-redundant configuration, where each top-level vdev is simply a disk or file, this is strongly discouraged as a single case of bit corruption can render some or all of your data unavailable.
池的运行状况通过以下状态之一来描述:
池中有一个或多个设备发生了故障,但由于有冗余配置,数据仍然可用。
池中的所有设备都正常运行。
池在等待设备连接恢复。在设备问题得到解决之前,挂起的池一直处于等待状态。
池中有损坏的元数据,或者有一个或多个设备不可用,并且没有足够的副本支持继续运行。
池未导入并且其实际状态尚未验证。此运行状况由 zpool label 命令使用。
使用 zpool label -C 命令至少清除了池中一个包含 ZFS 元数据的设备。无法导入清除的池。
顶层 vdev(如镜像或 raidz 设备)的运行状况可能会受与其关联的 vdev 或组件设备状态的影响。顶层 vdev 或组件设备处于以下状态之一:
一个或多个顶层 vdev 处于降级状态,因为有一个或多个组件设备脱机。有足够的副本支持继续运行。
一个或多个组件设备处于降级或故障状态,但有足够的副本支持继续运行。底层条件如下:
校验和错误的数量超出了可接受的程度,设备降级,这表明某个组件可能出现问题。ZFS 在必要时会继续使用该设备。
I/O 错误的数量超出了可接受的程度。不能将该设备标记为故障,因为还有足够的副本支持继续运行。
已通过 zpool offline 命令明确将设备置于脱机状态。
设备联机并正常运行。
正通过显式删除请求删除顶层 vdev。由于此 vdev 上的数据会迁移到池中的其余数据设备,因此系统性能可能会受影响。
系统正在运行时已物理移除了该设备。设备移除检测依赖于硬件,而且并非在所有平台上都受支持。
无法打开设备。如果在设备不可用时导入了某个池,则将用唯一标识符(而不是路径)标识该设备,因为最初的路径绝对不会正确。
设备当前未处于活动状态,但是其实际状态尚未验证。此状态由 zpool label 命令使用。
ZFS metadata on this device has been cleared by using the zpool label -C command.
如果移除设备后重新将其连接到系统,ZFS 会自动尝试将设备置于联机状态。设备连接检测依赖于硬件,而且并非在所有平台上都受支持。
ZFS 允许设备以热备件的方式与池关联。这些设备在池中的使用情况并不活跃,但在某个活动设备发生故障时,热备件会自动替换它。要创建带热备件的池,请对任意数量的设备指定 spare vdev。例如,
# zpool create pool mirror c0d0 c1d0 spare c2d0 c3d0
可以使用 zpool add 命令添加备件,使用 zpool remove 命令删除备件。一旦启动了备件替换,将在配置中创建一个新的备件 vdev,并且该备件将保留到原始设备被替换为止。此时,如果又有另外的设备发生故障,热备件将重新变得可用。
通过分离热备件,可以取消正在进行的备件替换。如果分离了原始故障设备,则热备件将取代故障备件在配置中的位置,并会从所有活动池的备件列表中移除。
如果以物理方式替换了原始故障设备、使其重新联机或者清除了错误(通过 FMA 事件或者通过使用 zpool online 或 zpool clear 命令),且原始设备的状态变为正常运行,则 INUSE 备件设备将再次变为 AVAIL。
备件不能替换日志设备或元设备。
ZFS 意图日志 (ZIL) 可满足同步事务的 POSIX 要求。例如,数据库通常要求其事务在从系统调用返回时在稳定的存储设备上。NFS 和其他应用程序也可以使用 fsync 来确保数据的稳定性。缺省情况下,意图日志是从主池内的块中分配的。但是,使用单独的意图日志设备(如 NVRAM 或专用磁盘)可能会获得更好的性能。例如:
# zpool create pool c0d0 c1d0 log c2d0
此外,还可以指定多个日志设备,并对它们进行镜像。有关镜像多个日志设备的示例,请参见“示例”部分。
可以将日志设备作为较大池的一部分添加、替换、附加、分离以及导入和导出。通过为日志指定顶层镜像,可以移除镜像日志设备。
可以将设备作为元设备添加到存储池中。这些设备可存储需要以非顺序方式访问的关键元数据的副本。此功能对重复数据删除条目特别有用。由于元数据的副本也会写入到主存储池,因此可以恢复此设备发生的 I/O 错误,并且不必对此设备进行镜像。
要创建具有元设备的池,请指定具有任意设备数量的元 vdev。例如:
# zpool create pool c0d0 c1d0 meta c2d0 c3d0
可以指定多个元设备,然后对这些元设备进行镜像,但这些设备不能是 raidz 配置的一部分。
可以将元设备作为较大池的一部分进行添加、替换、附加、分离、导入和导出。
可以将设备作为高速缓存设备添加到存储池中。这些设备在主内存和磁盘之间提供了一个进行高速缓存的附加层。对于读取操作量很大的工作负荷,当工作集大小比主内存中可高速缓存的内容大得多时,使用高速缓存设备可以通过低延迟介质处理此工作集的更大部分。使用高速缓存设备,可以最大程度地提高大多数静态内容的随机读取工作量的性能。
要创建带高速缓存设备的池,请对任意数量的设备指定 cache vdev。例如:
# zpool create pool c0d0 c1d0 cache c2d0 c3d0
高速缓存设备不能镜像,也不能成为 raidz 配置的一部分。如果高速缓存设备发生读取错误,则该读取 I/O 会重新发送给原始存储池设备(它可能是镜像配置或 raidz 配置的一部分)。
高速缓存设备的内容被认为具有易失性,其他系统的高速缓存也具有这个特点。
每个导入的池都有一个关联的进程 zpool- poolname。此进程中的线程是该池的 I/O 处理线程,该线程处理压缩、检验和操作以及与该池关联的所有 I/O 的其他任务。此进程的目的是呈现系统存储池的 CPU 使用率信息。此进程的存在形成了一个不稳定的接口。
每个池都有多个关联的属性。有些属性是只读的统计信息,而其他属性是可配置的,可以改变池的行为。以下是只读属性:
池中已实际分配的存储空间量。该属性也可通过其简短列名 alloc 来引用。
已用的池空间百分比。此属性也可通过其简短列名 cap 来引用。
为池指定的重复数据删除比率,用乘数因子表示。该值用一个十进制数表示。例如,dedupratio 值 1.76 表示存储了 1.76 个单位的数据,但实际消耗的磁盘空间只有 1 个单位。该属性也可通过其简短列名 dedup 来引用。
可按如下方式启用重复数据删除:
# zfs set dedup=on pool/ dataset
缺省值为 off(关闭)。
有关重复数据删除功能的说明,请参见 zfs(8)。
池中未分配的块的数量。
池的当前运行状况。Health can be ONLINE, DEGRADED, UNAVAIL, CLEARED, UNKNOWN, or SUSPENDED.
上一次成功清理的开始时间。
存储池的总大小。
这些空间使用属性报告存储池的实际可用物理空间。物理空间可能与空间总量不同,后者是所有包含的数据集可以实际使用的空间量。raidz 配置中使用的空间量取决于写入的数据的特征。此外,ZFS 会保留一些空间用于内部记帐,zfs(8) 命令会考虑这一点,但 zpool 命令则不会。对于合理大小的未满池,应该看不出这些影响。对于小型池,或者接近全满的池,这些差异可能会变得更加明显。
The following property can be set at creation time:
This sets the allocation unit ZFS will use to read and write from and to the vdev.In general this property should not need to be set by hand.The value for 'allocunit' must be a power of 2 number between 512 and 8192(8K).If an invalid or unsupported 'allocunit' is specified (for example a smaller 'allocunit' than the logical sectorsize of the device), an error will be returned.
Please note that the allocunit is used by zfs to do allocations and that has a consequence that allocated blocks that zfs write and read later will be aligned on this boundary.Overriding it manually may have performance and/or space usage implications, so it should not be done without a clear need for that.
以下属性可在创建或导入时设置:
Alternate root directory.如果进行了设置,则该目录会被前置到池中的任何挂载点。检查未知池(无法信任其中的挂载点)时,或在典型路径无效的备用启动环境中,可以使用此属性。altroot 不是持久属性。它仅在系统运行期间有效。设置 altroot 即表示缺省情况下使用 cachefile=none,但此设置可以使用显式设置来覆盖。
以下属性可在导入时设置:
控制是否可以修改池。启用后,在以读写模式导入池之前,任何仅存在于意图日志中的同步数据都不可访问。
以只读模式导入池具有以下限制:
导入期间试图设置其他池属性将被忽略。
所有文件系统挂载都将转换为包括只读 (ro) 挂载选项。
通过导出和导入池可将已以只读模式导入的池恢复为读写模式。
创建池时将自动设置以下属性。此属性通常无需手动设置,但以下情况除外:以某种方式克隆了池,从而导致 guid 值失去其唯一性。It can be reset on an imported pool with the zpool reguid command.
池的唯一标识符
以下属性可在创建时和导入时设置,并可在以后使用 zpool set 命令更改:
在底层 LUN 增长时控制自动池扩展。如果设置为 on,池将根据扩展设备的大小重新调整大小。如果设备是某个镜像或 raidz 的一部分,则在新空间对池可用之前,该镜像或 raidz 组内的所有设备都必须扩展。缺省行为为 off。该属性也可通过其简短列名 expand(扩展)来引用。
请勿使用 format 命令来获取 LUN 的新大小以及重新对其进行标记。zpool 将自动反映 LUN 的新大小。
控制设备的自动替换。如果设置为 off(关闭),则必须由管理员使用 zpool replace 命令来启动设备替换。如果设置为 on(打开),则会自动对与先前属于池的设备在同一物理位置的任何新设备进行格式化和替换。缺省行为为 off。此属性也可通过其简短列名 replace 来引用。
标识根池的缺省可引导数据集。此属性应主要通过安装和升级程序设置。
控制高速缓存池配置的位置。要在系统启动时发现所有池,需要存储在根文件系统上的配置数据的高速缓存副本。系统引导时会自动导入此高速缓存中的所有池。有些环境(如安装和群集)需要将此信息高速缓存在其他位置,从而使池不会被自动导入。设置此属性后,池配置将高速缓存在其他位置,以后可以使用 zpool import -c 将其导入。如果将其设置为特殊值 none(无),将创建一个永远不会高速缓存的临时池;如果设置为特殊值 ''(空字符串),则将使用缺省位置。
多个池可以共享同一个高速缓存文件。Because the kernel destroys and re-creates this file when pools are added and removed, care should be taken when attempting to access this file.在导出或销毁了最后一个使用 cachefile 的池后,将删除该文件。
控制是否将池作为全局池导入到 Oracle Solaris Cluster。只能在运行 Oracle Solaris Cluster 的系统上导入池时设置此属性。如果已导入池或者未安装并引导 Oracle Solaris Cluster,尝试设置此属性将失败。
如果此属性设置为 on,则会以全局方式挂载该池的所有文件系统,并且可以从群集的所有节点访问所有文件系统。缺省行为为 off。
目前,当文件系统以全局方式挂载时,设置某些 ZFS 属性会受到限制。当文件系统未挂载或挂载到本地时,允许设置下述属性;而当文件系统以全局方式挂载时,不允许设置这些属性。如果在这些上下文中进行设置,则属性将在后续进行全局重新挂载之后才会正常工作:
atime devices exec readonly rstchown setuid xattr sync canmount mountpoint zoned
ZFS 文件系统的 "zoned" 属性必须设置为 "off",全局挂载才能成功。尝试设置以全局方式挂载的 ZFS 文件系统的 "zoned" 属性将失败。
将来可能会解除上述部分限制。
设置副本数的阈值。如果某个消重后的块的引用数超过了此阈值,将自动存储该块的另一个相同副本。缺省值为 "0"。
控制是否根据在数据集上定义的数据集权限授予非特权用户访问权。缺省值为 on。有关 ZFS 委托管理的更多信息,请参见 zfs(8)。
控制在出现灾难性池故障时的系统行为。这种情况通常是由于失去与基础存储设备的连接或池中所有设备出现故障而导致的。此类事件的行为按以下方式确定:
阻止对池的所有 I/O 访问,直到恢复设备连接并清除错误。在设备问题得到解决之前,池一直处于 wait 状态。这是缺省行为。
使 EIO 返回到任何新的写入 I/O 请求,但允许对其余任何运行状况良好的设备执行读取操作。将会阻止必须提交到磁盘的任何写入请求。如果同时发生了其他池问题,此值仍可能会导致故障。
向控制台列显一则消息,并生成一个系统故障转储。
控制使用 zfs list 命令是否可显示此池中的共享信息。缺省值为 off(关闭)。
Controls whether information about snapshots associated with this pool is output when zfs list is run without the -t option.缺省值为 off(关闭)。该属性也可通过其简短列名 listsnaps 来引用。
Displays a count of filesystems within this pool that have mandatory retention and retained files.This count does not decrease when file retentions expire, but only when a mandatory retention filesystem is destroyed.
Displays the latest/last retention timestamp of mandatory retention filesystems in this pool.If that time has passed, the property will also display (expired) indicating that all file retentions have expired.
如果 scrubinterval 设置为 manual,将禁用清理调度。
如果 scrubinterval 设置为一个时间间隔,则自上次清理开始起经过此属性指定的时间后,将启动新清理,其中,上次清理是指已成功完成或通过 zpool scrub -s 显式取消的清理。
接受以下单位:s(秒,缺省值)、h(小时)、d(天)、w(周,7 天)m(月,30 天)和y(年,365 天);这些值在内部以秒为单位存储在属性中,但由 "zfs get" 以 s/h/d/w/m/y 显示。
只能使用一个单位,即,以下情况不允许:
# zpool set scrubinterval=1w3d
而是应表示为 10d。
默认值是 1m。
池的当前盘上版本。此版本可以提高,但绝不能降低。The preferred method of updating pools is with the zpool upgrade command, though this property can be used when a specific version is needed for backward compatibility.此属性可以是 1 与 zpool upgrade -v 所报告的当前版本之间的任何数值。
If the pool is a boot pool then this property can not be set with the zpool set command.
For reasons such as debugging, the zpool subcommands like import and status can report various device specific information using a -s option.This section lists those device specific properties that are currently supported and their descriptions.These properties are specific to the context it is reported in, for example if 'checksum' property is reported against a vdev that is a number of checksum errors detected specifically on that vdev
Allocation unit used by a vdev or a disk(toplevel).The allocated blocks that zfs write and read later will be aligned on this boundary.
Aliases: aunit
Total allocated space on a vdev or a disk.
Total allocatable space on a vdev or a disk.
Percentage of allocated space on a vdev or a disk.
Logical sector size reported by a disk.
Physical sector size reported by a disk.
Number of checksum errors detected by zfs.
Aliases: cksum
Name of the pool, a vdev or a disk.
Number of read errors detected by zfs.
State of the pool, a vdev or a disk.See 'Pool or Device Failure and Recovery' for details about various states.
Number of write errors detected by zfs.
These properties are boolean, but only reported if it is active.
Display whether a repair is currently running for a vdev or a disk.
Aliases: rpair
Display whether a resilver is currently running for a vdev or a disk.
Aliases: rslvr
Display whether a disk and a vdev marked as slow.
修改状态的所有子命令将以原始形式永久记录到池中。
zpool 命令提供了一些子命令,可以创建和销毁存储池,为存储池增加容量,以及提供有关存储池的信息。支持以下子命令:
显示帮助消息。
显示 zpool 命令用法。可以显示特定命令或属性的帮助。如果显示特定命令或属性的帮助,将会显示命令语法或可用的属性值。使用不带任何参数的 zpool help 可显示 zpool 命令的完整列表。
显示 zfs 属性信息,包括属性值是否可编辑以及可能的属性值。如果显示特定子命令或属性的帮助信息,将显示命令语法或属性值。使用不带任何参数的 zpool help 可显示 zpool 子命令的完整列表。
将指定的虚拟设备添加到给定的池。vdev 规范在“虚拟设备”部分中介绍。The behavior of the -f option, and the device checks performed are described in the zpool create subcommand.
强制使用 vdev,即使它们显示为正在使用;或者指定一个冲突的复制级别。并非所有设备都可以通过这种方式覆盖。
Sets the specified property for all vdevs specified in a command.Only 'allocunit' is supported at the moment.
显示将使用的配置,但不实际添加 vdev。实际的池创建操作仍可能因特权不足或设备共享的原因而失败。
If possible, have -n display the configuration in current /dev/chassis location form.
不要添加当前配置为 ZFS 存储池的法定设备的磁盘。某个磁盘进入池中后,就可将该磁盘配置为法定设备。
将 new_device 连接到现有的 zpool 设备。现有设备不能是 raidz 配置的一部分。如果 device 当前不是某个镜像配置的一部分,device 将自动转换为 device 和 new_device 的双向镜像。如果 device 是某个双向镜像的一部分,则连接 new_device 将创建一个三向镜像,依此类推。无论哪种情况,new_device 都会立即开始重新同步。
强制使用 new_device,即使它显示为正在使用。并非所有设备都可以通过这种方式覆盖。
清除某个池中的设备错误。如果未指定任何参数,将清除池中的所有设备错误。如果指定了一个或多个设备,将仅清除与指定设备关联的错误。
启动不可打开池的恢复模式。尝试放弃池中最后少数几个事务会将其恢复到可打开状态。并非所有损坏的池都能使用此选项恢复。如果成功,将不可挽回地丢失所放弃事务中的数据。
Used in combination with the -F flag.检查放弃事务是否会使池可打开,但不会实际放弃任何事务。
这是一个特殊的池恢复选项,如果 fmadm acquit 或 fmadm repair 命令无法清除池故障,可以使用该选项。如果系统重新引导,FMA 将重放池故障,因此需要在池恢复后解决 FMA 故障。
创建一个新的存储池,其中包含在命令行上指定的虚拟设备。池名称必须以字母开头,并且可以包含字母数字字符以及下划线 (_)、破折号 (-)、冒号 (:)、空格 ( ) 和句点 (.)。池名称 mirror、raidz、spare、log 和 meta 以及以模式 c[0-9] 开头的名称是保留的名称。vdev 规范在“虚拟设备”部分中介绍。
该命令确认指定的每个设备可访问,并且其他子系统当前未使用这些设备。有一些使用情况(如当前正在挂载,或者被指定为专用转储设备)会阻止设备被 ZFS 使用。Other uses, such as having a preexisting UFS file system, can be overridden with the -f option.
该命令还会检查池的复制策略是否一致。An attempt to combine redundant and non-redundant storage in a single pool, or to mix disks and files, results in an error unless -f is specified.The use of differently sized devices within a single raidz or mirror group is also flagged as an error unless -f is specified.
Unless the -R option is specified, the default mount point is /pool.不得有挂载点,或者即使存在,也必须为空,否则将无法挂载根数据集。This can be overridden with the -m option.
当在整个磁盘设备上运行时,将创建引导分区(如果它是从平台上的 EFI (GPT) 标签磁盘进行引导所必需的)。The -B option has no effect on devices that are not whole disks.
创建池而不挂载或共享新创建的池的根文件系统。
强制使用 vdev,即使它们显示为正在使用;或者指定一个冲突的复制级别。并非所有设备都可以通过这种方式覆盖。
If possible, have -n display the configuration in current /dev/chassis location form.
显示将在不实际创建池的情况下使用的配置。实际的池创建操作仍可能因特权不足或设备当前正处于使用状态而失败。
设置指定的池属性。有关可设置的有效属性列表,请参见“属性”部分。
设置池的顶层文件系统的指定属性。有关可设置的有效属性的列表,请参见 zfs(8) 的“属性”部分。
Equivalent to -o cachefile=none,altroot=root.
设置池的顶层文件系统的挂载点。The default mount point is /pool, or / altroot if altroot is specified.挂载点必须是一个绝对路径 legacy(传统)或 none(无)。有关数据集挂载点的更多信息,请参见 zfs(8)。
尝试销毁不再需要的池,这样,系统便无法再使用或访问池设备。The -f option might be required.因此,如果想要重新使用剩余的池设备,请使用 zpool label 命令从池设备中删除已销毁的池信息。
强制卸载池中包含的所有活动数据集。
从镜像存储池分离 device 或备件。如果以物理方式替换了现有设备,则也可以从 RAID-Z 存储池分离备件。或者,可以分离 RAID-Z 存储池中的现有设备(如果已替换为备件)。如果没有数据的其他有效副本,将拒绝该操作。
从系统中导出指定的池。所有设备将标记为已导出,但其他子系统仍认为它们在使用。只要存在足够的设备数量,就可以在系统之间移动设备(即使这些设备采用不同的字节存储顺序 (endianness))以及导入这些设备。
在导出池之前,将卸载池中的所有数据集。
要使池可移植,必须在 zpool 命令中指定整个磁盘(而不仅仅是分片),从而使 ZFS 可以使用可移植的 EFI 标签来设置磁盘标签。否则,采用不同字节存储顺序的平台上的磁盘驱动程序将无法识别磁盘。
Forcibly unmount all datasets, using the unmount -f command.
This command will forcibly export the pool.
检索指定存储池的给定属性列表或所有属性(如果使用了 all)。
有关可用池属性的更多信息,请参见"属性"部分。
Scripted mode.不显示标题,以单个制表符(而不是任意空格)来分隔字段。
显示可解析(确切)值中的数字。
要显示的字段的逗号分隔列表。缺省情况下,这些属性以下列字段显示:
name Name of storage pool property Property name value Property value source Property source, either 'default' or 'local'.
将显示逗号分隔的源列表。将忽略来自此列表中的源之外的某个源的属性。每个源必须是以下源之一:
local, default, none
缺省值是所有源。
有关可用池属性的更多信息,请参见"属性"部分。
显示指定池或所有池(如果没有指定任何池)的命令历史记录。
显示内部记录的 ZFS 事件以及用户启动的事件。
以长格式显示日志记录;长格式除了标准格式以外,还包括用户名、主机名以及执行操作所在的区域。
列出可导入的池。If the -d option is not specified, this command searches for devices in /dev/dsk.The -d option can be specified multiple times, and all directories and device paths are searched.如果设备显示为导出池的一部分,则此命令将显示池的摘要,其中包括池的名称、数字标识符以及 vdev 布局和每个设备或文件的当前运行状况。Pools that were previously destroyed with the zpool destroy command, are not listed unless the -D option is specified.
数字标识符是唯一的,当有多个名称相同的导出池时,可用于代替池名称。
从使用 cachefile 池属性创建的指定 cachefile 中读取配置。将使用此 cachefile 代替搜索设备。
在 path 中搜索设备或文件,其中 path 可以是目录或设备路径。The -d option can be specified multiple times.
仅列出销毁或清除的池。
If possible, display information in current /dev/chassis location form.
A comma-separated list of device status property fields to display.The list of status fields available are: name, state, read, write, checksum, repair, resilver, slow, allocunit, psize, lsize, alloc, free and pctfull.See 'Device status properties' section for more details.
When used in combination with -S, 'config' section is implicitly included in the sections displayed.
A comma-separated list of sections to display.The list of status sections available are: pool, id, state, retained, scan, config, dedup, errors.
Without -S option all available sections will be displayed.
导入在搜索目录或设备路径中找到的所有池。与前一个命令相同,但会导入具有足够的可用设备数量的所有池。Pools that were previously destroyed with the zpool destroy command, are not imported unless the -D option is specified.
挂载池中的数据集时要使用的挂载选项列表(用逗号分隔)。有关数据集属性和挂载选项的说明,请参见 zfs(8)。
对导入的池设置指定属性。有关可用池属性的更多信息,请参见“属性”部分。
从使用 cachefile 池属性创建的指定 cachefile 中读取配置。将使用此 cachefile 代替搜索设备。
在 path 中搜索设备或文件。The -d option can be specified multiple times.This option is incompatible with the -c option.
仅导入销毁的池。The -f option is also required.
强制导入,即使池看上去可能处于活动状态。
不可导入池的恢复模式。尝试通过放弃最后几个事务将池恢复到可导入状态。并非所有损坏的池都能使用此选项恢复。如果成功,将不可挽回地丢失所放弃事务中的数据。如果池是可导入的,或者已经导入,将忽略此选项。
搜索并导入所有找到的池。
允许在缺少日志设备时导入池。
将 cachefile 属性设置为 none(无),将 altroot 属性设置为 root。
导入池而不挂载或共享任何文件系统。
Used with the -F recovery option.确定是否可将不可导入的池重新变得可导入,但不实际执行池恢复。For more details about pool recovery mode, see the -F option, above.
If possible, have -n display information in current /dev/chassis location form.
导入特定的池。池可以用名称或数字标识符来标识。如果指定了 newpool,将使用持久名称 newpool 导入池。否则,使用与其导出名称相同的名称导入。请不要使用新名称导入根池。否则,系统可能无法引导。
如果没有先运行 zpool export 就从系统中移除了设备,则设备看上去可能处于活动状态。这将无法确定这是失败的导出,还是真的有其他主机在使用该设备。To import a pool in this state, the -f option is required.
挂载池中的数据集时要使用的挂载选项列表(用逗号分隔)。有关数据集属性和挂载选项的说明,请参见 zfs(8)。
对导入的池设置指定属性。有关可用池属性的更多信息,请参见“属性”部分。
从使用 cachefile 池属性创建的指定 cachefile 中读取配置。将使用此 cachefile 代替搜索设备。
在 path 中搜索设备或文件。The -d option can be specified multiple times.This option is incompatible with the -c option.
Imports destroyed pool.The -f option is also required.
强制导入,即使池看上去可能处于活动状态。
不可导入池的恢复模式。尝试通过放弃最后几个事务将池恢复到可导入状态。并非所有损坏的池都能使用此选项恢复。如果成功,将不可挽回地丢失所放弃事务中的数据。如果池是可导入的,或者已经导入,将忽略此选项。
将 cachefile 属性设置为 none(无),将 altroot 属性设置为 root。
在不挂载任何文件系统的情况下导入池。
Used with the -F recovery option.确定是否可将不可导入的池重新变得可导入,但不实际执行池恢复。For more details about pool recovery mode, see the -F option, above.
If possible, have -n display information in current /dev/chassis location form.
允许在缺少日志设备时导入池。
将指定的临时池名称用于整个导入。暗指 -o cachefile=none。
显示指定池的 I/O 统计信息。如果指定了时间间隔,将每隔 interval 秒输出一次统计信息,直到按 Ctrl-C 为止。如果未指定 pools,将显示系统中每个池的统计信息。如果指定了 count,该命令将在输出 count 报告后退出。
清除指定非活动池中的 ZFS 池元数据,以使其设备可以在新池中使用或由其他文件系统使用。
池可以用名称或数字标识符来标识。如果指定了设备,则此命令仅清除在给定设备上找到的池元数据。If the -d option is not specified, this command searches for devices in /dev/dsk directory.
从使用 cachefile pool 属性创建的给定 cachefile 中读取配置。将使用此 cachefile 代替搜索设备。
在 path 中搜索设备或文件。The -d option can be specified multiple times.This option is incompatible with the -c option.
清除指定设备上的 ZFS 池元数据。必须使用完整的路径和名称来指定设备。设备不能是活动池的一部分,否则将列显一条错误消息。
这是 zpool label -C 命令的撤消操作。它可恢复特定池的 ZFS 元数据,如果以这种方式还原了池中足够多的设备,这样便可以重新导入池。如果指定了设备,则仅恢复此设备上的元数据。
池可以用名称或数字标识符来标识。If the -d option is not specified, this command searches for devices in /dev/dsk directory.必须使用完整的路径和名称来指定设备。
从使用 cachefile pool 属性创建的指定 cachefile 中读取配置。将使用此 cachefile 代替搜索设备。
在 path 中搜索设备或文件,其中 path 可以是目录或设备路径。The -d option can be specified multiple times.
恢复在指定设备上找到的所有可恢复的 ZFS 池元数据。必须使用完整的路径和名称来指定设备。设备不能是活动池的一部分,否则将列显一条错误消息。
列出指定池以及运行状态和空间使用情况。如果未指代任何参数,将列出系统中的所有池。
如果指定了时间间隔,将每隔 interval 秒显示一次状态和空间使用情况,直到按 Ctrl-C 为止。如果指定了 count,该命令将在显示 count 报告后退出。
显示给定池的状态或进度信息。如果未输入池,则显示所有池的信息。当给定了间隔时,将每隔 interval 秒输出一次信息,直到按了 Ctrl-C。如果指定了 count,则命令将在输出 count 个报告后退出。
将指定的物理设备脱机。当 device 处于脱机状态时,不会尝试对设备进行任何读或写操作。
此命令不适用于高速缓存设备。
Temporary.重新引导时,指定的物理设备将恢复到其以前的状态。
将指定的物理设备联机。
此命令不适用于高速缓存设备。
扩展设备以使用所有可用空间。如果设备是某个镜像或 raidz 的一部分,则在新空间对池可用之前,所有设备都必须扩展。
Change the guid of a specified pool.The new guid will be generated automatically.The command will fail if the pool or any of its vdevs is not in state HEALTHY or if there are any outstanding FMA faults.
开始从池中移除指定的设备。此命令支持移除热备件、高速缓存设备、日志设备、元数据设备和非冗余数据设备。可以通过指定顶层 mirror 或 raidz 来移除冗余日志或数据设备。可以使用 zpool detach 命令移除属于某个冗余配置的数据设备。此命令接受移除设备列表。设备列表必须属于同一类型,即数据设备或非数据设备,不能是两者的混合。
移除顶层数据设备会将该设备中的数据迁移到池中的其余数据设备。zpool status 命令报告移除操作的进度,直到重新同步操作完成。
在顶层数据设备移除操作完成之前,可通过 zpool remove -s 取消正在进行的顶层数据设备移除操作。
取消移除顶层数据设备,并将池恢复为其原始状态。
将 old_device 替换为 new_device。该命令等效于连接 new_device,等待它重新同步,然后分离 old_device 。
new_device 的大小必须大于或等于镜像配置或 raidz 配置中所有设备的最小大小。
如果池不是冗余池,则必须要有 new_device。如果不指定 new_device,将缺省为 old_device。在现有磁盘出现故障并已进行物理更换后,这种形式的替换很有用。在这种情况下,新磁盘可能有着与旧设备相同的 /dev/dsk 路径,尽管它实际上是一个不同的磁盘。ZFS recognizes this.
在 zpool status 输出中,old_device 显示在 replacing 一词下,其后附有字符串 /old。重新同步完成后,将自动移除 replacing 和 old_device。如果新设备在重新同步之前发生故障,并且有第三个设备安装在它的位置,则两个故障设备都将显示为后面附有 /old,并且重新同步过程将重新开始。重新同步完成后,两个 /old 设备将与 replacing 一词一起被移除。
强制使用 new_device,即使它看上去正在使用也是如此。并非所有设备都可以通过这种方式覆盖。
Lists the mandatory retention filesystems with retained files in the specified pool.If no pools are specified, then all pools with filesystems with mandatory retention are shown.
These options select whether expired (-e) or unexpired (-u) retention datasets and files are shown.If neither option is included, all are shown.
These options select whether automatic (-a) or non-automatic (-n) retention datasets are included.If neither option is included, all are shown.
If the -r option is included, all retained files within those mandatory retention filesystems are also displayed.
If the -A option is included, retained files are listed including file information - mode, system attributes, crtime, mtime, ctime, rtime, uid, gid, then filename.Output fields are space-delimited with any spaces or backslashes preceded by a backslash (e.g. file "a b c" would be shown as "a\ b\ c").
If the -f option is included, only the filenames are shown, with no pool name, dataset name, retention properties, or timestamps. -f implies -r.
Display the list of retained files in the pool using a stable machine-parseable format.For more information, see 'Parseable Output Format', below. -p implies -r.
Display the specified field(s) in parseable format.Available fields are dataset, policy, automatic, mountpoint, filename, object, mode, sysattrs, size, uid, gid, crtime, mtime, ctime, rtime, and expired.
Begins a scrub.scrub 将检查指定池中的所有数据以验证其校验和是否正确。对于复制的(镜像或 raidz)设备,ZFS 会自动修复在清理过程中发现的所有损坏。zpool status 命令报告清理的进度,并在完成时汇总清理的结果。
清理和重新同步是非常相似的操作。不同之处在于,重新同步仅检查 ZFS 已知将要过期的数据(例如,在将新设备连接到某个镜像或者替换现有设备时),而清理将检查所有数据以发现由于硬件故障或磁盘故障而产生的无提示错误。
由于清理和重新同步都是 I/O 密集型操作,因此 ZFS 一次仅允许使用其中的一个。If a scrub is already in progress, a subsequent zpool scrub returns an error, with the advice to use zpool scrub -s to cancel the current scrub.如果正在进行重新同步,ZFS 将不允许启动清理,直到重新同步完成为止。
Stop scrubbing.
对指定池设置指定属性。有关可设置哪些属性和可接受的值的更多信息,请参见“属性”一节。
从某个池中每个镜像的顶层 vdev 中分割出一个磁盘,然后使用分割出的磁盘新建一个池。原始池必须包含一个或多个镜像,并且不能处在重新同步过程中。split 子命令会选择每个镜像 vdev 中的最后一个设备,除非被命令行上的设备指定覆盖。
Pools cannot be split if they contain mandatory retention filesystems.
使用 device 参数时,split 会将指定的设备包括在新池中;如果有任何设备仍处于未指定状态,则会将每个镜像 vdev 中的最后一个设备分配到该池,就像其正常操作时一样。If you are uncertain about the outcome of a split command, use the -n (“dry-run”) option to ensure your command will have the effect you intend.
显示在不实际分割池的情况下会创建的配置。实际的池分割操作仍可能因特权不足或设备状态的原因而失败。
If possible, have -n display the configuration in current /dev/chassis location form.
在分割后自动导入新创建的池,将指定的 altroot 参数用于新池的备用根。请参见前面“属性”部分中的 altroot 说明。
挂载池中的数据集时要使用的挂载选项列表(用逗号分隔)。有关数据集属性和挂载选项的说明,请参见 zfs(8)。Valid only in conjunction with the -R option.
对新池设置指定的属性。有关可用池属性的更多信息,请参见前面的“属性”部分。
显示指定池的详细运行状态。如果未指定任何 pool,将显示系统中每个池的状态。有关池和设备运行状况的更多信息,请参见“设备故障和恢复”部分。
如果指定了时间间隔,将每隔 interval 秒显示一次状态和空间使用情况,直到按 Ctrl-C 为止。如果指定了 count,该命令将在显示 count 报告后退出。
如果正在清理或重新同步,此命令将报告完成百分比以及估计的完成时间。这两项数据都只是近似值,因为池中的数据量以及系统上的其他工作负荷可能会发生变化。
A comma-separated list of device status property fields to display.The list of status fields available are: name, state, read, write, checksum, repair, resilver, slow, allocunit, psize, lsize, alloc, free and pctfull.See 'Device status properties' section for more details.
When used in combination with -S, 'config' section is implicitly included in the sections displayed.
Without -s option, the default fields (name, state, read, write, checksum) will be displayed.
A comma-separated list of sections to display.The list of status sections available are: pool, id, state, retained, scan, config, dedup, errors.
Without -S option all available sections will be displayed.
如果可能,以当前 /dev/chassis 位置格式显示 vdev 状态。
仅显示呈现错误或者因其他原因不可用的池的状态。
显示详细数据错误信息,列显自上次完成池清理以来所有数据错误的完整列表。
显示时间戳。
指定 d 表示标准日期格式。请参见 date(1)。指定 u 表示时间的内部表示形式的印刷表示形式。请参见 time(2)。
标识池的盘上版本,该版本确定当前正在运行的软件版本中的可用池功能。可以继续使用较旧的池版本,但有些功能可能不可用。A pool can be upgraded by using the zpool upgrade -a command.无法在运行较早软件版本的系统上访问较新版本的池。
显示当前软件支持的 ZFS 池版本。当前 ZFS 池版本以及所有以前支持的版本都会显示,还会显示随每个版本提供的功能的说明。
将指定的池升级到最新的盘上版本。If this command reveals that a pool is out-of-date, the pool can subsequently be upgraded using the zpool upgrade -a command.升级后的池在运行较早软件版本的系统上将不可访问。
Upgrades all pools.
Report what would be done without actually upgrading any pools.
Force the upgrade even if it makes more boot environments un-bootable.
Upgrades to the specified version, which must be higher than the current version.If the -V flag is not specified, the pool is upgraded to the most recent version.
If a pool is bootable zpool upgrade will verify that the upgrade will not make any more boot environments un-bootable.If it will make more boot environments un-bootable those boot environments and their current supported pool versions will be listed.To force zpool upgrade to do the upgrade and make those boot environments un-bootable the -V and -f flags must both be used. zpool upgrade will never allow an upgrade to make the active boot environment un-bootable.
If a bootable pool is listed or the -a flag is present and the pool can be updated without making any more boot environments un-bootable then the upgrade will be done unless the -n is given.
对于不同的提供器,字段也不同。如果选择了提供器不支持的字段,则会返回错误。
迄今为止已完成或已处理的数据量。
取决于提供器。提供额外的信息,例如正在处理的当前项或任务的当前状态。例如,在 zfs send 操作中,此值可能反映当前正在发送的个体数据集或快照。报告为 OTHER 的特定值不是接口,可能会更改且不进行通知。
已处理的数据所占百分比。
从中检索信息的池。
提供信息的任务。send、receive、destroy、scrub 和 resilver 中的一个。
每秒单位数。通常为字节,但取决于数据提供器使用的单位。
提供器在所显示的任务上的启动时间。
TAG 用于消除整个操作的歧义。它在任一时刻都是唯一的,但是值在后续的操作中可以重复。例如,两个同时进行的发送操作将具有不同的 TAG,即使它们发送的是同一数据集也是如此。
完成此任务将需要的相对时间。它是根据当前的数据处理速率计算得到的。
所监视的数据快照的拍摄时间。
估计要处理的数据总量。
The zpool monitor and zpool retained commands provide a -p option that displays output in a machine-parseable format.输出格式是一行或多行以冒号 (:) 分隔的字段。Output includes only those fields requested by means of the -o option, in the order requested.
当请求多个字段时,将在输出之前使用反斜杠 (\) 对任何文本冒号字符进行转义。类似地,也会对文本反斜杠字符进行转义 (\\)。通过使用环境变量设置为 IFS=: 的 shell read(1) 函数,可以解析此转义格式。请注意,当仅请求一个字段时,不会进行转义。
The following command creates a pool with a single raidz top-level vdev that consists of six disks.
# zpool create tank raidz c0t0d0 c0t1d0 c0t2d0 c0t3d0 c0t4d0 c0t5d0示例 2 创建镜像存储池
以下命令创建包含两个镜像的池,其中每个镜像各包含两个磁盘。
# zpool create tank mirror c0t0d0 c0t1d0 mirror c0t2d0 c0t3d0
或者,可以使用描述磁盘当前位置的 /dev/chassis 路径指定整个磁盘。
# zpool create tank \ mirror \ /dev/chassis/RACK29.U01-04/DISK_00/disk \ /dev/chassis/RACK29.U05-08/DISK_00/disk \ mirror \ /dev/chassis/RACK29.U01-04/DISK_01/disk \ /dev/chassis/RACK29.U05-08/DISK_01/disk示例 3 将镜像添加到 ZFS 存储池
以下命令将两个镜像磁盘添加到池 tank 中(假定该池由双向镜像组成)。增加的空间可立即供池中的任何数据集使用。
# zpool add tank mirror c1t0d0 c1t1d0示例 4 列出可用的 ZFS 存储池
以下命令列出系统上的所有可用池。
# zpool list NAME SIZE ALLOC FREE CAP DEDUP HEALTH ALTROOT pool 278G 4.19G 274G 1% 1.00x ONLINE - rpool 278G 78.2G 200G 28% 1.00x ONLINE -示例 5 列出池的所有属性。
以下命令列出某个池的所有属性。
% zpool get all pool NAME PROPERTY VALUE SOURCE pool allocated 4.19G - pool altroot - default pool autoexpand off default pool autoreplace off default pool bootfs - default pool cachefile - default pool capacity 1% - pool dedupditto 0 default pool dedupratio 1.00x - pool delegation on default pool failmode wait default pool free 274G - pool guid 1907687796174423256 - pool health ONLINE - pool lastscrub Jan_21 local pool listshares off local pool listsnapshots off default pool readonly off - pool scrubinterval 2m local pool size 278G - pool version 34 default示例 6 销毁 ZFS 存储池
以下命令销毁池 tank 以及其中包含的所有数据集。
# zpool destroy -f tank示例 7 导出 ZFS 存储池
以下命令导出池 tank 中的设备,使这些设备可以重新定位,或在以后导入。
# zpool export tank示例 8 导入 ZFS 存储池
以下命令显示可用的池,然后导入池 tank 供系统使用。
此命令的结果与以下内容相似:
# zpool import pool: tank id: 7678868315469843843 state: ONLINE action: The pool can be imported using its name or numeric identifier. config: tank ONLINE mirror-0 ONLINE c1t2d0 ONLINE c1t3d0 ONLINE # zpool import tank示例 9 将所有 ZFS 存储池升级到当前版本
以下命令将所有 ZFS 存储池升级到软件的当前版本。
# zpool upgrade -a This system is currently running ZFS pool version 22. All pools are formatted using this version.示例 10 管理热备件
以下命令创建一个包含可用热备件的新池:
# zpool create tank mirror c0t0d0 c0t1d0 spare c0t2d0
如果其中的一个磁盘发生故障,池会缩减至降级状态。可以使用以下命令替换故障设备:
# zpool replace tank c0t0d0 c0t3d0
设备重新同步后,将自动分离备件,并使其在其他设备发生故障时可用。使用以下命令可将热备件从池中永久移除:
# zpool remove tank c0t2d0示例 11 创建具有单独的镜像日志设备的 ZFS 池
以下命令创建一个 ZFS 存储池,该池包含两个双向镜像和镜像日志设备。
# zpool create pool mirror c0d0 c1d0 mirror c2d0 c3d0 log mirror \ c4d0 c5d0示例 12 将高速缓存设备添加到 ZFS 池中
以下命令添加两个磁盘,用作 ZFS 存储池的高速缓存设备:
# zpool add pool cache c2d0 c3d0
添加以后,高速缓存设备会逐渐被主内存中的内容填满。填充它们可能需要一个多小时的时间,具体取决于高速缓存设备的大小。使用 iostat 选项可以监视容量和读取操作,如下所示:
# zpool iostat -v pool 5示例 13 将镜像元设备添加到 ZFS 池中
以下命令可将双向镜像元设备添加到 ZFS 存储池中:
# zpool add pool meta mirror c2d0 c3d0示例 14 移除镜像日志设备
指定下面所示的配置后,以下命令即删除池 tank 中的镜像日志设备 mirror-2。
pool: tank state: ONLINE scrub: none requested config: NAME STATE READ WRITE CKSUM tank ONLINE 0 0 0 mirror-0 ONLINE 0 0 0 c6t0d0 ONLINE 0 0 0 c6t1d0 ONLINE 0 0 0 mirror-1 ONLINE 0 0 0 c6t2d0 ONLINE 0 0 0 c6t3d0 ONLINE 0 0 0 logs mirror-2 ONLINE 0 0 0 c4t0d0 ONLINE 0 0 0 c4t1d0 ONLINE 0 0 0
# zpool remove tank mirror-2示例 15 恢复发生故障的 ZFS 池
如果某个池发生了可恢复的故障,在该池已高速缓存(请参见前面的 cachefile)时,zpool status 将提供指示此状态的消息,或者在因为池的 zpool import 失败而显示的错误输出中提供。
使用 zpool clear 命令恢复高速缓存的池:
# zpool clear -F data Pool data returned to its state as of Thu Jun 07 10:50:35 2012. Discarded approximately 29 seconds of transactions.
如果池配置未高速缓存,请使用带恢复模式标志的 zpool import:
# zpool import -F data Pool data returned to its state as of Thu Jun 07 10:50:35 2012. Discarded approximately 29 seconds of transactions.示例 16 导入缺少日志设备的 ZFS 池
以下示例说明尝试导入缺少日志设备的池。The -m option is used to complete the import operation.
尽管无法确定其他设备的准确配置,但知道它们是该池的一部分。
# zpool import tank The devices below are missing, use '-m' to import the pool anyway: c5t0d0 [log] cannot import 'tank': one or more devices is currently unavailable # zpool import -m tank # zpool status tank pool: tank state: DEGRADED status: One or more devices could not be opened. Sufficient replicas exist for the pool to continue functioning in a degraded state. action: Attach the missing device and online it using 'zpool online'. see: http://www.support.oracle.com/msg/ZFS-8000-2Q scan: none requested config: NAME STATE READ WRITE CKSUM tank DEGRADED 0 0 0 c7t0d0 ONLINE 0 0 0 logs 1693927398582730352 UNAVAIL 0 0 0 was /dev/dsk/c5t0d0 errors: No known data errors
以下示例说明如何导入缺少镜像日志设备的池:
# zpool import tank The devices below are missing, use ?-m? to import the pool anyway: mirror-1 [log] c5t0d0 c5t1d0 # zpool import -m tank # zpool status tank pool: tank state: DEGRADED status: One or more devices could not be opened. Sufficient replicas exist for the pool to continue functioning in a degraded state. action: Attach the missing device and online it using 'zpool online'. see: http://www.support.oracle.com/msg/ZFS-8000-2Q scan: none requested config: NAME STATE READ WRITE CKSUM tank DEGRADED 0 0 0 c7t0d0 ONLINE 0 0 0 logs mirror-1 UNAVAIL 0 0 0 insufficient replicas 46385995713041169 UNAVAIL 0 0 0 was /dev/dsk/c5t0d0 13821442324672734438 UNAVAIL 0 0 0 was /dev/dsk/c5t1d0 errors: No known data errors示例 17 通过特定路径导入池
以下命令通过标识 tank 池的特定设备路径(在本例中为 /dev/dsk/c9t9d9 和 /dev/dsk/c9t9d8)来导入该池。
# zpool import -d /dev/dsk/c9t9d9s0 /dev/dsk/c9t9d8s0 tank
现有的限制在于,即使该池由完整的磁盘组成,该命令也必须包括特定设备的分片标识符。
示例 18 移除两个镜像数据设备给定下面所示的配置后,以下命令可从池 tank 中移除镜像数据设备 mirror-0 和 mirror-1 。
pool: tank state: ONLINE scrub: none requested config: NAME STATE READ WRITE CKSUM tank ONLINE 0 0 0 mirror-0 ONLINE 0 0 0 c6t0d0 ONLINE 0 0 0 c6t1d0 ONLINE 0 0 0 mirror-1 ONLINE 0 0 0 c6t2d0 ONLINE 0 0 0 c6t3d0 ONLINE 0 0 0 mirror-2 ONLINE 0 0 0 c6t4d0 ONLINE 0 0 0 c6t5d0 ONLINE 0 0 0 # zpool remove tank mirror-0 mirror-1 zpool status shows mirror-0 and mirror-1 are being removed. # zpool status tank pool: tank 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 tank ONLINE 0 0 0 mirror-0 REMOVING 0 0 0 c6t0d0 REMOVING 0 0 0 c6t1d0 REMOVING 0 0 0 mirror-1 REMOVING 0 0 0 c6t2d0 REMOVING 0 0 0 c6t3d0 REMOVING 0 0 0 mirror-2 ONLINE 0 0 0 c6t4d0 ONLINE 0 0 0 c6t5d0 ONLINE 0 0 0 errors: No known data errors After the resilvering completes, mirror-0 and mirror-1 are removed from the pool configuration and the pool returns to ONLINE state. # zpool status tank pool: tank state: ONLINE scan: resilvered 6.67G in 0h2m with 0 errors on Mon Jul 7 18:22:10 2014 config: NAME STATE READ WRITE CKSUM tank ONLINE 0 0 0 mirror-2 ONLINE 0 0 0 c6t4d0 ONLINE 0 0 0 c6t5d0 ONLINE 0 0 0 errors: No known data errors示例 19 Obtaining Parseable Output
以下命令用来获取可解析的输出并且将提供一个间隔:
# zpool monitor -p -o pool,pctdone,other -t send poolA poolC poolA:20.4:poolA/fs2/team2@fs2_all poolA:0.0:poolA/fs2/team2@all poolA:28.6:poolA/fs\:1/team3@fs1_all poolC:33.3:poolC/fs1/team2@fs1_all poolC:50.0:poolC/fs2/team1@fs2_all示例 20 Removing zpool Metadata
以下命令可删除 zpool 元数据:
# zpool import pool: tank id: 16467356871648988132 state: ONLINE action: The pool can be imported using its name or numeric identifier. config: tank ONLINE raidz1-0 ONLINE c7t8d0 ONLINE c7t9d0 ONLINE c7t10d0 ONLINE # zpool label -C tank # zpool import cannot import: no pools found示例 21 恢复 zpool 元数据
以下命令可恢复 zpool 元数据:
# zpool import -D pool: tank id: 16467356871648988132 state: CLEARED status: The pool has cleared device(s) and therefore it is not possible to determine its exact configuration. The configuration presented below is only tentative. action: You can try using 'zpool label -R' to recover the pool but some devices might be already used by another pool or be unavailable. config: tank CLEARED raidz1-0 CLEARED c7t8d0 CLEARED c7t9d0 CLEARED c7t10d0 CLEARED # zpool label -R tank # zpool import示例 22 从指定设备上删除 zpool 元数据
以下命令可从指定设备上删除 zpool 元数据:
# zpool status tank pool: tank state: ONLINE scan: none requested config: NAME STATE READ WRITE CKSUM tank ONLINE 0 0 0 mirror-0 ONLINE 0 0 0 c2t1d0 ONLINE 0 0 0 c2t2d0 ONLINE 0 0 0 errors: No known data errors # zpool export pool_m # zpool label -C /dev/dsk/c2t1d0s0 # zpool import no pools available to import示例 23 恢复指定设备上的 zpool 元数据
以下命令可恢复指定设备上的 zpool 元数据:
# zpool import -D pool: tank id: 413554598802822140 state: CLEARED (EXPORTED) status: The pool has cleared device(s) and therefore it is not possible to determine its exact configuration. The configuration presented below is only tentative. action: You can try using 'zpool label -R' to recover the pool but some devices might be already used by another pool or be unavailable. config: tank CLEARED mirror-0 CLEARED c2t1d0 CLEARED c2t2d0 ONLINE # zpool label -R /dev/dsk/c2t1d0s0 # zpool import tank示例 24 移除 raidz 数据设备
给定下面所示的配置后,以下命令可从池 tank 中移除数据设备 raidz1-0。
pool: tank state: ONLINE scrub: none requested config: NAME STATE READ WRITE CKSUM tank ONLINE 0 0 0 raidz1-0 ONLINE 0 0 0 c6t0d0 ONLINE 0 0 0 c6t1d0 ONLINE 0 0 0 raidz1-1 ONLINE 0 0 0 c6t2d0 ONLINE 0 0 0 c6t3d0 ONLINE 0 0 0 # zpool remove tank raidz1-0 zpool status shows raidz1-0 is being removed. # zpool status tank pool: tank 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 tank ONLINE 0 0 0 raidz1-0 REMOVING 0 0 0 c6t0d0 REMOVING 0 0 0 c6t1d0 REMOVING 0 0 0 raidz1-1 ONLINE 0 0 0 c6t2d0 ONLINE 0 0 0 c6t3d0 ONLINE 0 0 0 errors: No known data errors After the resilvering completes, raidz1-0 is removed from the pool configuration and the pool returns to ONLINE state. # zpool status tank pool: tank state: ONLINE scan: resilvered 6.67G in 0h2m with 0 errors on Mon Jul 7 18:22:10 2014 config: NAME STATE READ WRITE CKSUM tank ONLINE 0 0 0 raidz-1 ONLINE 0 0 0 c6t2d0 ONLINE 0 0 0 c6t3d0 ONLINE 0 0 0 errors: No known data errors示例 25 移除非冗余数据设备和 meta(元)设备
给定下面所示的配置后,以下命令可从池 tank 中移除非冗余数据设备 c6t0d0 和 meta 设备 c6t2d0。
# zpool status tank pool: tank state: ONLINE scan: none requested config: NAME STATE READ WRITE CKSUM tank ONLINE 0 0 0 c6t0d0 ONLINE 0 0 0 c6t1d0 ONLINE 0 0 0 metas c6t2d0 ONLINE 0 0 0 c6t3d0 ONLINE 0 0 0 logs c6t4d0 ONLINE 0 0 0 cache c6t5d0 ONLINE 0 0 0 spares c6t6d0 AVAIL errors: No known data errors # zpool remove tank c6t0d0 c6t2d0 zpool status shows c6t0d0 and c6t2d0 are being removed. pool: tank state: ONLINE status: One or more devices are being removed. action: Wait for the resilver to complete. Run 'zpool status -v' to see device specific details. scan: resilver in progress since Fri Jan 19 10:33:36 2018 2.38G scanned out of 2.48G at 144M/s, 1s to go 0 resilvered config: NAME STATE READ WRITE CKSUM tank ONLINE 0 0 0 c6t0d0 REMOVING 0 0 0 c6t1d0 ONLINE 0 0 0 metas c6t2d0 REMOVING 0 0 0 c6t3d0 ONLINE 0 0 0 logs c6t4d0 ONLINE 0 0 0 cache c6t5d0 ONLINE 0 0 0 spares c6t6d0 AVAIL errors: No known data errors After the resilver completes, c6t0d0 and c6t2d0 are removed from the pool configuration and the pool returns to ONLINE state. # zpool status tank pool: tank state: ONLINE scan: resilvered 1.27M in 1s with 0 errors on Fri Jan 19 09:37:41 2018 config: NAME STATE READ WRITE CKSUM tank ONLINE 0 0 0 c6t1d0 ONLINE 0 0 0 metas c6t3d0 ONLINE 0 0 0 logs c6t4d0 ONLINE 0 0 0 cache c6t5d0 ONLINE 0 0 0 spares c6t6d0 AVAIL errors: No known data errors示例 26 Changing the pool guid of an existing pool
The following command changes the guid of an existing pool to a random number.
# zpool get guid tank NAME PROPERTY VALUE SOURCE tank guid 11540845105265937039 # zpool reguid tank # zpool get guid tank NAME PROPERTY VALUE SOURCE tank guid 3172738027577799950 -
将返回以下退出值:
成功完成。
出现错误。
指定的命令行选项无效。
有关下列属性的说明,请参见 attributes(7):
|
ps(1), SDC(4), attributes(7), beadm(8), zfs(8), datasets(7)
为了给 zpool 留出更多空间(通过扩展底层 LUN 的容量实现),请勿使用 format 命令来获取 LUN 的新大小以及重新对其进行标记。请改用以下过程:
Run zpool set autoexpand=on pool once, and leave autoexpand=on for the pool all the time.
根据需要扩展 LUN 的大小。The pool will reflect the size of the LUN automatically.
Files in filesystems with mandatory retention that are retained but the retention has not yet expired will prevent destruction of their containing pool and re-use of devices which are part of that pool.There is no privilege which will allow this to be overridden.
每个 ZFS 存储池具有一个关联的进程 zpool-poolname,在 ps(1) 之类的工具中可见。用户与这些进程没有交互。有关更多信息,请参见 SDC(4) 手册页。