Seite wählen

NETWAYS Blog

ZFS Cheat Sheet

Wenn man sich mit einem eigenen Linux Storage Servers beschäftigt hat man sicher schon davon gehört: ZFS. Ich beschäftige mich schon seit längerem mit ZFS und bin an einem Punkt an dem ich mir die Menge der Kommandos nicht mehr merken kann. Zu ZFS findet man zwar schon sehr viel im Internet, die Themen Snapshots oder verschlüsselte ZFS-Datasets fehlt aber leider meistens oder die Informationen sind nicht gesammelt an einer Stelle zu finden. Damit ich in Zukunft nicht immer suchen muss und Ihr auch etwas davon habt, schreibe ich hier alles zusammen.

Installation von ZFS unter Debian / Ubuntu
Die Installation wurde unter Debian 10 (Buster) und Ubuntu Server 20.10 (Groovy Gorilla) durchgeführt. Das Einbinden des Backports Repos ist für Ubuntu Server 20.10 nicht notwendig.
# apt-get update
# apt-get upgrade

# vi /etc/apt/sources.list.d/buster-backports.list
deb http://deb.debian.org/debian buster-backports main contrib
deb-src http://deb.debian.org/debian buster-backports main contrib

# vi /etc/apt/preferences.d/90_zfs
Package: libnvpair1linux libuutil1linux libzfs2linux libzpool2linux spl-dkms zfs-dkms zfs-test zfsutils-linux zfsutils-linux-dev zfs-zed
Pin: release n=buster-backports
Pin-Priority: 990

# apt-get update
# apt-get upgrade

--> Reboot (falls es ein Kernelupgrade gab)

# apt install dpkg-dev linux-headers-$(uname -r) linux-image-amd64
# apt install zfs-dkms zfsutils-linux

Erstellen eines einfachen ZFS Storage Pools
Mit folgendem Kommando wird ein ZFS Storage Pool namens „data“ erstellt. Dank „raidz1“ wird eine Redundanz aufgebaut und eine Festplatte kann ohne Probleme ausfallen. Es ist unter anderem auch möglich „raidz2“ oder „raidz3“ zu definieren.
# zpool create data raidz1 sdb sdc sdd
# zpool status

Erstellen eines ZFS Storage Pools mit Partition UUIDs
# ls -la /dev/disk/by-partuuid/
# zpool create data raidz1 00b85ce9-a0d5-9340-b347-cd0bcc714dc0 04c20b90-5678-4b88-af49-21db76427eda 0c35cb57-5bc6-7c49-929f-466102c22d05

Erstellen eines ZFS Datasets
# zfs create data/playground

Erstellen eines verschlüsselten ZFS Datasets
# zfs create -o encryption=aes-256-gcm -o keyformat=passphrase data/playground
# zfs get encryption

Erstellen eines ZFS Snapshots
# zfs snapshot data/playground@`date +%Y-%m-%d_%H-%M-%S`

Löschen eines ZFS Snapshots:
# zfs destroy data/playground@2020-09-12_17-25-42

Durchsuchen von Snapshots (z. B. zum Restore einzelner Daten)
# cd /data/playground/.zfs/snapshot/2020-09-12_17-25-42
# ls -la

Hinzufügen eines SSD-Caches
Erzeugen des Dateisystems auf der Partition:
# zpool create -f log  /dev/sde1
# zpool create -f cache  /dev/sde2

Löschen des Dateisystems:
# zpool destroy log1
# zpool destroy cache1

Hinzufügen von Cache und Log zum ZFS Pool:
# zpool add data log /dev/sde1
# zpool add data cache /dev/sde2

Vorsicht: In diesem Beispiel ist der Cache nicht gespiegelt / abgesichert! Beim Ausfall der SSD wären die Daten im Cache verloren!

Anzeigen der Speicherbelegung über den ganzen ZFS Pool inkl. Snapshots
# zpool set listsnapshots=on data
# zfs list -o space -r data

Tobias Redel
Tobias Redel
Head of Professional Services

Tobias hat nach seiner Ausbildung als Fachinformatiker bei der Deutschen Telekom bei T-Systems gearbeitet. Seit August 2008 ist er bei NETWAYS, wo er in der Consulting-Truppe unsere Kunden in Sachen Open Source, Monitoring und Systems Management unterstützt. Insgeheim führt er jedoch ein Doppelleben als Travel-Hacker und renoviert, baut und bastelt als Heimwerker an allem was er finden kann.

Open Source Backup Conference – 7 reasons | part 4

Hello again! Today, we want to present the location for the special OSBConf evening event on the first conference day:

The restaurant “Belgischer Hof” is in the belgian quarter of Cologne and fascinates with it’s cozy and relaxed atmosphere. Take the opportunity to meet each other for networking and socializing in a casual setting. Enjoy the evening with some drinks and a variety of culinary delights.
The conference will be held from September 25 to 26, 2017 at the Steigenberger Hotel in Cologne.
What awaits you: Core theme of the Open Source Backup Conference is the development and application of open source sofware solutions for data backup. The conference agenda covers the latest developments, conveys strategic knowledge and presents empirical reports as well as best practices, case studies and technical background. Apart from that, three hands-on workshops on September 25 are offered!
Have a look at this great talk by Christian Reiß about Backup with BAREOS and ZFS. 

YouTube player

OSDC 2016: More for your datacenter stack

We need more coffee – the first talk of day 2 directly kicked off with automation and challenges. We are using Foreman at NETWAYS and it helps me on a daily basis to deploy development boxes with Opennebula. So it was interesting to find out about insights and challenges by Julien Pivotto with Automating a R&D lab with Foreman: What can be hard?.

#osdc moa 5 starts w/ @roidelapluie from @inuits on managing a R&D lab with @ForemanProject /mif pic.twitter.com/soED2QNoKO

— netways (@netways) April 28, 2016


Sadly the second talk about Interesting things you can do with ZFS by Allan Jude & Benedict Reuschling was at the same time – again one for the conference archive.

Allan Jude and Benedict Reuschling just started their talk "Interesting Things you can do with ZFS" /mn pic.twitter.com/i0J9ub6Rkw

— netways (@netways) April 28, 2016


Decisions decisions. Mesos and the Architecture of the New Datacenter by Jörg Schad or Hybrid Cloud – A Cloud Migration Strategy by Schlomo Shapiro. I guess I’m one of those devops hipsters going for Mesos. Although I hear that its implementation can be tricky (hi Sebastian) we’re using it at NETWAYS and I wanted to learn more about it. Especially since Mesosphere recently announced DC/OS.

.@mesosphere DC/OS #osdc pic.twitter.com/60PdU1Ljq7

— netways (@netways) April 28, 2016


Ingesting Logs with Style sounds like a swiss army knife presentation style. Logs always remind me of the days when there was not Logstash or Graylog around, just some unacceptable expensive Splunk license and your own central syslog server plus some custom handmade scripts. Pere gave an awesome outlook on what’s coming with Elastic Stack 5.0 including hist sports activities as live demos.

Real life @elastic stack demo from @purbon 's sports activities 🙂 #awesome #osdc /mif pic.twitter.com/XAA83HqTCG

— netways (@netways) April 28, 2016


Everyone knows about Docker. Everyone uses it in production already? Or at least tried to until the company’s security team stepped into? Inspecting Security of Docker formatted Container Images to find Peace of Mind provided insights on the most often asked questions when it comes to production deployments.
Right after lunch David Schmitt gave an interesting Introduction to Testing Puppet Modules. Being a developer and writing tests? Meh. The least exciting part right after the documentation bits. Though tests will make your life easier especially with Puppet modules ensuring they won’t break. The talk’s topic also reminds me of Tom de Vylder maintaining the Icinga puppet modules and insisting on rspec tests on every single PR – chapeau 🙂

@dev_el_ops talking about @puppetize testing at #osdc (rspec, rspec-puppet, beaker) pic.twitter.com/J8ZA7LIPqT

— mika (@mikagrml) April 28, 2016


Coming from MariaDB Colin Charles provided tipps and tricks on Tuning Linux for your Database.

. @bytebot from @mariadb is now on stage, talking about Tuning Linux for your Database! /mn pic.twitter.com/F6bQtRIM8p

— netways (@netways) April 28, 2016


An Introduction to Software Defined Networking (SDN) by Martin Loschwitz or Bareos Backup Integration with Standard Open Source Tools with Maik Aussendorf?

An introduction into SDN with @madkissTM at #osdc/be pic.twitter.com/InUn6I6Klp

— netways (@netways) April 28, 2016


Finally the last talks for this years OSDC. We already learned about Puppet and Salt, now it is time for Kaiten Zushi – Chef at Goodgame Studios by Jan Ulferts. Florian Lautenschlager with Chronix – A fast and efficient time series storage based on Apache Solr was again my favourite for the conference archive.
 

Thank you and see you in 2017

The conference archive will be made available in the next couple of days. Save the date – 16.-18.5.2017 🙂
PS: Everything is a freaking DNS problem!

@dnsmichi @bortzmeyer @jpmens I`m actually writing a book on the topic pic.twitter.com/uRhqhNV1J2

— Kris Buytaert (@KrisBuytaert) April 28, 2016

Weekly Snap: Puppet Camp CfP, PHP SPL & OSMC

weekly snap23 – 27 June ended the month with tips for PHP developers, sys admins and business travellers, while shining the spotlight on our upcoming events.
At 155 days, Eva started her countdown to the Open Source Monitoring Conference with Luca Deri’s talk on “Monitoring Network Traffic Using Ntopng”, and Bernd followed with his OSMC reflections in suit.
Eva went on to open the Puppet Camp Call for Papers in full song and dance, as Christian reminded readers to join the Foreman / OpenNebula webinar.
Sebastian then explained how to replicate ZFS file systems with zrep, and Eric began a new blog series on PHP’s SPL with an example of ‘peek ahead during iteration’.
To end the week, Tobias shared his flight-booking tips for business travellers.

ZFS Replikation mit zrep

Das Dateisystem ZFS wurde ursprünglich von der Firma „Sun Microsystems“ entwickelt, die dann später bekanntermaßen von Oracle gekauft wurde. Das sind jetzt keine wirklichen Neuigkeiten und ZFS ist auch nicht neu, aber immer noch in seinen Bereichen das Maß der Dinge. Auf Linux muss man allerdings wegen Lizenzschwierigkeiten von Haus aus darauf verzichten und sich mit dem FUSE Modul oder dem zfsonlinux Kernel Modul Abhilfe schaffen. Für Linux steht ja schon seit langem BTRFS in den Startlöchern, was aber bis heute noch nicht als stable markiert ist.
ZFS ist ein Copy on Write Filesystem, das durch ein reiches Feature Set glänzen kann. Unter anderem unterstützt es Snapshots und kann diese Snapshots inkrementell versenden, um einen Datenzustand als Backup oder für höhere Verfügbarkeit auf einen weiteren Server vorhalten zu können. Das ganze ist denkbar einfach:
zfs snapshot tank/myzfs@1hourago
zfs snapshot tank/myzfs@now
zfs send -I tank/myzfs@1hourago tank/myzfs@now | ssh server2.domain zfs receive tank/myzfsbackup
Die drei Befehle erzeugen zwei Snapshots die dann dann mit „zfs send“ inkrementell von „1hourago“ bis „now“ an den „server2“ gesendet und dort empfangen werden. Die Schwierigkeit besteht jetzt darin, Snapshots auch wieder zu löschen und dafür zu sorgen, dass die Snapshots aufeinander aufbauen.
Hierfür gibt es ein KSH Script mit dem Namen zrep. Zrep sorgt sich genau darum und kann noch viel mehr. Neben dem initialen synchronisieren und dem Handling der Snapshots kann mit zrep auch auf den zweiten Server im Fehlerfall geschwenkt werden. Während des Schwenks werden die Filesysteme auf beiden Seiten readonly gesetzt, der letzte Zustand gesynced und anschließend läuft die Replikation in die andere Richtung weiter.
Mehr Informationen zu zrep findet man auf der Website zu dem Projekt.

Sebastian Saemann
Sebastian Saemann
CEO Managed Services

Sebastian kam von einem großen deutschen Hostingprovider zu NETWAYS, weil ihm dort zu langweilig war. Bei uns kann er sich nun besser verwirklichen, denn er leitet das Managed Services Team. Wenn er nicht gerade Cloud-Komponenten patched, versucht er mit seinem Motorrad einen neuen Rundenrekord aufzustellen.