{"id":951,"date":"2016-04-20T17:46:58","date_gmt":"2016-04-21T00:46:58","guid":{"rendered":"http:\/\/blog.ls-al.com\/?p=951"},"modified":"2016-04-20T17:46:58","modified_gmt":"2016-04-21T00:46:58","slug":"ubuntu-zfs-replication","status":"publish","type":"post","link":"https:\/\/blog.ls-al.com\/ubuntu-zfs-replication\/","title":{"rendered":"Ubuntu ZFS replication"},"content":{"rendered":"

Most of you will know that Ubuntu 16.04 will have ZFS merged into the kernel. Despite licensing arguments I see this as a positive move. I recently tested btrfs replication (http:\/\/blog.ls-al.com\/btrfs-replication\/) but being a long time Solaris admin and understanding how easy ZFS makes things I welcome this development. Here is a quick test of ZFS replication between two Ubuntu 16.04 hosts.<\/p>\n

Install zfs utils on both hosts.<\/p>\n

\r\n# apt-get install zfsutils-linux\r\n<\/pre>\n

Quick and dirty create zpools using an image just for the test.<\/p>\n

\r\nroot@u1604b1-m1:~# dd if=\/dev\/zero of=\/tank1.img bs=1G count=1 &> \/dev\/null\r\nroot@u1604b1-m1:~# zpool create tank1 \/tank1.img \r\nroot@u1604b1-m1:~# zpool list\r\nNAME    SIZE  ALLOC   FREE  EXPANDSZ   FRAG    CAP  DEDUP  HEALTH  ALTROOT\r\ntank1  1008M    50K  1008M         -     0%     0%  1.00x  ONLINE  -\r\n\r\nroot@u1604b1-m2:~# dd if=\/dev\/zero of=\/tank1.img bs=1G count=1 &> \/dev\/null\r\nroot@u1604b1-m2:~# zpool create tank1 \/tank1.img\r\nroot@u1604b1-m2:~# zpool list\r\nNAME    SIZE  ALLOC   FREE  EXPANDSZ   FRAG    CAP  DEDUP  HEALTH  ALTROOT\r\ntank1  1008M    64K  1008M         -     0%     0%  1.00x  ONLINE  -\r\nroot@u1604b1-m2:~# zfs list\r\nNAME    USED  AVAIL  REFER  MOUNTPOINT\r\ntank1    55K   976M    19K  \/tank1\r\n<\/pre>\n

Copy a file into the source file system.<\/p>\n

\r\nroot@u1604b1-m1:~# cp \/media\/sf_E_DRIVE\/W.pdf \/tank1\/\r\nroot@u1604b1-m1:~# ls -lh \/tank1\r\ntotal 12M\r\n-rwxr-x--- 1 root root 12M Apr 20 19:22 W.pdf\r\n<\/pre>\n

Take a snapshot.<\/p>\n

\r\nroot@u1604b1-m1:~# zfs snapshot tank1@snapshot1\r\nroot@u1604b1-m1:~# zfs list -t snapshot\r\nNAME              USED  AVAIL  REFER  MOUNTPOINT\r\ntank1@snapshot1      0      -  11.2M  -\r\n<\/pre>\n

Verify empty target<\/p>\n

\r\nroot@u1604b1-m2:~# zfs list\r\nNAME    USED  AVAIL  REFER  MOUNTPOINT\r\ntank1    55K   976M    19K  \/tank1\r\n\r\nroot@u1604b1-m2:~# zfs list -t snapshot\r\nno datasets available\r\n<\/pre>\n

Send initial<\/p>\n

\r\nroot@u1604b1-m1:~# zfs send tank1@snapshot1 | ssh root@192.168.2.29 zfs recv tank1\r\nroot@192.168.2.29's password: \r\ncannot receive new filesystem stream: destination 'tank1' exists\r\nmust specify -F to overwrite it\r\nwarning: cannot send 'tank1@snapshot1': Broken pipe\r\n\r\nroot@u1604b1-m1:~# zfs send tank1@snapshot1 | ssh root@192.168.2.29 zfs recv -F tank1\r\nroot@192.168.2.29's password: \r\n<\/pre>\n

Check target.<\/p>\n

\r\nroot@u1604b1-m2:~# zfs list -t snapshot\r\nNAME              USED  AVAIL  REFER  MOUNTPOINT\r\ntank1@snapshot1      0      -  11.2M  -\r\nroot@u1604b1-m2:~# ls -lh \/tank1\r\ntotal 12M\r\n-rwxr-x--- 1 root root 12M Apr 20 19:22 W.pdf\r\n<\/pre>\n

Lets populate one more file and take a new snapshot.<\/p>\n

\r\nroot@u1604b1-m1:~# cp \/media\/sf_E_DRIVE\/S.pdf \/tank1\r\nroot@u1604b1-m1:~# zfs snapshot tank1@snapshot2\r\n<\/pre>\n

Incremental send<\/p>\n

\r\nroot@u1604b1-m1:~# zfs send -i tank1@snapshot1 tank1@snapshot2 | ssh root@192.168.2.29 zfs recv tank1\r\nroot@192.168.2.29's password: \r\n<\/pre>\n

Check target<\/p>\n

\r\nroot@u1604b1-m2:~# ls -lh \/tank1\r\ntotal 12M\r\n-rwxr-x--- 1 root root 375K Apr 20 19:27 S.pdf\r\n-rwxr-x--- 1 root root  12M Apr 20 19:22 W.pdf\r\n\r\nroot@u1604b1-m2:~# zfs list -t snapshot\r\nNAME              USED  AVAIL  REFER  MOUNTPOINT\r\ntank1@snapshot1     9K      -  11.2M  -\r\ntank1@snapshot2      0      -  11.5M  -\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"

Most of you will know that Ubuntu 16.04 will have ZFS merged into the kernel. Despite licensing arguments I see<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[31,30],"tags":[],"class_list":["post-951","post","type-post","status-publish","format-standard","hentry","category-ubuntu","category-zfs"],"_links":{"self":[{"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/posts\/951","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/comments?post=951"}],"version-history":[{"count":0,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/posts\/951\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/media?parent=951"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/categories?post=951"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/tags?post=951"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}