ZFS Overview and GuideDon Turnbull, March 2007
ZFS is Sun Microsystems' newest method of managing storage in the Solaris 10 Operating System. ZFS incorporates a volume management system with a POSIX-compliant file system and a rich set of management tools. From the perspective of applications, the file system behaves exactly as traditional file systems behave but offers much improved performance and capacity. Finally, ZFS affords the system administrator with a wide range of tools comparable to the best volume management and backup solutions. This guide is intended to provide an overview that is useful when configuring ZFS for the first time.
ZFS incorporates many features and options not covered in this guide. These features are useful
in specific circumstances not suitable for inclusion in this general overview. Please refer to
the man pages, General ConceptsStorage Pools ZFS organizes physical devices into logical pools called storage pools. Both individual disks and array logical unit numbers (LUNs) visible to the operating system may be included in a ZFS pools. ZFS can be based on other less traditional storage structures as well, but these features are not covered in this guide. Storage pools can be sets of disks striped together with no redundancy (RAID 0), mirrored disks (RAID 1), striped mirror sets (RAID 1 + 0), or striped with parity (RAID Z). Additional disks can be added to pools at any time but they must be added with the same RAID level. For example, if a pool is configured with RAID 1, disks may be added only to the pool in mirrored sets in the same number as was used when the pool was created. As disks are added to pools, the additional storage is automatically used from that point forward. Note: Adding disks to a pool causes data to be written to the new disks as writes are performed on the pool. Existing data is not redistributed automatically, but is redistributed when modified. When organizing disks into pools, the following issues should be considered:
Note: RAID-Z is a special implementation of RAID-5 for ZFS allowing stripe sets to be more easily expanded with higher performance and availability. Tip 1:
Storage pools perform better as more disks are included. Include as
many disks in each pool as possible and build multiple file systems on each pool.
ZFS File System ZFS offers a POSIX-compliant file system interface to the operating system. In short, a ZFS file system looks and acts exactly like a UFS file system except that ZFS files can be much larger, ZFS file systems can be much larger, and ZFS will perform much better when configured properly. Note: It is not necessary to know how big a file system needs to be to create it. ZFS file systems will grow to the size of their storage pools automatically.ZFS file systems must be built in one and only one storage pool, but a storage pool may have more than one defined file system. Each file system in a storage pool has access to all the unused space in the storage pool. As any one file system uses space, that space is reserved for that file system until the space is released back to the pool by removing the file(s) occupying the space. During this time, the available free space on all the file systems based on the same pool will decrease. ZFS file systems are not necessarily managed in the Finally, the default mount point for a ZFS file system is based on the name
of the pool and the name of the file system. For example, a file system named
Command-Line InterfaceThe command-line interface consists primarily of the For example, assume that a new server named Planning for ZFS Tip 2:
Use the
format command to determine the list of available devices and to
address configuration problems with those devices.
The following steps must be performed prior to configuring ZFS on a new system. All commands must be issued by root or by a user with root authority:
Additional planning information can be found at docs.sun.com. In the running example, two bodies of JBOD ("just a bunch of disks" or non-RAID managed storage) are attached to the server. Though there is no reason to avoid hardware RAID systems when using ZFS, this example is clearer without hardware RAID systems. The following table lists the physical devices presented from attached storage.
Based on the need to separate indexes from data, it is decided to use
two pools named Creating a Storage Pool Storage pools are created with the # zpool create <pool_name> [<configuration>] <device_files> The command requires the user to supply a name for the new pool and the disk device file names without path ( Tip 3:
Check out the
-m option for defining a specific mount point
or the -R option for redefining the relative root path for the default mount point.
Continuing the example, the # zpool create indexes raidz c2t0d0 c2t1d0 c2t2d0 \ c2t3d0 c4t0d0 c4t1d0 c4t2d0 c4t3d0 # zpool create tables raidz c3t0d0 c3t1d0 c3t2d0 \ c3t3d0 c5t0d0 c5t1d0 c5t2d0 c5t3d0 The effect of these commands will be to create two pools
named The pools are automatically brought online and mounted as ZFS file systems
against Creating File Systems If the default file system that is created is not adequate to suit the needs of the system, additional file systems can be created using the Suppose, in the running example, two databases were to be configured on the new storage and for management purposes, each database needed to have its own mount points in the # zfs create indexes/db1 # zfs create indexes/db2 # zfs create tables/db1 # zfs create tables/db2 Note: Be careful when naming file systems. It is possible to reuse the same name for different file systems in different pools, which might be confusing. The effect is to add a separate mount point for
The space available to Tip 4:
Check out the
set options of the zfs command
to manipulate the mount point and other properties of each file system.
Displaying Information Information on the pools and file systems can be displayed using the # 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 Monitoring Though a detailed discussion of monitoring is out of this document's scope, this overview would be incomplete without some mention of the ZFS built-in monitoring. As with management, the command to monitor the system is simple: # zpool iostat <pool_name> <interval> <count> This command works very much like the The command output is as follows:
# 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
Other commands can be used to contribute to an administrator's
understanding of the status, performance, options, and configuration of running
ZFS pools and file systems. Please read the man pages for Summary With just the two commands, Please note that there is no requirement in ZFS that disks be separated by controller, be stand-alone drives, be internal or external, be managed by hardware RAID controllers, or be attached using any particular technology. ZFS will manage any storage device that represents itself all or in part as a device file in the Solaris OS. The example is meant to provide context for the information in this guide; it does not provide a complete demonstration of ZFS capabilities. Sample ScriptHere is a sample script that can be cut and pasted to perform the running example. Be sure to change anything in the script shown in bold to suit the local requirements: #!/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 (data1), 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 data1 raidz c2t0d0 c2t1d0 c2t2d0 c2t3d0 c4t0d0 c4t1d0 c4t2d0 c4t3d0 # Create second pool. Change the pool name (data2), 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 data2 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 (data1) to suit the pools created previously and the # file system name (fs1) to suit your local needs. Please see # the zfs man page for information on options and settings. zfs create data1/fs1 # 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 (data1) to suit the pools created previously and the # file system name (fs2) to suit your local needs. Please # see the zfs man page for information on options and settings. zfs create data1/fs2 # 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 (data2) to suit the pools created previously # and the file system name (fs1) to suit your local needs. # Please see the zfs man page for information on options and # settings. zfs create data2/fs1 # 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 (data2) to suit the pools created previously and # the file system name (fs2) to suit your local needs. Please # see the zfs man page for information on options and settings. zfs create data2/fs2 For More Information
Unless otherwise licensed, code in all technical manuals herein (including articles, FAQs, samples) is provided under this License. |
| ||||||||||||||||||||