———

 
Translations of this page:

zfs cheatsheet

install zfs on centos 7.3

(source):

1. install zfs repo:

yum install http://download.zfsonlinux.org/epel/zfs-release.el7_3.noarch.rpm

2. disable zfs and enable zfs-kmod in /etc/yum.repos.d/zfs.repo

in order to automatically import pools on CentOS run this (source):

systemctl preset zfs-import-cache zfs-import-scan zfs-mount zfs-share zfs-zed zfs.target

Create pool

zpool create -o mountpoint=/path/to/mount <name> <raid level> <dev1> <dev2> ...

Raid levels:

  1. do not specify - none
  2. mirror - RAID1
  3. raidz or raidz1 = RAID5
  4. raidz2 = RAID6
  5. raidz3 = “RAID7” or has 3 parity

example - create raid5 of 4 disks:

zpool create -o mountpoint=/storage storage raidz /dev/sdb /dev/sdc /dev/sdd /dev/sde

Create Filesystems

Create filesystem

zfs create [-o mountpoint=/path/to/mount] -o compression=lz4 <pool>/<fsname>

create sub-filesystem

zfs create [-o mountpoint=/path/to/mount] -o compression=lz4 <pool>/<fsname>/<subfsname>

Default mount point is as a subdirectory of pool mount point. To set mount point:

zfs set mountpoint=/path/to/mount <pool>/<fsname>

Remove filesystem

zfs destroy [-f] <pool><filesystem>

cache

MySQL

MySQL

This assumes lots of RAM

Tweaks for MySQL

innodb_flush_log_at_trx_commit=2
skip-innodb_doublewrite

Tweaks for ZFS

zfs set primarycache=metadata tank/db
zfs set atime=off tank/db
zfs set recordsize=16k tank/db/innodb
zfs set recordsize=128k tank/db/logs
zfs set zfs:zfs_nocacheflush = 1
zfs set sync=disabled tank/db

Note: MySQL 5.6.6 and newer (and related MariaDB / Percona forks) has innodb_file_per_table = on as default, so IBD files are not created under tank/db/innodb (defined by innodb_data_home_dir in your my.cnf), they are created under tank/db/<db_name>/ and you should use recordsize=16k on this dataset too or switch back to innodb_file_per_table = off

Links

 
lcb/storage/zfs.txt · Last modified: 05.30.2017 10:44 by npelov
 
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki