跳过导航链接 | |
退出打印视图 | |
Oracle Solaris 11.1 管理:ZFS 文件系统 Oracle Solaris 11.1 Information Library (简体中文) |
1. Oracle Solaris ZFS 文件系统(介绍)
6. 使用 Oracle Solaris ZFS 快照和克隆
7. 使用 ACL 和属性保护 Oracle Solaris ZFS 文件
有时,可能需要在系统之间移动存储池。为此,必须将存储设备与原始系统断开,然后将其重新连接到目标系统。可以通过以下方法完成此任务:以物理方式重新为设备布线,或者使用多端口设备(如 SAN 中的设备)。使用 ZFS 可将池从一个系统中导出,然后将其导入目标系统,即使这些系统采用不同的字节存储顺序 (endianness)。有关在不同存储池(可能驻留在不同的系统中)之间复制或迁移文件系统的信息,请参见发送和接收 ZFS 数据。
应显式导出存储池,以表明可随时将其迁移。此操作会将任何未写入的数据刷新到磁盘,将数据写入磁盘以表明导出已完成,并从系统中删除有关池的所有信息。
如果不显式导出池,而是改为手动删除磁盘,则仍可以在其他系统中导入生成的池。但是,可能会丢失最后几秒的数据事务,并且由于设备不再存在,该池在原始系统中可能会显示为处于 UNAVAIL 状态。缺省情况下,目标系统无法导入未显式导出的池。为防止意外导入包含仍在其他系统中使用的网络连接存储器的活动池,此条件是必要的。
要导出池,请使用 zpool export 命令。例如:
# zpool export tank
此命令将尝试取消挂载池中任何已挂载的文件系统,然后再继续执行。如果无法取消挂载任何文件系统,则可以使用 -f 选项强制取消挂载这些文件系统。例如:
# zpool export tank cannot unmount '/export/home/eric': Device busy # zpool export -f tank
执行此命令后,池 tank 在系统中即不再可见。
如果在导出时设备不可用,则无法将设备标识为正常导出。如果之后将某个这样的设备附加到不包含任何工作设备的系统中,则该设备的状态会显示为“可能处于活动状态”。
如果 ZFS 卷在池中处于使用状态,即使使用 -f 选项,也无法导出池。要导出包含 ZFS 卷的池,请首先确保卷的所有使用者都不再处于活动状态。
有关 ZFS 卷的更多信息,请参见ZFS 卷。
从系统中删除池后(通过显式导出或通过强制删除设备),可以将设备附加到目标系统。ZFS 可以处理仅有其中一些设备可用的情况,但池迁移成功与否取决于设备的整体运行状况。此外,没有必要使用相同的设备名称附加设备。ZFS 可检测任何移动的或重命名的设备,并相应地调整配置。要搜索可用的池,请运行不带任何选项的 zpool import 命令。例如:
# zpool import pool: tank id: 11809215114195894163 state: ONLINE action: The pool can be imported using its name or numeric identifier. config: tank ONLINE mirror-0 ONLINE c1t0d0 ONLINE c1t1d0 ONLINE
在本示例中,池 tank 可用于在目标系统中导入。每个池都由一个名称以及唯一的数字标识符标识。如果有多个同名池可用于导入,则可以使用数字标识符对其进行区分。
与 zpool status 命令输出类似,zpool import 输出也会包括一个知识文章链接,其中包含有关禁止导入池这一问题的修复过程的最新信息。在此示例中,用户可以强制导入池。但是,如果导入当前正由其他系统通过存储网络使用的池,则可能导致数据损坏和出现紧急情况,因为这两个系统都尝试写入同一存储器。如果池中的某些设备不可用,但是存在足够的冗余数据可确保池可用,则池会显示 DEGRADED 状态。例如:
# zpool import pool: tank id: 4715259469716913940 state: DEGRADED status: One or more devices are unavailable. action: The pool can be imported despite missing or damaged devices. The fault tolerance of the pool may be compromised if imported. config: tank DEGRADED mirror-0 DEGRADED c0t5000C500335E106Bd0 ONLINE c0t5000C500335FC3E7d0 UNAVAIL cannot open device details: c0t5000C500335FC3E7d0 UNAVAIL cannot open status: ZFS detected errors on this device. The device was missing.
在本示例中,第一个磁盘已损坏或缺失,但仍可以导入池,这是因为仍可以访问镜像数据。如果存在过多的不可用设备,则无法导入池。
在本示例中,RAID-Z 虚拟设备中缺少两个磁盘,这意味着没有足够的可用冗余数据来重新构建池。在某些情况下,没有足够的设备就无法确定完整的配置。在这种情况下,虽然 ZFS 会尽可能多地报告有关该情况的信息,但是 ZFS 无法确定池中包含的其他设备。例如:
# zpool import pool: mothership id: 3702878663042245922 state: UNAVAIL status: One or more devices are unavailable. action: The pool cannot be imported due to unavailable devices or data. config: mothership UNAVAIL insufficient replicas raidz1-0 UNAVAIL insufficient replicas c8t0d0 UNAVAIL cannot open c8t1d0 UNAVAIL cannot open c8t2d0 ONLINE c8t3d0 ONLINE device details: c8t0d0 UNAVAIL cannot open status: ZFS detected errors on this device. The device was missing. c8t1d0 UNAVAIL cannot open status: ZFS detected errors on this device. The device was missing.
缺省情况下,zpool import 命令仅在 /dev/dsk 目录中搜索设备。如果设备存在于其他目录中,或者使用的是文件支持的池,则必须使用 -d 选项搜索其他目录。例如:
# zpool create dozer mirror /file/a /file/b # zpool export dozer # zpool import -d /file pool: dozer id: 7318163511366751416 state: ONLINE action: The pool can be imported using its name or numeric identifier. config: dozer ONLINE mirror-0 ONLINE /file/a ONLINE /file/b ONLINE # zpool import -d /file dozer
确定要导入的池后,即可通过将该池的名称或者其数字标识符指定为 zpool import 命令的参数来将其导入。例如:
# zpool import tank
如果多个可用池具有相同名称,则必须使用数字标识符指定要导入的池。例如:
# zpool import pool: dozer id: 2704475622193776801 state: ONLINE action: The pool can be imported using its name or numeric identifier. config: dozer ONLINE c1t9d0 ONLINE pool: dozer id: 6223921996155991199 state: ONLINE action: The pool can be imported using its name or numeric identifier. config: dozer ONLINE c1t8d0 ONLINE # zpool import dozer cannot import 'dozer': more than one matching pool import by numeric ID instead # zpool import 6223921996155991199
如果该池的名称与现有的池名称冲突,则可以使用其他名称导入该池。例如:
# zpool import dozer zeepool
此命令使用新名称 zeepool 导入已导出的池 dozer。新的池名称是持久性的。
如果池未正常导出,则 ZFS 需要使用 -f 标志,以防止用户意外导入仍在其他系统中使用的池。例如:
# zpool import dozer cannot import 'dozer': pool may be in use on another system use '-f' to import anyway # zpool import -f dozer
注 - 请勿尝试将一个系统上处于活动状态的池导入到另一个系统。ZFS 不是本机簇、分布式或平行文件系统,不能从多个不同主机进行并发访问。
也可以使用 -R 选项在备用根下导入池。有关备用根池的更多信息,请参见使用 ZFS 备用根池。
缺省情况下,无法导入缺少日志设备的池。但是,可以使用 zpool import -m 命令强制导入缺少日志设备的池。例如:
# zpool import dozer pool: dozer id: 16216589278751424645 state: UNAVAIL status: One or more devices are missing from the system. action: The pool cannot be imported. Attach the missing devices and try again. see: http://support.oracle.com/msg/ZFS-8000-6X config: dozer UNAVAIL missing device mirror-0 ONLINE c8t0d0 ONLINE c8t1d0 ONLINE device details: missing-1 UNAVAIL corrupted data status: ZFS detected errors on this device. The device has bad label or disk contents. Additional devices are known to be part of this pool, though their exact configuration cannot be determined.
导入缺少日志设备的池。例如:
# zpool import -m dozer # zpool status dozer pool: dozer state: DEGRADED status: One or more devices are unavailable in response to persistent errors. Sufficient replicas exist for the pool to continue functioning in a degraded state. action: Determine if the device needs to be replaced, and clear the errors using 'zpool clear' or 'fmadm repaired', or replace the device with 'zpool replace'. Run 'zpool status -v' to see device specific details. scan: none requested config: NAME STATE READ WRITE CKSUM dozer DEGRADED 0 0 0 mirror-0 ONLINE 0 0 0 c8t0d0 ONLINE 0 0 0 c8t1d0 ONLINE 0 0 0 logs 2189413556875979854 UNAVAIL 0 0 0 errors: No known data errors
在附加了缺少的日志设备后,运行 zpool clear 命令清除池错误。
缺少镜像日志设备时,也可以尝试进行类似的恢复:例如:
在附加了缺少的日志设备后,运行 zpool clear 命令清除池错误。
可以在只读模式下导入池。如果池受损严重而无法访问,此功能也许能使您恢复池中的数据。例如:
# zpool import -o readonly=on tank # zpool scrub tank cannot scrub tank: pool is read-only
在只读模式下导入池时,须符合以下条件:
所有文件系统和卷均以只读模式挂载。
池的事务处理功能被禁用。这也意味着,意图日志 (intent log) 中任何暂停的同步写入操作只有在读写模式下导入池后才启动。
只读导入期间,将忽略对池属性的设置尝试。
通过导出再导入池的方法,可以将只读池设置回读写模式。例如:
# zpool export tank # zpool import tank # zpool scrub tank
在本示例中,以下命令通过标识池 dpool 的其中一个特定设备 /dev/dsk/c2t3d0 来导入该池。
# zpool import -d /dev/dsk/c2t3d0s0 dpool # zpool status dpool pool: dpool state: ONLINE scan: resilvered 952K in 0h0m with 0 errors on Fri Jun 29 16:22:06 2012 config: NAME STATE READ WRITE CKSUM dpool ONLINE 0 0 0 mirror-0 ONLINE 0 0 0 c2t3d0 ONLINE 0 0 0 c2t1d0 ONLINE 0 0 0
即使该池由整个磁盘组成,该命令也必须包括特定设备的分片标识符。
可以使用 zpool import -D 命令恢复已销毁的存储池。例如:
# zpool destroy tank # zpool import -D pool: tank id: 5154272182900538157 state: ONLINE (DESTROYED) action: The pool can be imported using its name or numeric identifier. config: tank ONLINE mirror-0 ONLINE c1t0d0 ONLINE c1t1d0 ONLINE
在此 zpool import 输出中,由于包含以下状态信息,因此可以将池 tank 确定为已销毁的池:
state: ONLINE (DESTROYED)
要恢复已销毁的池,请再次执行 zpool import -D 命令,并指定要恢复的池。例如:
# zpool import -D tank # zpool status tank pool: tank state: ONLINE scrub: none requested config: NAME STATE READ WRITE CKSUM tank ONLINE mirror-0 ONLINE c1t0d0 ONLINE c1t1d0 ONLINE errors: No known data errors
如果已销毁池中的某个设备不可用,通过添加 -f 选项也许能够恢复已销毁的池。在此情况下,请导入已降级的池,然后尝试修复设备故障。例如:
# zpool destroy dozer # zpool import -D pool: dozer id: 4107023015970708695 state: DEGRADED (DESTROYED) status: One or more devices are unavailable. action: The pool can be imported despite missing or damaged devices. The fault tolerance of the pool may be compromised if imported. config: dozer DEGRADED raidz2-0 DEGRADED c8t0d0 ONLINE c8t1d0 ONLINE c8t2d0 ONLINE c8t3d0 UNAVAIL cannot open c8t4d0 ONLINE device details: c8t3d0 UNAVAIL cannot open status: ZFS detected errors on this device. The device was missing. # zpool import -Df dozer # zpool status -x pool: dozer state: DEGRADED status: One or more devices are unavailable in response to persistent errors. Sufficient replicas exist for the pool to continue functioning in a degraded state. action: Determine if the device needs to be replaced, and clear the errors using 'zpool clear' or 'fmadm repaired', or replace the device with 'zpool replace'. Run 'zpool status -v' to see device specific details. scan: none requested config: NAME STATE READ WRITE CKSUM dozer DEGRADED 0 0 0 raidz2-0 DEGRADED 0 0 0 c8t0d0 ONLINE 0 0 0 c8t1d0 ONLINE 0 0 0 c8t2d0 ONLINE 0 0 0 4881130428504041127 UNAVAIL 0 0 0 c8t4d0 ONLINE 0 0 0 errors: No known data errors # zpool online dozer c8t4d0 # zpool status -x all pools are healthy