目前有个专门的网站,最新版本是spl-0.6.3 / zfs-0.6.3(2014-11-25)
http://zfsonlinux.org/
安装比较简单:
yum localinstall --nogpgcheck https://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm yum localinstall --nogpgcheck http://archive.zfsonlinux.org/epel/zfs-release.el6.noarch.rpm yum install kernel-devel dkms spl zfs spl-modules-dkms zfs-modules-dkms
经常会出现如下错误:
Failed to load ZFS module stack. Load the module manually by running 'insmod/zfs.ko' as root.
大部分原因是kernel不够新, 解决办法如下:
rpm -qa | grep kernel yum upgrade reboot --根据情况 yum reinstall dkms spl zfs spl-modules-dkms zfs-modules-dkms
使用dd工具测试
dd使用详解 http://tanxin.blog.51cto.com/6114226/1162588
备份磁盘开始的512个字节大小的MBR信息到指定文件
dd if=/dev/hda of=/root/image count=1 bs=512
count=1指仅拷贝一个块;bs=512指块大小为512个字节。
恢复:dd if=/root/image of=/dev/hda
mkdir zfstest cd zfstest dd if=/dev/zero of=disk1.img bs=64M count=1 dd if=/dev/zero of=disk2.img bs=64M count=1 dd if=/dev/zero of=disk3.img bs=64M count=1 dd if=/dev/zero of=disk4.img bs=64M count=1 $ ls disk1.img disk2.img disk3.img disk4.img $ losetup /dev/loop0 ./disk1.img $ losetup /dev/loop1 ./disk2.img $ losetup /dev/loop2 ./disk3.img $ losetup /dev/loop3 ./disk4.img
创建 ZFS 池
zpool create myzpool raidz /dev/loop0 /dev/loop1 /dev/loop2 /dev/loop3 [root@localhost ~]# zfs list NAME USED AVAIL REFER MOUNTPOINT myzpool 1.93M 144M 43.4K /myzpool myzpool/myzdev 1.77M 144M 1.77M /myzpool/myzdev
查看详细情况
zfs get all myzpool
设置压缩
zfs set compression=on myzpool/myzdev
测试压缩情况:
cp /logs/goldoffice_mt5_web1.log /myzpool/myzdev
[root@localhost ~]# ls -la /logs/goldoffice_mt5_web1.log -rw-r--r-- 1 root root 6362448 Oct 29 10:04 /logs/goldoffice_mt5_web1.log [root@localhost ~]# ls -la /myzpool/myzdev/ total 1771 drwxr-xr-x 2 root root 3 Nov 25 14:37 . drwxr-xr-x 3 root root 3 Nov 25 14:34 .. -rw-r--r-- 1 root root 6362448 Nov 25 14:37 goldoffice_mt5_web1.log [root@localhost ~]# du -ah /myzpool/myzdev/ 1.8M /myzpool/myzdev/goldoffice_mt5_web1.log 1.8M /myzpool/myzdev/ [root@localhost ~]# zfs get compressratio myzpool NAME PROPERTY VALUE SOURCE myzpool compressratio 3.49x -
从结果看压缩了3.49倍, 相当给力