ZFS
ZFS
Tips
- zfsonlinux
- zfsonlinux/zfs
- open-zfs
- Archlinux ZFS
- Archlinux ZFS/Virtual disks
- ZFS Administration
- ZFS Tutorial - 2016
- ZFS Resources
- Oracle® Solaris Administration: ZFS File Systems - 2012HTML
- Encryption
- 数据完整性
- 数据完整性是 ZFS 的主要特性
- 256 位的校验和位于元数据中,与数据相隔离
- Copy on Write
- 数据快照
- Pooled Data Storage
- ZFS 会将存储设备的可用空间作为一个资源池, zpool
- 会用于优化性能和冗余
- RAIDZ
- RAIDZ1 - RAID-5
- RAIDZ2 - RAID-6
- RAIDZ3 用的相对较少, 多一个冗余
- SSD 混合存储池
- 容量
- ZFS 是 128 位的文件系统, 可存储 256 ZB
- 数据清洗
- ZFS 可对存储池里的数据进行完整性校验,可修改其中的数据错误.
- 可使用 ZSF 指令来管理文件系统
- 数据去重
- 加密
- ARC - Adaptive Replacement Cache.
- faq
- 选择创建 pool 的名字
- 开发,测试 /dev/hdX,/dev/sdX
- < 10 /dev/disk/by-id
10 /dev/disk/by-path
10 最好 /dev/disk/by-vdev
- 选择创建 pool 的名字
- zpool.8
- zfs.8
- OpenZFS novel algorithms: snapshots, space allocation, RAID-Z - Matt Ahrens
- http://www.zfsbuild.com/2010/05/26/zfs-raid-levels/
- ZFS Raidz Performance, Capacity and Integrity
- https://forum.proxmox.com/threads/zfs-with-ssds-am-i-asking-for-a-headache-in-the-near-future.25967/
NOTES
- zpool
- 存储池
- 一组虚拟设备的合集
- 存储池
- vdev - Virtual Device - 虚拟设备
- disk
- file
- mirror
- raidz
- raidz 等同于 raidz1
- raidz1
- raidz2
- raidz3
- spare
- log
- cache
- vdev 状态
- DEGRADED
- FAULTED
- OFFLINE
- ONLINE
- REMOVED
- UNAVAIL
- 主要的守护进程
- zfs-import
zpool import
- 导入 pool
- zfs-mount
zfs mount -a
/zfs umount -a
- 自动挂载目录, 挂载目录和是否挂载由 mountpoint 和 canmount 控制
- zfs-share
zfs share -a
/zfs unshare -a
- 控制 iSCSI, NFS 或 CIFS 等网络共享
- zfs-zed
- ZFS Event Daemon
- 监控 zfs 事件, 当有 zevent 时间触发时, 会执行相应类型的脚本
- zfs-import
A raidz group with N disks of size X with P parity disks can hold approximately (N-P)*X bytes and can withstand P device(s) failing before data integrity is compromised. The minimum number of devices in a raidz group is one more than the number of parity disks. The recommended number is between 3 and 9 to help increase performance.
数据冗余
Stripped
- 无冗余
RAIDZ1
- 等同于 RAID 5
- 最大的磁盘空间
- 当磁盘读写块大于 128K 时性能较好
- 应该使用 2n+1 个磁盘
RAIDZ2
- 等同于 RAID 6
- 更好的容错
- 比 RAIDZ1 更好的 MTTDL(mean time to data loss)
- 应该使用 2n+2 个磁盘
RAIDZ3
- 应该使用 2n+3 个磁盘
镜像
- 等同于 RAID 1
- 使用更多的磁盘空间,但处理小数据的读写性能会较好.
- 为了追求更好的性能可基于 RAIDZ 实现镜像,特别是针对交大的,不可缓存的随机读.
每个 vdev 的磁盘不应该超过 12 个.建议每个 vdev 为 3-9 个磁盘.
一个或多个磁盘组成 vdev
vdev 创建后不能修改
一个或多个 vdev 组成 zpool
磁盘损坏不会导致数据丢失
vdev 损坏导致 zpool 不可使用
添加到 zpool 后的 vdev 不能被删除
ZIL(ZFS intent log) 损坏会导致数据丢失
L1ARC 是存储于 RAM 的读缓存,不应该超过 7/8 总 RAM
L2ARC 是存储于磁盘的读缓存
ZIL he L2ARC 存储于 SSD 但不应该存储于同一个 SSD
ZIL 主要用于同步写,大多数情况下不需要
L2ARC 大多数情况下不会提升太多的性能
增加 RAM 是提升性能的最好方式
https://github.com/zfsonlinux/zfs/blob/master/module/zfs/dmu.c This statistic shows ZFS DMU (Data Management Unit) operations/sec. https://docs.oracle.com/cd/E27998_01/html/E48490/analytics__statistics__disk_zfs_dmu_operations.html
ARC buffer data (ABD). https://github.com/zfsonlinux/zfs/blob/master/module/zfs/abd.c
dnode dnode is a data structure which represents an object. An object can be a ZPL file or directory, a ZVOL volume, or several other types of internal metadata http://open-zfs.org/wiki/Documentation/DnodeSync
硬件
Tutor
准备工作
zpool
zfs
share
管理运维
ZFS vs 硬件 RAID
ZFS 有校验和,和可避免位翻转等问题,而 RAID 主要用于避免整个磁盘的损坏
ZFS 只需要 HBAs (host bus adapter ) 而不需要 RAID 控制器
最多只需要 Z2, Z3 很少使用,并且可能会有问题,有其他的办法来避免可能的错误
ZFS 并不是 RAID, 而是一个软件,一个文件系统
ZFS 重建比 RAID 更快,例如 1TB 的云盘,实际数据只有 100MB, 那么 ZFS 只需要 100MB 的 IO, 而 RAID 需要 1TB 的 IO.
scrub 是用来保证数据安全的,而不是保证磁盘健康的.不是自动的,需要定时调度.
"PFA"s, as in Pre-Failure Alerts
加密
https://blog.heckel.xyz/2017/01/08/zfs-encryption-openzfs-zfs-on-linux/ https://www.rolando.cl/blog/2017/06/13/playing-with-zfs-encryption/ https://news.ycombinator.com/item?id=14591452
参考
- ZFS RAIDZ stripe width, or: How I Learned to Stop Worrying and Love RAIDZ
- [Getting the Most out of ZFS Pools](Getting the Most out of ZFS Pools)
- A Closer Look at ZFS, Vdevs and Performance
- FreeBSD ZFS Tuning Guide
- ZFS Administration Guide
- Becoming a ZFS Ninja (video)
- Slideshow explaining VDev, zpool, ZIL and L2ARC and other newbie mistakes!
- A Crash Course on ZFS
- ZFS: The Last Word in File Systems - Part 1 (video)
- ZFS Raidz Performance, Capacity and Integrity
- The 'Hidden' Cost of Using ZFS for Your Home NAS
SSD
- https://linuxhint.com/configuring-zfs-cache/
- https://www.reddit.com/r/zfs/comments/7bd797/ssd_caching/
- SLOG is a write cache. This is the one you'd want to mirror and you'd also want to use an SSD that can finish in flight writes in the case of a power outage
- Something with a battery or capacitor