Messing around with ZFS on opensolaris a bit before Oracle kills it once and for all.

ZFS and opensolaris make for a fantastic log server. Logs compress well. ZFS has built-in compression, snapshotting, and the Sun/Solaris NFS server is leaps-and-bounds above linux as far as stability goes. Here’s how to make a ZFS nfs server that uses transparent compression. It’s super-simple.

Install opensolaris, log in as root and do this:

format

(that will give you the disks that it finds - pick out a few that you’d like to use for the ZFS filesystem)

zpool create vault raidz disk1 disk2 disk3 ... zfs set compression=on vault zfs set sharenfs=rw=@10.0.0.0/24 vault

Now, wasn’t that simple?

Now, you’ve got an exported filesystem that has transparent compression, it’s raided. Let’s enable snapshots so we don’t have to worry about file rotation!

svcadm enable svc:/system/filesystem/zfs/auto-snapshot:daily

It’ll take a snapshot immediately for every new share, check it out:

root@opensolaris:/vault# zfs list -r -t snapshot | grep vault vault@zfs-auto-snap:daily-2010-06-28-14:22 0 - 1.48M -

Delete some files and go get them again via the snapshot.

root@opensolaris:/vault# ls mpdscribble.log syslog syslog.0 syslog.1.gz syslog.2.gz syslog.3.gz syslog.4.gz syslog.5.gz syslog.6.gz user.log.0 root@opensolaris:/vault# rm syslog root@opensolaris:/vault# ls /vault/.zfs/snapshot/zfs-auto-snap:daily-2010-06-28-14:22 mpdscribble.log syslog syslog.0 syslog.1.gz syslog.2.gz syslog.3.gz syslog.4.gz syslog.5.gz syslog.6.gz user.log.0 root@opensolaris:/vault# ls -la /vault/.zfs/snapshot/zfs-auto-snap:daily-2010-06-28-14:22/syslog -rw-r----- 1 nobody nobody 394494 2010-06-28 14:00 /vault/.zfs/snapshot/zfs-auto-snap:daily-2010-06-28-14:22/syslog

Now, just prune files > 1 day old, and we’re done. If you need to store more logs, just add another disk to your array and you’ve got more space. It’s awesome.

Woohoo! No log rotation, no compression. No mess, no fuss. :) ZFS is awesome!

Tweet
submit to reddit