====== zfs cheatsheet ====== ===== install zfs on centos 7.3 ===== ([[https://github.com/zfsonlinux/zfs/wiki/RHEL-%26-CentOS#kabi-tracking-kmod|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 ([[https://github.com/zfsonlinux/zfs/wiki/RHEL-%26-CentOS#kabi-tracking-kmod|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 ... Raid levels: - do not specify - none - **mirror** - RAID1 - **raidz** or **raidz1** = RAID5 - **raidz2** = RAID6 - **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 / create sub-filesystem zfs create [-o mountpoint=/path/to/mount] -o compression=lz4 // Default mount point is as a subdirectory of pool mount point. To set mount point: zfs set mountpoint=/path/to/mount / Remove filesystem zfs destroy [-f] ===== cache ===== http://louwrentius.com/zfs-on-linux-monitor-cache-hit-ratio.html ===== 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// and you should use recordsize=16k on this dataset too or switch back to innodb_file_per_table = off ===== Links ===== * [[https://wiki.freebsd.org/ZFSTuningGuide#L2ARC_discussion]] - optimization