Задача: подготовить пул ZFS для размещения на нем ресурсов Samba-сервера.
Для начала создаем раздел GPT:
gpart create -s gpt /dev/ada1 #создаем раздел GPT
Далее создаем zfs-раздел с меткой disk1, используя весь диск:
gpart add -t freebsd-zfs -l disk1 /dev/ada1
ls /dev/gpt
Чтобы создать партицию определенного размера (в данном случае 2Тб), причем указываем метку после параметра -l:
gpart add -t freebsd-zfs -l diskmirror1 -s 2T /dev/ada1
Создаем зеркало на ZFS:
zpool create -m /files/mirror zfsdatamirror /dev/gpt/diskmirror1
здесь /files/mirror - точка монтирования пула
zpool attach zfsdatamirror /dev/gpt/diskmirror1 /dev/gpt/diskmirror2
Cделаем теперь «страйп», если нужно:
zpool create –m /files/stripe zfsdatastripe /dev/gpt/diskstripe1 /dev/gpt/diskstripe2
Теперь сделаем файловую систему на страйпе (аналогично на зеркале) с именем Designers:
zfs create zfsdatastripe/Designers
Далее некоторый свод команд для пула с именем zfspool:
zfs set mountpoint=/files zfspool #создаем точку монтирования ZFS zfs set aclmode=passthrough zfspool #ставим 'сквозной' режим работы ACL zfs set aclinherit=passthrough zfspool #устанавливаем 'сквозное' наследование ACL zfs set atime=off zfspool #отключаем метку времени доступа к файлам zfs set exec=off zfspool #отключаем запуск программ на разделе zfs set setuid=off zfspool #отключаем бит выполнения от другого пользователя zfs set compression=gzip zfspool #ставим сжатие данных на разделе zfs set dedup=on zfspool #ставим дедубликацию данных(сильно снижает дисковую производительность)
Включаем zfs в rc.conf, если еще не сделано:
echo 'zfs_enable="YES"' >> /mnt/etc/rc.conf
В /boot/loader.conf прописываем:
zfs_load="YES"
Если после перезагрузки пул не примонтировался по каким-либо причинам:
zpool import -R /mnt_new -f zfspool
В сети натолкнулся на статью, к сожалению не помню ссылку на автора:
Система
Samba
В smb.conf:
[global] socket options = TCP_NODELAY SO_SNDBUF=131072 SO_RCVBUF=131072 use sendfile = no min receivefile size = 16384 aio read size = 16384 aio write size = 16384 aio write behind = yes
ZFS пулы
pool: backups
state: ONLINE scrub: none requested config:
NAME STATE READ WRITE CKSUM backups ONLINE 0 0 0 ada2 ONLINE 0 0 0
errors: No known data errors
pool: data
state: ONLINE scrub: none requested config:
NAME STATE READ WRITE CKSUM data ONLINE 0 0 0 ada1 ONLINE 0 0 0
errors: No known data errors
Тюнинг ZFS
Your tunings here are «wild» (meaning all over the place). Your use of vfs.zfs.txg.synctime=«1» is probably hurting you quite badly, in addition to your choice to enable prefetching (every ZFS FreeBSD system I've used has benefit tremendously from having prefetching disabled, even on systems with 8GB RAM and more). You do not need to specify vm.kmem_size_max, so please remove that. Keeping vm.kmem_size is fine. Also get rid of your vdev tunings, I'm not sure why you have those.
My relevant /boot/loader.conf tunings for 8.2-RELEASE (note to readers: the version of FreeBSD you're running, and build date, matters greatly here so do not just blindly apply these without thinking first):
# We use Samba built with AIO support; we need this module! aio_load="yes"
# Increase vm.kmem_size to allow for ZFS ARC to utilise more memory. vm.kmem_size="8192M" vfs.zfs.arc_max="6144M"
# Disable ZFS prefetching # http://southbrain.com/south/2008/04/the-nightmare-comes-slowly-zfs.html # Increases overall speed of ZFS, but when disk flushing/writes occur, # system is less responsive (due to extreme disk I/O). # NOTE: Systems with 8GB of RAM or more have prefetch enabled by # default. vfs.zfs.prefetch_disable="1"
# Decrease ZFS txg timeout value from 30 (default) to 5 seconds. This # should increase throughput and decrease the "bursty" stalls that # happen during immense I/O with ZFS. # http://lists.freebsd.org/pipermail/freebsd-fs/2009-December/007343.html # http://lists.freebsd.org/pipermail/freebsd-fs/2009-December/007355.html vfs.zfs.txg.timeout="5"
sysctl tunings
Please note that the below kern.maxvnodes tuning is based on my system usage, and yours may vary, so you can remove or comment out this option if you wish. The same goes for vfs.ufs.dirhash_maxmem. As for vfs.zfs.txg.write_limit_override, I strongly suggest you keep this commented out for starters; it effectively «rate limits» ZFS I/O, and this smooths out overall performance (otherwise I was seeing what appeared to be incredible network transfer speed, then the system would churn hard for quite some time on physical I/O, then fast network speed, physical I/O, etc… very «bursty», which I didn't want).
# Increase send/receive buffer maximums from 256KB to 16MB. # FreeBSD 7.x and later will auto-tune the size, but only up to the max. net.inet.tcp.sendbuf_max=16777216 net.inet.tcp.recvbuf_max=16777216
# Double send/receive TCP datagram memory allocation. This defines the # amount of memory taken up by default *per socket*. net.inet.tcp.sendspace=65536 net.inet.tcp.recvspace=131072
# dirhash_maxmem defaults to 2097152 (2048KB). dirhash_mem has reached # this limit a few times, so we should increase dirhash_maxmem to # something like 16MB (16384*1024). vfs.ufs.dirhash_maxmem=16777216
# # ZFS tuning parameters # NOTE: Be sure to see /boot/loader.conf for additional tunings #
# Increase number of vnodes; we've seen vfs.numvnodes reach 115,000 # at times. Default max is a little over 200,000. Playing it safe... kern.maxvnodes=250000
# Set TXG write limit to a lower threshold. This helps "level out" # the throughput rate (see "zpool iostat"). A value of 256MB works well # for systems with 4GB of RAM, while 1GB works well for us w/ 8GB on # disks which have 64MB cache. vfs.zfs.txg.write_limit_override=1073741824
TAG: