ZFS

This Forum is for Question, Comment, Request & all things conserning Linux. All Hail Mighty Tux

Moderator: [PX]Kal Bob

Post Reply
User avatar
THE JEW (RaVeN)
Posts: 12499
Joined: Sun Mar 23, 2003 2:52 pm
Location: Bethlehem ;)
Contact:

ZFS

Post by THE JEW (RaVeN) »

Best practices:
http://www.solarisinternals.com/wiki/in ... iderations



Optimum disk number:

Getting the most out of a ZFS pool takes a little bit of math and some thought about how you want your system to work. There is a central trade-off between redundancy, performance, and capacity. Choose any 2. For ultimate performance and capacity, there is no beating a striped array. For redundancy and performance, mirror... etc. RAID 5 and 6 strike a balance. Even more so, RAID 5+0 or 6+0 (striped arrays of RAID 5s or 6s). If you have a huge disk array using FreeNAS and ZFS there are many opportunities for optimizing your configuration. But, to do it requires a trick.

First an example of deciding how to make a configuration:

Let's assume that you have a 96 drive disk array (big, I know, but bare with me)
I can tell you now that you DO NOT want a 96 drive RAID-6, or even a 94 drive RAID-6 with 2 spares. Not only is that an unwieldy Z-pool, ZFS doesn't like it either. That document says that less than 40 devices is recommended, but less than 12 is preferred. Also, as a side benefit, if you want to add devices to the pool later, expanding the capacity, you can, but only in the same sized chunks that the stripe already uses. In the same example, if you built up your disk array using 12 device JBODs (Just a Bunch Of Disk), and were using a 12 device pool then you can add capacity one JBOD at a time.

Moving on to the tradeoffs... I've made a spreadsheet that helps you calculate these numbers for an arbitrary configuration, but for the above example:

If each pool contains less than or equal to 5 disks, I'll assume RAID-5, unless it's 2 disks which will be mirrored. Above 5 disks, to 12, I assume RAID-6. My design criteria is to have at least 1 hot-spare.

The '#' symbol is the number of disks in the pool, lost means lost capacity (due to parity or spares), read and write are the multiplier of a single disk speed, assuming that the disk is the bottleneck.

Code:
# Spares Pairity Lost Read Write Raid level
1 0 0.00 0.00% 96 96 Striping
2 0 48.00 50.00% 96 1 Mirroring
3 0 32.00 33.33% 64 64 Raid-5 (Z)
4 0 24.00 25.00% 72 72 Raid-5 (Z)
5 1 38.00 40.63% 57 57 Raid-6 (Z2)
6 0 32.00 33.33% 64 64 Raid-6 (Z2)
7 5 26.00 32.29% 65 65 Raid-6 (Z2)
8 0 24.00 25.00% 72 72 Raid-6 (Z2)
9 6 20.00 27.08% 70 70 Raid-6 (Z2)
10 6 18.00 25.00% 72 72 Raid-6 (Z2)
11 8 16.00 25.00% 72 72 Raid-6 (Z2)
12 0 16.00 16.67% 80 80 Raid-6 (Z2)
Now, in convenient graph form:


I decided to use 5 disk pools. This was because it was the only option with a single spare disk. I ran the math out until the next time there was a single spare, and it didn't occur until I had pools of 19 disks each, which is too much for me. I will admit that I used RAID-5 rather than RAID-6 because it's a development machine.

Now the question: "How do I make FreeNAS build a configuration like this?" It's not available in the web interface, but you can make it work. The trick is using the command line zpool command. First, you need a list of disk devices. I don't remember how I did this in FreeNAS, but I'll update this when I remember. Or, someone can reply with the answer. Once you have a list of devices, paste it into a text file. Collect the device names for each disk into a single line for each pool. Do this for every pool that you want. Leave the spare devices on a separate line. Like this:

zpool create data \
raidz c1t5000C50025F5D3B7d0 c1t5000C50025F6448Fd0 c1t5000C50025FCD6C7d0 c1t5000C50025FD2D3Fd0 c1t5000C50025FD5A0Fd0 \
raidz c1t5000C50025FD9D9Fd0 c1t5000C50025FD93E3d0 c1t5000C50025FD669Fd0 c1t5000C50025FDACFBd0 c1t5000C50025FDBC27d0 \
raidz c1t5000C50025FDC39Bd0 c1t5000C50025FDC393d0 c1t5000C50025FDDD93d0 c1t5000C50025FDE9FFd0 c1t5000C50025FDF6C7d0 \
raidz c1t5000C50025FDFE4Bd0 c1t5000C50025FE1BB3d0 c1t5000C50025FE2C93d0 c1t5000C50025FE3D6Bd0 c1t5000C50025FE012Fd0 \
raidz c1t5000C50025FE174Fd0 c1t5000C50025FE226Fd0 c1t5000C50025FE446Bd0 c1t5000C50025FE494Bd0 c1t5000C50025FE2867d0 \
raidz c1t5000C50025FE5503d0 c1t5000C50025FED877d0 c1t5000C50025FF90FBd0 c1t5000C50025FFAC3Fd0 c1t5000C50025FFAF83d0 \
raidz c1t5000C50025FFB7C7d0 c1t5000C50025FFB027d0 c1t5000C50025FFB99Fd0 c1t5000C50025FFB917d0 c1t5000C50025FFC9CFd0 \
raidz c1t5000C50025FFD1DBd0 c1t5000C50025FFD2AFd0 c1t5000C50025FFD79Bd0 c1t5000C50025FFD787d0 c1t5000C50025FFE13Bd0 \
raidz c1t5000C50025FFE88Bd0 c1t5000C50025FFF55Fd0 c1t5000C5002600AFE7d0 c1t5000C5002600B7A7d0 c1t5000C5002600B587d0 \
raidz c1t5000C5002600BADBd0 c1t5000C5002600BE13d0 c1t5000C5002600C1E7d0 c1t5000C5002600C8A3d0 c1t5000C5002600CB47d0 \
raidz c1t5000C5002600CF2Bd0 c1t5000C5002600DDF7d0 c1t5000C5002600E62Fd0 c1t5000C5002600E483d0 c1t5000C5002600EDABd0 \
raidz c1t5000C5002600F02Bd0 c1t5000C5002600F027d0 c1t5000C5002600F33Bd0 c1t5000C5002600F96Bd0 c1t5000C5002600FA27d0 \
raidz c1t5000C5002601A47Bd0 c1t5000C5002601A237d0 c1t5000C5002601D96Fd0 c1t5000C5002601D197d0 c1t5000C5002601DF77d0 \
raidz c1t5000C5002602E77Fd0 c1t5000C5002604EF4Bd0 c1t5000C5002604F19Fd0 c1t5000C5002604F313d0 c1t5000C50026014DA7d0 \
raidz c1t5000C50026016A87d0 c1t5000C50026016AF7d0 c1t5000C50026016BEBd0 c1t5000C50026016C03d0 c1t5000C50026016CD3d0 \
raidz c1t5000C50026017A5Bd0 c1t5000C50026017CFBd0 c1t5000C50026018D6Bd0 c1t5000C50026018D97d0 c1t5000C50026019D9Bd0 \
raidz c1t5000C50026033BE7d0 c1t5000C50026050EBFd0 c1t5000C500260103A7d0 c1t5000C500260112FBd0 c1t5000C500260113DFd0 \
raidz c1t5000C500260135CBd0 c1t5000C500260315B3d0 c1t5000C5002601043Bd0 c1t5000C5002603314Fd0 c1t5000C5002603335Fd0 \
raidz c1t5000C50026033293d0 c1t5000C50026013853d0 c1t5000C50026017323d0 c1t5000C50026017623d0 c1t5000C50026052597d0 \
spare c1t5000C50026016737d0

Add "raidz" before each line, '\<CR>', where <CR> is a actual carriage return, at the end of each line, and "zpool create data \<CR>" at the top of the document. Finally, add "spare" to the line with your spare disks.

Copy and paste this into the command line as root. This will instruct ZFS to create your Z-pool as a stripe of many RAID'd volumes.

Now, the trick. We need to "export" the pool. This means to essentially take it out of the OS. This may seem counter intuitive, but do it anyway.

"zpool export data"

Now, if you run "zpool status" you shouldn't see any Z-pools.

In the web interface, go to Storage->Volumes->View all Volumes
Click on the "Auto import all volumes"
In a few minutes your carefully crafted ZFS pool should appear!

Idea credit: http://blogs.oracle.com/roch/entry/when_to_and_not_to

http://forums.freenas.org/threads/getti ... -pools.16/


RAIDZ, RAIDZ2, and RAIDZ3 have the best performance when there is a power of two number of data drives. In keeping the arrays under 12 drives, you end up with 2, 4 or 8 data drives. Adding the parity drives to that you get:

RAIDZ 3, 5, or 9 drives
RAIDZ2 4, 6, or 10 drives
RAIDZ3 5, 7, 11 drives

http://forums.freenas.org/threads/getti ... 6/#post-52
******* /=========\Image
****(_]/_____________\[_)
***** /(__)==JEW==(__)\
***** |=o__________o=|
***** |_|====---====|_|
Image
¨˜”°º•[K]•º°”˜¨
User avatar
THE JEW (RaVeN)
Posts: 12499
Joined: Sun Mar 23, 2003 2:52 pm
Location: Bethlehem ;)
Contact:

Re: ZFS

Post by THE JEW (RaVeN) »

Recommended hardware:

So you want more SATA ports to connect disks to and feed it to ZFS. What controller do you need, what combinations work? This thread should shed some light on this.


Motherboard onboard SATA
Modern motherboards have onboard SATA ports. These are supplied by the chipset and should be regarded as the best possible SATA ports when doing software RAID like with ZFS.

You may want to enter your system BIOS and set the onboard ports to AHCI mode. Other options would be IDE/Legacy mode and RAID mode. Avoid RAID mode at all costs. IDE mode would also work, but would lack SATA features as hot-plug, NCQ (Native Command Queueing) and would use the older ata disk (ad) driver in FreeBSD, not the newer ahci driver which can yield performance benefits on HDDs but especially SSDs.


FakeRAID add-on PCI/PCI-express controllers
These include chipsets like Silicon Image, Promise FastTrak and JMicron. These offer RAID support via Windows-only drivers. When you boot into Linux or FreeBSD, it is seen as SATA controller instead. But there's rough edges with many of these cheap controllers:
Often you cannot turn off the RAID functionality.
You may not touch the last sector on each HDD, which is used by the controllers boot firmware which use it to 'taste' the HDDs for any existing RAID configuration. If you use the entire disk under FreeBSD and write to the last sector, this may cause problems when you reboot and the controller gives you an annoying error. The workaround to this issue is to create partitions which ensure that you never write to the last sector of the drive. Also do not use geom labels on the physical drives; only GPT labels.
BIOS issues may cause boot failures, especially if you mix several controllers. I don't have much information about this issue. Try different PCI-express slots.
They are often bandwidth-limited. PCI is very bad for performance and PCI-express x1 generation 1 is only 250MB/s full-duplex; with just two HDDs you could be reaching this limit in sequential workloads.
Under Windows, the drivers would quickly detach disks and degrade/fail/split the array whenever a disk misbehaves or has a hickup; not that reliable at all!


Hardware RAID PCI/PCI-express controllers
Hardware RAID means ZFS cannot access the redundant information and has no knowledge about how the data is organised. The result: about half the features that make ZFS so cool would be vaporized if you opt for Hardware RAID. No more self-healing, useless copies=2 option and possibly unsafe writes if the Hardware RAID doesn't have a BBU and properly designed firmware that never exposes the disks to a condition in which a power failure at that moment would cause corruption. As far as ZFS goes, you have a single-disk RAID0 array.

Now you could actually make one array for each disk in the controller's RAID BIOS setup. So 8 arrays for 8 disks we have. Now we give them to ZFS. Happy now? Well not quite, whenever your disks misbehave, the RAID controller may still disconnect/detach/fail those disks and the entire array; thus disks would start popping 'UNAVAIL(able)' and that's not quite as elegant as ZFS likes to do it. ;-)

So avoid Hardware RAID - PLEASE! ZFS does RAID so much better than any Hardware RAID theoretically could ever do. The combination of filesystem and RAID-engine in one package yields emerging properties unavailable when these packages are separated. Variable stripe sizes and RAID5 write hole, for one. Let ZFS do its thing. That's what it's famous for.


non-RAID PCI-express x8 SAS HBA
Now these are the ones to buy. They are non-RAID controllers (or can turn off RAID functionality) and behave as normal SATA controllers. This is excellent for FreeBSD + ZFS or any software RAID.

LSI 1068E
I can highly recommend this LSI chip; it works well under virtually all OS (Windows, Linux, FreeBSD, OpenSolaris). No bandwidth issues, quite affordable too. The only issue i'm aware of is I/O failures when quering SMART values rapidly in succession. These were reported by users running Linux. I've not experienced any malfunctioning behavior on my two SuperMicro controllers with this chip.

SuperMicro USAS-L8i (2x Mini-SAS -> 8x SATA/300)
Intel SASUC8i



LSI SAS2008
This is the successor of the 1068E and features 2x Mini-SAS -> 8x SATA/600 ports. Thus this gets a boost from SAS/SATA 3Gbps to SAS/SATA 6Gbps. Support for this new chip has been added only recently, using a system image of at least 8.2-001 should be enough to get this controller working; though the driver is still development and has some outstanding issues, none of them extremely serious.

SuperMicro USAS2-L8e (2x Mini-SAS -> 8x SATA/600)

http://zfsguru.com/forum/buildingyourownzfsserver/21


Flashing 1068E to IT mode from IR mode:
http://forums.freebsd.org/showthread.php?t=25194
http://www.servethehome.com/flashing-in ... are-guide/
******* /=========\Image
****(_]/_____________\[_)
***** /(__)==JEW==(__)\
***** |=o__________o=|
***** |_|====---====|_|
Image
¨˜”°º•[K]•º°”˜¨
User avatar
THE JEW (RaVeN)
Posts: 12499
Joined: Sun Mar 23, 2003 2:52 pm
Location: Bethlehem ;)
Contact:

Re: ZFS

Post by THE JEW (RaVeN) »

Ubuntu & ZFS:

This is a quick guide to get zfs up and running on Ubuntu server, it would also work on Ubuntu desktop.

I have not not tried running zfs on Ubuntu 12.10, as it have no reason to upgrade by n40l from 12.04 LTS.

From Ubuntu server I needed to install python-software-properties, so that i could run add-apt-repository ( You don't need to complete this first step from Ubuntu desktop or Linux mint )

$ sudo apt-get install python-software-properties
Then install the zfs-native ppa, so that you can download and compile native zfs goodness

$ sudo add-apt-repository ppa:zfs-native/stable
Update your repo list, so it includes the new zfs-native ppa

$ sudo apt-get update
Make sure the the zfs packages in the repo

$ apt-cache search zfs
Install, Note: this might take some time as it compiles the kernel module for your kernel

$ sudo apt-get install ubuntu-zfs
Run the zfs commands to make sure it works

$ sudo zfs
$ sudo zpool
Create a pool

$ sudo zpool create data /dev/sda
Check the mounts

$ df -h -F zfs
Filesystem Size Used Avail Use% Mounted on
data 229G 0 229G 0% /data
This will also work on Linux mint.

http://dansysadm.com/blog/installing_zf ... _n40l.html

https://launchpad.net/~zfs-native/+archive/stable

https://wiki.ubuntu.com/ZFS



ZFS for more distros:
http://zfsonlinux.org/

Install Ubuntu on ZFS:
https://github.com/zfsonlinux/pkg-zfs/w ... Filesystem
Last edited by THE JEW (RaVeN) on Wed Jun 19, 2013 3:21 pm, edited 1 time in total.
******* /=========\Image
****(_]/_____________\[_)
***** /(__)==JEW==(__)\
***** |=o__________o=|
***** |_|====---====|_|
Image
¨˜”°º•[K]•º°”˜¨
User avatar
THE JEW (RaVeN)
Posts: 12499
Joined: Sun Mar 23, 2003 2:52 pm
Location: Bethlehem ;)
Contact:

Re: ZFS

Post by THE JEW (RaVeN) »

32bit system and FreeNAS:

Alright folks, so I was toying around with my FreeNAS 8.0.2 box and I encountered a problem where when I would copy data via samba to the ZFS share, the machine would kernel panic after about 30 gigabytes. This is my story.

The idea behind this thread is that FreeNAS (and other ZFS vendors I believe) recommend 4GB of memory and x86-64 processors when using ZFS. Well the thing is if you're like me, you just want a NAS to fill a few, fairly basic needs. A full on 64bit processor and 4GB of memory starts to sound like an actual system rather than an appliance. Here's my set up.

Pentium 4 3.2GHz
1.5GB DDR2 (hodge podge of different speeds. 2x 512MB and 2x 256MB)
3x 500GB SATA drives in RAID-Z
2x 320GB SATA drives mirrored
FreeNAS 8.0.2-RELEASE


The situation

So what happened was after creating my RAID-Z and samba share, I would start copying my data over to FreeNAS from my backup drive. After about 30GB had transferred, I would get the kernel panic regarding vm.kmem_size. There is also a message that pops up frequently on FreeNAS boxes complaining about vm.kmem_size and vm.kmem_size_max. I will try to dig up the exact kernel panic message when I get home.


The research

So like any of us would do, I immediately hit up the University of Google and come across a number of posts talking about modifying /boot/loader.conf. The solutions said that adding the following lines would clear up problems.

Code:
vm.kmem_size="512M"
vm.kmem_size_max="512M"


I also came across the ZFS Tuning Guide, which I believe someone in the LKF pointed me to a number of months ago as well. The Tuning Guide has a lot of good information in it.


The solution

Adding the two kmem_size options to loader.conf did not fix the problem. I did some more reading in the Tuning Guide and came across this piece.

Quote:
Some workloads need greatly reduced ARC size and the size of VDEV cache. ZFS manages the ARC through a multi-threaded process. If it requires more memory for ARC ZFS will allocate it. Previously it exceeded arc_max (vfs.zfs.arc_max) from time to time, but with 7.3 and 8-stable as of mid-January 2010 this is not the case anymore. On memory constrained systems it is safer to use an arbitrarily low arc_max. For example it is possible to set vm.kmem_size and vm.kmem_size_max to 512M, vfs.zfs.arc_max to 160M, keeping vfs.zfs.vdev.cache.size to half its default size of 10 Megs (setting it to 5 Megs can even achieve better stability, but this depends upon your workload).

There is one example (CySchubert) of ZFS running nicely on a laptop with 768 Megs of physical RAM with the following settings in /boot/loader.conf:

vm.kmem_size="330M"
vm.kmem_size_max="330M"
vfs.zfs.arc_max="40M"
vfs.zfs.vdev.cache.size="5M"


So it struck me that I might need to put in the two vfs.zfs pieces in to loader.conf as well. Here's what I came up with.

Code:
vm.kmem_size="512M"
vm.kmem_size_max="512M"
vfs.zfs.arc_max="60M"
vfs.zfs.vdev.cache.size="10M"


Given everything I tried, I wouldn't mind anyone saying I just picked those numbers out of thin air. That's pretty much what I did. I saw the example configuration was based off of 768MB of memory, I have 1.5GB. So I'm guessing my vm.kmem_size and kmem_size_max can be larger. But likely not larger than 512MB since according to the Tuning Guide, that could require a kernel rebuild to actually work. So 512MB was the safe maximum.

vfs.zfs.arc_max and vdev.cache.size I increased slightly based off of the increase to kmem_size. I'm not sure if that was the correct way to do things or not, but that's what I went with. After this change I was able to copy over ~35GB of stuff, followed by another roughly 75GB of stuff without issue.

Full disclosure, I do not know what arc_max or vdev.cache.size affects, and have minimal knowledge of what the kmem_size features are for. If anyone can and would like to expand upon what I've written here, I think that would be awesome as the point of this is to help other people who might be in the same situation I was.

Edit:
I found out that with FreeNAS 8, the 32bit kernel is made to handle a kmem_size_max of 512M. If you want anything larger you'll have to go to 64bit.

http://arstechnica.com/civis/viewtopic. ... &t=1159726

Things to watch for on 32bit Ubuntu:
http://comments.gmane.org/gmane.linux.f ... .user/7685
******* /=========\Image
****(_]/_____________\[_)
***** /(__)==JEW==(__)\
***** |=o__________o=|
***** |_|====---====|_|
Image
¨˜”°º•[K]•º°”˜¨
User avatar
THE JEW (RaVeN)
Posts: 12499
Joined: Sun Mar 23, 2003 2:52 pm
Location: Bethlehem ;)
Contact:

Re: ZFS

Post by THE JEW (RaVeN) »

Why it's best to flash your LSI hardware raid card to IT mode:

forums.freebsd.org/showthread.php?t=25194
******* /=========\Image
****(_]/_____________\[_)
***** /(__)==JEW==(__)\
***** |=o__________o=|
***** |_|====---====|_|
Image
¨˜”°º•[K]•º°”˜¨
User avatar
THE JEW (RaVeN)
Posts: 12499
Joined: Sun Mar 23, 2003 2:52 pm
Location: Bethlehem ;)
Contact:

Re: ZFS

Post by THE JEW (RaVeN) »

OpenZFS hopes to unify all the different streams and bring in new features

open-zfs.org/wiki/Main_Page
******* /=========\Image
****(_]/_____________\[_)
***** /(__)==JEW==(__)\
***** |=o__________o=|
***** |_|====---====|_|
Image
¨˜”°º•[K]•º°”˜¨
User avatar
THE JEW (RaVeN)
Posts: 12499
Joined: Sun Mar 23, 2003 2:52 pm
Location: Bethlehem ;)
Contact:

Re: ZFS

Post by THE JEW (RaVeN) »

Good guide on ZFS on Linux

http://arstechnica.com/information-tech ... -on-linux/

I like how he covers naming of drives.
******* /=========\Image
****(_]/_____________\[_)
***** /(__)==JEW==(__)\
***** |=o__________o=|
***** |_|====---====|_|
Image
¨˜”°º•[K]•º°”˜¨
Post Reply

Return to “Linux Forum”