Oracle Solaris 11 ZFS Lab for Openworld 2012

Posted by user12626122 on Oracle Blogs See other posts from Oracle Blogs or by user12626122
Published on Thu, 11 Oct 2012 11:08:15 +0000 Indexed on 2012/10/11 15:43 UTC
Read the original article Hit count: 387

Filed under:

Preface

This is the content from the Oracle Openworld 2012 ZFS lab. It was well attended - the feedback was that it was a little short - thats probably because in writing it I bacame very time-concious after the ASM/ACFS on Solaris extravaganza I ran last year which was almost too long for mortal man to finish in the 1 hour session. Enjoy.

Table of Contents

Introduction

This set of exercises is designed to briefly demonstrate new features in Solaris 11 ZFS file system: Deduplication, Encryption and Shadow Migration. Also included is the creation of zpools and zfs file systems - the basic building blocks of the technology, and also Compression which is the compliment of Deduplication. The exercises are just introductions - you are referred to the ZFS Adminstration Manual for further information. From Solaris 11 onward the online manual pages consist of zpool(1M) and zfs(1M) with further feature-specific information in zfs_allow(1M), zfs_encrypt(1M) and zfs_share(1M). The lab is easily carried out in a VirtualBox running Solaris 11 with 6 virtual 3 Gb disks to play with.

Exercise Z.1: ZFS Pools

Task: You have several disks to use for your new file system. Create a new zpool and a file system within it.

Lab: You will check the status of existing zpools, create your own pool and expand it.

Your Solaris 11 installation already has a root ZFS pool. It contains the root file system. Check this:

root@solaris:~# zpool list
NAME    SIZE  ALLOC   FREE  CAP  DEDUP  HEALTH  ALTROOT
rpool  15.9G  6.62G  9.25G  41%  1.00x  ONLINE  -

root@solaris:~# zpool status 
pool: rpool
state: ONLINE
scan: none requested
config:

NAME        STATE     READ WRITE CKSUM
rpool       ONLINE       0     0     0
  c3t0d0s0  ONLINE       0     0     0

errors: No known data errors

Note the disk device the root pool is on - c3t0d0s0

Now you will create your own ZFS pool. First you will check what disks are available:

root@solaris:~# echo | format 
Searching for disks...done

AVAILABLE DISK SELECTIONS:
0. c3t0d0 <ATA-VBOX HARDDISK-1.0 cyl 2085 alt 2 hd 255 sec 63>
/pci@0,0/pci8086,2829@d/disk@0,0
1. c3t2d0 <ATA-VBOX HARDDISK-1.0 cyl 1534 alt 2 hd 128 sec 32>
/pci@0,0/pci8086,2829@d/disk@2,0
2. c3t3d0 <ATA-VBOX HARDDISK-1.0 cyl 1534 alt 2 hd 128 sec 32>
/pci@0,0/pci8086,2829@d/disk@3,0
3. c3t4d0 <ATA-VBOX HARDDISK-1.0 cyl 1534 alt 2 hd 128 sec 32>
/pci@0,0/pci8086,2829@d/disk@4,0
4. c3t5d0 <ATA-VBOX HARDDISK-1.0 cyl 1534 alt 2 hd 128 sec 32>
/pci@0,0/pci8086,2829@d/disk@5,0
5. c3t6d0 <ATA-VBOX HARDDISK-1.0 cyl 1534 alt 2 hd 128 sec 32>
/pci@0,0/pci8086,2829@d/disk@6,0
6. c3t7d0 <ATA-VBOX HARDDISK-1.0 cyl 1534 alt 2 hd 128 sec 32>
/pci@0,0/pci8086,2829@d/disk@7,0
Specify disk (enter its number): Specify disk (enter its number): 

The root disk is numbered 0. The others are free for use. Try creating a simple pool and observe the error message:

root@solaris:~# zpool create mypool c3t2d0 c3t3d0 
'mypool' successfully created, but with no redundancy; failure of one
device will cause loss of the pool

So destroy that pool and create a mirrored pool instead:

root@solaris:~# zpool destroy mypool  
root@solaris:~# zpool create mypool mirror c3t2d0 c3t3d0 
root@solaris:~# zpool status mypool 
pool: mypool
state: ONLINE
scan: none requested
config:

NAME        STATE     READ WRITE CKSUM
mypool      ONLINE       0     0     0
  mirror-0  ONLINE       0     0     0
    c3t2d0  ONLINE       0     0     0
    c3t3d0  ONLINE       0     0     0

errors: No known data errors

Back to top

Exercise Z.2: ZFS File Systems

Task: You have to create file systems for later exercises.

You can see that when a pool is created, a file system of the same name is created:

root@solaris:~# zfs list 
NAME                     USED  AVAIL  REFER  MOUNTPOINT
mypool                  86.5K  2.94G    31K  /mypool

Create your filesystems and mountpoints as follows:

root@solaris:~# zfs create -o mountpoint=/data1 mypool/mydata1 

The -o option sets the mount point and automatically creates the necessary directory.

root@solaris:~# zfs list mypool/mydata1 
NAME            USED  AVAIL  REFER  MOUNTPOINT
mypool/mydata1   31K  2.94G    31K  /data1

Back to top

Exercise Z.3: ZFS Compression

Task:Try out different forms of compression available in ZFS

Lab:Create 2nd filesystem with compression, fill both file systems with the same data, observe results

You can see from the zfs(1) manual page that there are several types of compression available to you, set with the property=value syntax:

compression=on | off | lzjb | gzip | gzip-N | zle

 Controls  the  compression  algorithm  used   for   this
 dataset. The lzjb compression algorithm is optimized for
 performance while  providing  decent  data  compression.
 Setting  compression  to  on  uses  the lzjb compression
 algorithm. The gzip compression algorithm uses the  same
 compression  as the gzip(1) command. You can specify the
 gzip level by using the  value  gzip-N  where  N  is  an
 integer  from 1 (fastest) to 9 (best compression ratio).
 Currently, gzip is equivalent to gzip-6 (which  is  also
 the default for gzip(1)).

Create a second filesystem with compression turned on. Note how you set and get your values separately:

root@solaris:~# zfs create -o mountpoint=/data2 mypool/mydata2 
root@solaris:~# zfs set compression=gzip-9 mypool/mydata2 
root@solaris:~# zfs get compression mypool/mydata1 
NAME            PROPERTY     VALUE     SOURCE
mypool/mydata1  compression  off       default

root@solaris:~# zfs get compression mypool/mydata2 
NAME            PROPERTY     VALUE     SOURCE
mypool/mydata2  compression  gzip-9    local

Now you can copy the contents of /usr/lib into both your normal and compressing filesystem and observe the results. Don't forget the dot or period (".") in the find(1) command below:

root@solaris:~# cd /usr/lib
root@solaris:/usr/lib# find . -print | cpio -pdv /data1 
root@solaris:/usr/lib# find . -print | cpio -pdv /data2 

The copy into the compressing file system takes longer - as it has to perform the compression but the results show the effect:

root@solaris:/usr/lib# zfs list 
NAME                     USED  AVAIL  REFER  MOUNTPOINT
mypool                  1.35G  1.59G    31K  /mypool
mypool/mydata1          1.01G  1.59G  1.01G  /data1
mypool/mydata2           341M  1.59G   341M  /data2

Note that the available space in the pool is shared amongst the file systems. This behavior can be modified using quotas and reservations which are not covered in this lab but are covered extensively in the ZFS Administrators Guide.

Back to top

Exercise Z.4: ZFS Deduplication

The deduplication property is used to remove redundant data from a ZFS file system. With the property enabled duplicate data blocks are removed synchronously. The result is that only unique data is stored and common componenents are shared.

Task:See how to implement deduplication and its effects

Lab: You will create a ZFS file system with deduplication turned on and see if it reduces the amount of physical storage needed when we again fill it with a copy of /usr/lib.

root@solaris:/usr/lib# zfs destroy mypool/mydata2 
root@solaris:/usr/lib# zfs set dedup=on mypool/mydata1
root@solaris:/usr/lib# rm -rf /data1/*  
root@solaris:/usr/lib# mkdir /data1/2nd-copy
root@solaris:/usr/lib# zfs list
NAME                     USED  AVAIL  REFER  MOUNTPOINT
mypool                  1.02M  2.94G    31K  /mypool
mypool/mydata1            43K  2.94G    43K  /data1
root@solaris:/usr/lib# find . -print | cpio -pd /data1
2142768 blocks
root@solaris:/usr/lib# zfs list
NAME                     USED  AVAIL  REFER  MOUNTPOINT
mypool                  1.02G  1.99G    31K  /mypool
mypool/mydata1          1.01G  1.99G  1.01G  /data1
root@solaris:/usr/lib# find . -print | cpio -pd /data1/2nd-copy 
2142768 blocks
root@solaris:/usr/lib#zfs list
NAME                     USED  AVAIL  REFER  MOUNTPOINT
mypool                  1.99G  1.96G    31K  /mypool
mypool/mydata1          1.98G  1.96G  1.98G  /data1

You could go on creating copies for quite a while...but you get the idea. Note that deduplication and compression can be combined: the compression acts on metadata.

Deduplication works across file systems in a pool and there is a zpool-wide property dedupratio:

root@solaris:/usr/lib# zpool get dedupratio mypool
NAME    PROPERTY    VALUE  SOURCE
mypool  dedupratio  4.30x  -

Deduplication can also be checked using "zpool list":

root@solaris:/usr/lib# zpool list
NAME     SIZE  ALLOC   FREE  CAP  DEDUP  HEALTH  ALTROOT
mypool  2.98G  1001M  2.01G  32%  4.30x  ONLINE  -
rpool   15.9G  6.66G  9.21G  41%  1.00x  ONLINE  -

Before moving on to the next topic, destroy that dataset and free up some space:

root@solaris:~# zfs destroy  mypool/mydata1 

Back to top

Exercise Z.5: ZFS Encryption

Task: Encrypt sensitive data.

Lab: Explore basic ZFS encryption.

This lab only covers the basics of ZFS Encryption. In particular it does not cover various aspects of key management. Please see the ZFS Adminastrion Manual and the zfs_encrypt(1M) manual page for more detail on this functionality.

Back to top

root@solaris:~# zfs create -o encryption=on mypool/data2 
Enter passphrase for 'mypool/data2': ********
Enter again: ********
root@solaris:~# 

Creation of a descendent dataset shows that encryption is inherited from the parent:

root@solaris:~# zfs create mypool/data2/data3 
root@solaris:~# zfs get -r  encryption,keysource,keystatus,checksum mypool/data2 
NAME                PROPERTY    VALUE              SOURCE
mypool/data2        encryption  on                 local
mypool/data2        keysource   passphrase,prompt  local
mypool/data2        keystatus   available          -
mypool/data2        checksum    sha256-mac         local
mypool/data2/data3  encryption  on                 inherited from mypool/data2
mypool/data2/data3  keysource   passphrase,prompt  inherited from mypool/data2
mypool/data2/data3  keystatus   available          -
mypool/data2/data3  checksum    sha256-mac         inherited from mypool/data2
You will find the online manual page zfs_encrypt(1M) contains examples. In particular, if time permits during this lab session you may wish to explore the changing of a key using "zfs key -c mypool/data2".

Exercise Z.6: Shadow Migration

Shadow Migration allows you to migrate data from an old file system to a new file system while simultaneously allowing access and modification to the new file system during the process. You can use Shadow Migration to migrate a local or remote UFS or ZFS file system to a local file system.

Task: You wish to migrate data from one file system (UFS, ZFS, VxFS) to ZFS while mainaining access to it.

Lab: Create the infrastructure for shadow migration and transfer one file system into another.

First create the file system you want to migrate

root@solaris:~# zpool create oldstuff c3t4d0 
root@solaris:~# zfs create oldstuff/forgotten 

Then populate it with some files:

root@solaris:~# cd /var/adm 
root@solaris:/var/adm# find . -print | cpio -pdv /oldstuff/forgotten

You need the shadow-migration package installed:

root@solaris:~# pkg install shadow-migration
           Packages to install:  1
       Create boot environment: No
Create backup boot environment: No
            Services to change:  1

DOWNLOAD                                  PKGS       FILES    XFER (MB)
Completed                                  1/1       14/14      0.2/0.2

PHASE                                        ACTIONS
Install Phase                                  39/39

PHASE                                          ITEMS
Package State Update Phase                       1/1 
Image State Update Phase                         2/2 

You then enable the shadowd service:

root@solaris:~# svcadm enable shadowd
root@solaris:~# svcs shadowd 
STATE          STIME    FMRI
online          7:16:09 svc:/system/filesystem/shadowd:default

Set the filesystem to be migrated to read-only

root@solaris:~# zfs set readonly=on oldstuff/forgotten

Create a new zfs file system with the shadow property set to the file system to be migrated:

root@solaris:~# zfs create -o shadow=file:///oldstuff/forgotten   mypool/remembered 

Use the shadowstat(1M) command to see the progress of the migration:

root@solaris:~# shadowstat 
					EST		
				BYTES	BYTES		ELAPSED
DATASET				XFRD	LEFT	ERRORS	TIME
mypool/remembered               92.5M	-	-	00:00:59
mypool/remembered               99.1M	302M	-	00:01:09
mypool/remembered               109M	260M	-	00:01:19
mypool/remembered               133M	304M	-	00:01:29
mypool/remembered               149M	339M	-	00:01:39
mypool/remembered               156M	86.4M	-	00:01:49
mypool/remembered               156M	8E	29		(completed)

Note that if you had created /mypool/remembered as encrypted, this would be the preferred method of encrypting existing data. Similarly for compressing or deduplicating existing data.

The procedure for migrating a file system over NFS is similar - see the ZFS Administration manual.

That concludes this lab session.

© Oracle Blogs or respective owner

Related posts about /Storage