Wednesday, November 18, 2009

Gzip with ZFS pools and Datasets..Mmmm. Tasty!

In case you weren't aware, Gzip compression is now available (has been, for a bit now) with ZFS Datasets in Solaris 10. Yay!

To set:

Identify the existing pool/dataset you want to enable the compression on:
root@Yourbox-> zpool list
NAME SIZE USED AVAIL CAP HEALTH ALTROOT
adminpool 980G 81K 980G 0% ONLINE -
rpool 29.8G 20.7G 9.09G 69% ONLINE -

root@Yourbox-> zpool status adminpool
pool: adminpool
state: ONLINE
scrub: none requested
config:

NAME STATE READ WRITE CKSUM
adminpool ONLINE 0 0 0
c1t1d0 ONLINE 0 0 0
c1t2d0 ONLINE 0 0 0
c1t3d0 ONLINE 0 0 0
c1t4d0 ONLINE 0 0 0

errors: No known data errors

root@Yourbox-> zfs get compression adminpool
NAME PROPERTY VALUE SOURCE
adminpool compression on local

Turn on or change compression algorithm:
root@Yourbox-> zfs set compression=gzip-9 adminpool

Check if set:
root@Yourbox-> zfs get compression adminpool
NAME PROPERTY VALUE SOURCE
adminpool compression gzip-9 local

You can also set at dataset creation time (See example, further below).



You can also choose the level of Gzip compression (1-9). Default is level 6, basically, where 1 is fastest and 9 is most compressed.

You don't have to set the whole pool and rely on inheritance (datasets under the pool) for subsequent datasets, adn the pool's level can differ from the child dataset: You can specify for each dataset, under the pool, specifically. This is useful where you may have several datasets maintained under the same pool, and one may need more compression, whereas another may need better performance.


root@Yourbox-> zfs create -o compression=gzip adminpool/yourdata

root@Yourbox-> zfs get compression adminpool/yourdata
NAME PROPERTY VALUE SOURCE
adminpool/yourdata compression gzip local

root@Yourbox-> zfs get compression adminpool
NAME PROPERTY VALUE SOURCE
adminpool compression gzip-9 local


Compression in ZFS improves I/O.

There are a ton of articles and comparisons out there now, so just google for it.

One thing to note is that the default lzjb may be better suited for run-time apps, whereas Gzip may be better suited for archival. There's some debate on this, out there. Try it out and you can make the determination, for yourself, after some testing.

Have fun!

No comments: