ZFS 概述和指南Don Turnbull,2007 年 3 月(于 2009 年 3 月更新)
ZFS 是 Sun Microsystems 提供的、在 Solaris 10 操作系统中管理存储的最新方法。ZFS 将卷管理系统与遵循 POSIX 的文件系统以及丰富的管理工具集进行了集成。从应用角度而言,该文件系统与传统文件系统具有完全相同的行为方式,唯一的不同之处在于该文件系统的性能更高、容量更大。最后,ZFS 为系统管理员提供了各种工具,这些工具可与最佳卷管理和备份解决方案相媲美。 本指南的目的是提供在初次配置 ZFS 时有用的概述。ZFS 所具有的许多功能和选项在本指南中并未涉及。这些功能在特定情况下非常有用,但本指南只是一般性概述,因此不适合介绍这些功能。有关更多详细信息,请参阅手册页 一般概念存储池 ZFS 将物理设备组织到名为存储池的逻辑池中。对操作系统可见的单个磁盘和阵列逻辑单元号 (Logical Unit Number, LUN) 均可包含在 ZFS 池中。ZFS 也可基于其他不太传统的存储结构,但本指南中未涉及此类专题。 存储池可以是不提供冗余功能的条带化磁盘阵列 (RAID 0)、镜像磁盘阵列 (RAID 1)、条带化的镜像磁盘阵列 (RAID 1 + 0) 或带奇偶校验的条带化磁盘阵列 (RAID Z)。随时都可以将更多磁盘添加到池中,但这些磁盘必须使用同一 RAID 级别进行添加。例如,如果某个池是使用 RAID 1 进行配置的,则磁盘只能以镜像磁盘阵列(其 RAID 级别号与创建该池时所使用的 RAID 级别号相同)的形式添加到该池中。将磁盘添加到池中时,会自动使用从上一次添加的磁盘所在的存储位置向前递进的其他存储位置。 注意:在对池执行写入操作时,向池中添加磁盘将导致数据被写入到新磁盘中。不会自动对现有数据进行再分发,但在修改现有数据后会对其进行再分发。 将磁盘组织到池中时,应考虑以下问题:
注意:RAID-Z 是 RAID-5 针对 ZFS 的一种特殊实现形式,它使条带化磁盘阵列可以更轻松地扩展,以便具有更高的性能和可用性。 提示 1:
存储池中包含的磁盘越多,其性能就越高。请在各个存储池中包含尽可能多的磁盘,并在各个存储池中构建多个文件系统。
ZFS 文件系统 ZFS 为操作系统提供了一个遵循 POSIX 的文件系统接口。简言之,ZFS 文件系统与 UFS 文件系统具有完全相同的外观和行为,只不过 ZFS 文件和 ZFS 文件系统可能会更大,且 ZFS 在配置正确的情况下性能会更高。 注意:无需明确 ZFS 文件系统在创建时所需具有的大小。 ZFS 文件系统将自动增加到其存储池的大小。ZFS 文件系统必须在一个(且仅此一个)存储池中构建,但一个存储池可以包含多个已定义的文件系统。存储池中的每个文件系统均具有对该存储池中所有未使用空间的访问权限。任一文件系统使用某个空间后,将为该文件系统保留该空间,直到通过删除占用该空间的文件将该空间释放回存储池为止。在此期间,基于同一存储池的所有文件系统上的可用空闲空间都将减少。 ZFS 文件系统并非必须在 最后,ZFS 文件系统的默认挂载点将基于存储池的名称和文件系统的名称。例如:存储池 命令行界面命令行界面主要由 例如,假定正在配置名为 对 ZFS 进行规划 提示 2:
使用
format 命令可确定可用设备的列表并找出这些设备的配置问题。
在新系统上配置 ZFS 之前,必须先执行以下步骤。所有命令都必须由超级用户或具有超级用户权限的用户发出:
可在 docs.sun.com 找到更多规划信息。 在演示示例中,JBOD("just a bunch of disks"(简单磁盘捆绑)或非 RAID 管理的存储器)的两个主体被连接到服务器。尽管在使用 ZFS 时并非一定不能使用硬件 RAID 系统,但在不使用硬件 RAID 系统的情况下,此示例更加清晰明了。下表列出了连接的存储中存在的物理设备。
鉴于需要将索引与数据分离开,我们决定分别使用名为 创建存储池 使用 # zpool create <pool_name> [<configuration>] <device_files> 该命令要求用户提供新存储池的名称以及不含路径的磁盘设备文件名(如 提示 3:
通过
-m 选项定义特定挂载点,或通过 -R 选项重新定义默认挂载点的相对根路径。
继续以示例来说明,用于构建两个 RAID-Z 存储池(共包含八个磁盘,且每个存储池的控制器争用程度均为最低)的 # zpool create indexes raidz c2t0d0 c2t1d0 c2t2d0 \ c2t3d0 c4t0d0 c4t1d0 c4t2d0 c4t3d0 # zpool create tables raidz c3t0d0 c3t1d0 c3t2d0 \ c3t3d0 c5t0d0 c5t1d0 c5t2d0 c5t3d0 使用这些命令将分别创建名为 创建文件系统 如果创建的默认文件系统不足以满足系统需要,可以使用 在演示示例中,假定在新的存储器上配置了两个数据库,为了便于管理,每个数据库在 # zfs create indexes/db1 # zfs create indexes/db2 # zfs create tables/db1 # zfs create tables/db2 注意:在命名文件系统时请务必小心谨慎。虽然可以对不同存储池中的不同文件系统重用同一名称,但这样可能会造成混淆。 结果如下:在每个
提示 4:
通过
zfs 命令的 set 选项,处理每个文件系统的挂载点及其他属性。
显示信息 使用 # zpool list NAME SIZE USED AVAIL CAP HEALTH ALTROOT indexes 240M 110K 240M 0% ONLINE - tables 240M 110K 240M 0% ONLINE - # zfs list NAME USED AVAIL REFER MOUNTPOINT indexes 107K 208M 25.5K /indexes indexes/db1 24.5K 208M 24.5K /indexes/db1 indexes/db2 24.5K 208M 24.5K /indexes/db2 tables 107K 208M 25.5K /tables tables/db1 24.5K 208M 24.5K /indexes/db1 tables/db2 24.5K 208M 24.5K /indexes/db2 监视 尽管本文档中并未涉及有关监视功能的详细讨论,但如果不提及 ZFS 内置监视功能,本概述可能会稍显欠缺。与管理一样,用于监视系统的命令也非常简单: # zpool iostat <pool_name> <interval> <count> 此命令与操作系统中提供的 该命令输出如下所示:
# zpool iostat test_pool 5 10
capacity operations bandwidth
pool used avail read write read write
---------- ----- ----- ----- ----- ----- -----
test_pool 80K 1.52G 0 7 0 153K
test_pool 80K 1.52G 0 0 0 0
test_pool 80K 1.52G 0 0 0 0
test_pool 80K 1.52G 0 0 0 0
test_pool 80K 1.52G 0 0 0 0
test_pool 80K 1.52G 0 0 0 0
test_pool 80K 1.52G 0 0 0 0
test_pool 80K 1.52G 0 0 0 0
test_pool 80K 1.52G 0 0 0 0
test_pool 80K 1.52G 0 0 0 0
可以使用其他命令帮助管理员了解正在运行的 ZFS 存储池及文件系统的状态、性能、选项和配置。有关详细信息,请参阅 小结 使用 请注意,ZFS 对磁盘没有以下要求:由控制器分隔、是独立驱动器、是内部或外部磁盘、由硬件 RAID 控制器管理或是使用任何特殊技术连接的磁盘。ZFS 将对全部或部分用作 Solaris 操作系统中设备文件的任意存储设备进行管理。列举的示例目的是为本指南中的信息提供上下文,而不提供 ZFS 功能的完整演示。 样例脚本以下是一个样例脚本,可剪切并粘贴以执行演示示例。请务必更改脚本中以粗体显示的内容,以使该脚本满足本地需要: #!/bin/sh # This script must be run as root or as a user with appropriate # role-based access control (RBAC) privileges. ################################################################## # # Create pools # # Creating pools also creates mount points. If you do not need # more mount points than pools and the pool names are acceptable # for mount points, you need not do more than create the pools. # # Create as many pools as you want. Pools define the groups of # disks under management. All disks in a pool must be managed # in the same way (RAID-Z, mirrored, and so on), but each pool # may have a different raid level. Use pools in the same way # traditional RAID manager LUNs are used. # # Create first pool. Change the pool name (indexes), the raid flag # (raidz), and the disk names (c#t#d#) to suite your local # requirements. Read the zpool man page to determine the available # options for the raid flag. zpool create indexes raidz c2t0d0 c2t1d0 c2t2d0 c2t3d0 c4t0d0 c4t1d0 c4t2d0 c4t3d0 # Create second pool. Change the pool name (tables), the raid flag # (raidz), and the disk names (c#t#d#) to suite your local # requirements. Read the zpool man page to determine the available # options for the raid flag. zpool create tables raidz c3t0d0 c3t1d0 c3t2d0 c3t3d0 c5t0d0 c5t1d0 c5t2d0 c5t3d0 ################################################################## # # Create mounts # # Creating mounts may not be necessary as each pool forms a mount # by default. However, if you need more than one mount point per # pool, use the following commands to provide distinct mount # points based on the pools created above. All mount points have # access to the full amount of free space in the mount point's # designated pool. As any one mount point uses space, available # space for all mount points decreases. # # Create the first mount point. The mount will be in the path # shown from root unless changed later. Be sure to change the # pool name (indexes) to suit the pools created previously and the # file system name (db1) to suit your local needs. Please see # the zfs man page for information on options and settings. zfs create indexes/db1 # Create the first mount point. The mount will be in the path # shown from root unless changed later. Be sure to change the # pool name (indexes) to suit the pools created previously and the # file system name (db2) to suit your local needs. Please # see the zfs man page for information on options and settings. zfs create indexes/db2 # Create the first mount point. The mount will be in the path # shown from root unless changed later. Be sure to change # the pool name (tables) to suit the pools created previously # and the file system name (db1) to suit your local needs. # Please see the zfs man page for information on options and # settings. zfs create tables/db1 # Create the first mount point. The mount will be in the path # shown from root unless changed later. Be sure to change the # pool name (tables) to suit the pools created previously and # the file system name (db2) to suit your local needs. Please # see the zfs man page for information on options and settings. zfs create tables/db2 更多信息
2009 年 3 月:
Unless otherwise licensed, code in all technical manuals herein (including articles, FAQs, samples) is provided under this License. |
BigAdmin SubscriptionsBigAdmin Areas
BigAdmin Sun Center
BigAdmin Topics | ||||||||||||||||||||