memo:test

差分

このページの2つのバージョン間の差分を表示します。

この比較画面にリンクする

両方とも前のリビジョン 前のリビジョン
次のリビジョン
前のリビジョン
memo:test [2020-12-02 17:47]
Decomo
memo:test [2020-12-09 09:21]
Decomo 削除
行 1: 行 1:
-27. ZFS Primer+====== ZFSのヤバげな機能Special Allocation ClassがFreeBSD 12.2で対応されてた ======
  
-ZFSは先進的で現代的なファイルシステムで、特に伝統的なUNIXファイルシステムでは利用できなかった機能の提供を目的に設計されました。 +OpenZFS 2.0リリースの陰でひっそりと、FreeBSD 12.2-RELEASEZFS実装Special Allocation Class(以下SACと略すことが追加されていた。
-ジナルはSunにおいてソースのオープン化意向ととも開発されたため他のオペレーティングシステムへ移植ことが可能でした。 +
-OracleによSunの買収後、ZFSのオリジナル開発者の何人か、オープンソースバージョンの継続的な共同開発を提供するために[[http://open-zfs.org/wiki/Main_Page|OpenZFS]]を創設しました。+
  
-ここZFS特徴概要を記し+時系列的はOpenZFS 2.0が2020年12月1日、FreeBSD 12.2Rが10月27日リリースなで、まったく陰ってはないんですけどね、インパクトありそうな機能割にはリリースノートに載がなく、''zpool status''たら「プールのアップグレードができるぜ!」と出たので調べてみたら追加されていたという。関連るコミットはこの辺→[[https://svnweb.freebsd.org/base?view=revision&revision=354382|Rev.354382]] [[https://svnweb.freebsd.org/base?view=revision&revision=354385|Rev.354385]] [[https://svnweb.freebsd.org/base?view=revision&revision=354941|Rev.354941]]
  
-**ZFSトランザクションを持つCopy-On-Write ([[https://en.wikipedia.org/wiki/ZFS#Copy-on-write_transactional_model|COW]])なファイルシステムす。** +Special Allocation Class自体は[[https://github.com/openzfs/zfs/releases/tag/zfs-0.8.0|ZoL 0.8.0]]で2019年5月24日リリーれ、その後、illumosへックポートを経て、めFreeBSD取り込れた模様ZFS実装が新生OpenZFSベ切り替わろうとしている、Legacy ZFSをきっちりメンテする姿勢には頭が下がります。
-各書き込み要求ついて、関係するディクブロックのコピーが作られ、そして全て変更は元ブロックではなコピー対して作用し +
-書き込み完了すると、全てのブロックポインタの指す先がそのしいコピーに変更されます。 +
-これは、ZFSは常に空き領域に書き込み、ほんどの書き込みはシーケンシャルで、そしてバージョンのファイルは新バージョンの書き込みが完全に成功す分離されないことを意味します。 +
-ZFSはディスクへの直接アクセス行い、複数の読み込み/込み要求をトラザクションにまとめます。 +
-ほとんどのファイルシスムはこれを行わず、ただディスクブロックへアクセスするのみです。 +
-完了か失敗どちらか一方定まるトランザクション、[[https://blogs.oracle.com/bonwick/raid-z|ライトホール]]は決して存在せず、そしてファイルシステムの確認ユーティリティは必要ないことを意味します。 +
-このトランザクションベースの設計により、追加のストレージ領域足されれば、それはすぐさま書き込み用に利用可能となります。 +
-データの再均衡化のために、データをコピーして既存のデータを全ての利用可能なディスクに横断的に上書きすることができます。 +
-128ビットファイルシステムなので、ファイルシステムとファイルの最大サイズは16エクサバイトです。+
  
-**ZFS自己修復ファイルシステムして設計されました。** +で、肝心のSpecial Allocation Class何かというと、I/O性能直結データを専用のvdev格納て性能改善るもののよう多少確さを欠く表現だが、階層化トレージのZFS版いえる。
-ZFSはデータを書くたびに対象のディスクブロックごとチェックサムを生成し記録しま。 +
-ZFSはデータを読むたび、対象のディスクブロックごとのチェックサムを読み込み検証ます。 +
-メディアのエラーや“ビット腐敗”はデータに変化引き起こし、そのチェックサムが一致すことはありません。 +
-ZFSがミラーないしRAIDZ構成のプール上にディスクブロックのチェックサムエラーを検出した場合、ZFSは壊れたデータを正しいデータで置き換えます。 +
-滅多に読まれないディスクブロックあることから、定期的なscrubをスケジューリングし、ZFSが全データブロックを読んでチェックサム検証と異常ブロック訂正が行えるようにすると良いでしょう +
-冗長性とデータ訂の提供のために複数のディスク要求される一方で1ディクのシステムにおいてもZFSはデタ異常検出を提供します。 +
-FreeNAS®は各ZFSプールに対し月1回のscrubを自動的にスケュールし、そ結果は[[https://www.ixsystems.com/documentation/freenas/11.3-U5/storage.html#pools|Pools]]を選択し (Settings)→Statusクリックすと表示されます。 +
-scrub結果をチェックすることは、ディスクの潜在的な問題の早期発見につながる可能性があります+
  
-伝統的なUNIXファイルシステムと違い、**ファイルシステム作成時にパーティションサイズを決める必要ありません。** +ZFSで扱うータ種類に応じてvdevをAllocation Classという概念で分類しておりOpenZFS 2.0時点では以下5種類となっているちなみAllocation Classは、元は[[blog:2020:2020-10-07|dRAID]]で導入さたもので、その後、開発コミュニティよっされ現在ったそうだ
-代わりに、vdevと呼ばれるィスクグループがZFSプールに組み込まれます。 +
-ファイルシステムは必要に応じて、プールから生成されます +
-より多くの容量が必要なった時は、同一のvdevをプールにストライピングすることができます。 +
-FreeNAS®の[[https://www.ixsystems.com/documentation/freenas/11.3-U5/storage.html#pools|Pools]]はプールの作成と拡張に使わます。 +
-プール作成後、必要応じ、プールから動的サイズのデータセットまたは固定サイズのzvolを切り出すことができます。 +
-データセットをい、格納されるデータ種類に応じたパーミッションや容量制限・圧縮ったプロパティをデータセット単位で設定し、ストレージを最適化することができます。 +
-zvolは本質的には生の仮想ブロックデバイスで、iSCSIデバイスエクステントなどのローデバイスを必要とするアプリケーションで使用されます+
  
 +^  クラス  ^  SAC  ^  用途  ^  専用vdevを割り当てた時の効果  ^
 +| Normal |  ×  | 通常のデータを扱うvdev。ミラーとかRAIDZとか。 | |
 +| Log |  ×  |ZILのレコード。いわゆるSLOG。 | 同期書き込みの高速化 |
 +| Dedup |  ○  |重複排除テーブル(DDT)のデータ | 重複排除パフォーマンスの向上とDDTのメモリ使用量の削減 |
 +| Metadata |  ○  | プールとファイルシステムのメタデータ | メタデータ操作(ファイル一覧の取得など)パフォーマンスの向上 |
 +| Small Blocks |  ○  | レコードサイズ以下のブロック | 小さなサイズの膨大なI/O性能の改善。詳細は後述 |
  
-**ZFSはリアルタイムデータ圧縮サポートします。** +表で〇付けたAllocation ClassSpecial Allocation Classている。れぞれSAC役割は名前のごとくで、専用vdev (Special vdev)割り当てるとそりに効果がありそうだとりわけSmall Blocks[[https://www.napp-it.org/doc/downloads/special-vdev.pdf|劇的な性能改善可能性]](PDF)秘めて
-ブロックディスクに書き込まれたきに圧縮が行わますが、そのデータが圧縮恩恵受けらる場合に限ます。 +
-圧縮済みブロックアクセスがあった時は、自動的に展開されます +
-圧縮ファイルレベルではなくブロックレベルで行われるため、あらゆるアプリケーションが透過的に圧縮データにアクセスします。 +
-FreeNAS®バージョン9.2.1以降で作られたZFSプールは、推奨LZ4圧縮アルゴリズム使ます+
  
-**ZFSは低コストの即時スナップショットを提供します。**対象となるのはプール、データセット、あるいはzvolです。 +ZFSのファイルI/O原則的に128KiB単位((データセットrecordsizeロパテ変更可能))で行われ、それに満ないデータは、より小なレコード使われる。この小さなレコードがI/O性能にそれなりに影響るようで、Small Blocksサイズ以下ロックの読み書きSpecial vdevにオフするようなイメージなるSpecial vdevとしてSSDを割り当てると、特性活かて膨大な小規模I/Oを捌けようになる、うわけだ
-COWのおかげで、スナップショットは最初は余分な領域を必要としません。 +
-スナップショットのサイズは時間ととも、スナッショットに含まれるファイルがデスクに書き込まれ、変更があるにつ増加します。 +
-スナップショットを使うとスナップショットを取得し時点のデータのコピーを提供することできます。 +
-通常、ファイルが削除されると対応するディスクブロック空きリストに追加されます。しかしスナップショット内にファイルが存在する場合、参照するすべてのスナップショットが削除れるまで、ファイルブロック空きリストに追加されることはありません +
-れにより、スナップショットはファイル履歴の保持、古いや削除さたファイルの復元に便利な賢い手段となり。 +
-した理由, 多くの管理者は頻繁にスナップショットを取得し一定期間保存し、そして別のシステムに保管します。 +
-このような戦略、管理者にシステムを特定の時点へールバックすること可能とします。 +
-もし破滅的なデータ消失があった場合、オフサイトのスナップショットはシステムを最後の定期スナップショット─例えばデタ消失の直前15分の時点に、システムを復元するができます +
-スナップショットはローカルに保管されすがリモートのZFSプールにレプリケートすもできます。 +
-レプリケーションではZFSはバイト単位コピーは行わず、代わりにスナップショットデータストリームへ変換ます。 +
-この設計は、受信側のZFSプール構成が同一であ必要はなく、異なるRAIDZレベルプールサイズ、あるは圧縮設定が使用可能なことを意味します+
  
 +ここで注意が必要なのは、Small Blocksの処理はファイルサイズベースではなく、あくまでブロックサイズベースで行われるということ。なので、小さなファイルの全体がSpecial vdevに格納される訳ではない((Small Blocksの閾値をレコードサイズと同値にして全データをSpecial vdevに送ることは可能))。そもそも、ZFSの書き込みは一旦メモリにキャッシュされ、トランザクショングループ(txg)にまとめられた上でレコードに書き出されるため、必ずしも小さいファイル=小さなレコードとは限らない。逆に、大きなファイルでもレコードサイズ以下の端数は必ず存在するわけで、これらのtxgでレコードサイズ未満となった分がSpecial vdev行きとなるようだ。この辺が一般的な階層化ストレージと大きく異なる部分である。
  
-**ZFS Boot Environemtはシステム更新失敗から復旧す手段を提供します。** +Small Blocks対象となブロックサイズは、レードサイズ以下2の冪を任意指定でき。128KiB以上のレコドサイズ使えるようなるlarge_blocksフィチャーと合わせて使うと、よりパフォマンスチューニングの幅が広がるだろうなおFreeBSDはードサイズ128KiB超えるデタセットからの起動にないので要注意
-FreeNAS®では、アップグレードやシステム更新、OSが存在すタセットのスナップショット自動取得されます。 +
-この保存済みBoot Environmentは自動的GRUBブトロダに追加されます +
-万が一アップグレードや設定変更失敗したら、単にシステム再起動し起動メニューから以前Boot Environmentを選択します。 +
-ユーザー必要に、例えば設定変更を行う前にSystem ➞ Bootで自身Boot Environmentを作ることもきます+
  
-**ZFSはメモリライトキャッシュとZFSインテントログ(ZIL)を提供します。** +Special Allocation Classで性能向上が見込める一方で、そ仕組Special vdevが死ぬと一発でプール全体のデータが飛ぶ恐れがある、というかメタデータという極めて重要なデータが飛ぶんだから、ほぼ確実死ぬと思われる。なので今まで以上冗長性には留意する必要がある信頼のおけるSSDで最低でもミラーリング、可能なら電源喪失保護付きSSDで3重ミラーにしいところ。
-ZILは、[[https://pthree.org/2013/04/19/zfs-administration-appendix-a-visualizing-the-zfs-intent-log/|「同期書き込」をZFSプールに書き込まれるまで一時的保持する]]ストレージ領域です +
-高速(遅延)で電源保護されたSSDをSLOG (Separate Log)デバイスとして追加すると、はるかに高い性能を得られます。 +
-これはESXi越しのNFSに不可欠、またデタベースサーバや同期書き込み依存する他のアプリケーションで強く推奨ます。 +
-SLOGの恩恵と使方の詳細は、以下のブログフォーラムの投稿をご覧ください:+
  
-  * [[http://www.freenas.org/blog/zfs-zil-and-slog-demystified/|The ZFS ZIL and SLOG Demystified]] +Special vdevの容量が一杯になった場合は、従来通り普通のvdevの方が使われるそうだ。
-  * [[https://forums.freenas.org/index.php?threads/some-insights-into-slog-zil-with-zfs-on-freenas.13633/|Some insights into SLOG/ZIL with ZFS on FreeNAS®]] +
-  * [[http://nex7.blogspot.com/2013/04/zfs-intent-log.html|ZFS Intent Log]]+
  
-SMB、AFP、iSCSIでは同期書き込みは比較的まれで、すなわち、これらプロトコルの性能改善のためのSLOG追加は特別な場合のみであると意味します。 +そのうち試してみたい。
-システムがSLOGの恩恵を受けられるかの判定のため、zilstatユーティリティをShellで実行することができます。 +
-使い方の情報は[[http://www.richardelling.com/Home/scripts-and-programs-1/zilstat|このウェブサイト]]をご覧ください。 +
- +
-現在のところZFSはSLOG用に16GiBの領域を使います。 +
-より大きなSSDを組み込んでも、余分な領域は使用されません。 +
-SLOGデバイスはプール間で共有できません。 +
-れぞれプールは別々のSLOGデバイスを要求します。 +
-帯域とスループットの制約により、SLOGデバイスはこの単一目的のためだけに使用されなければなりません。 +
-同一のSSDに他のキャッシュ機能を追加しよしてはなりません。さもなと性能を損なうことになるでしょう。 +
- +
-ミッションクリティカルなシステムでは、ミラー構成のSLOGデバイスを強く推奨します。 +
-ミラー構成のSLOGデバイスはZFSバージョン19以前のZFSプールで要求されます。 +
-ZFSプールのバージョンはShellで''zpool get version プール名''コマンドで確認します +
- +
- +
-In mission-critical systems, a mirrored SLOG device is highly recommended. Mirrored SLOG devices are required for ZFS pools at ZFS version 19 or earlier. The ZFS pool version is checked from the Shell with zpool get version poolname. A version value of - means the ZFS pool is version 5000 (also known as Feature Flags) or later. +
- +
-ZFS provides a read cache in RAM, known as the ARC, which reduces read latency. FreeNAS® adds ARC stats to top(1) and includes the arc_summary.py and arcstat.py tools for monitoring the efficiency of the ARC. If an SSD is dedicated as a cache device, it is known as an L2ARC. Additional read data is cached here, which can increase random read performance. L2ARC does not reduce the need for sufficient RAM. In fact, L2ARC needs RAM to function. If there is not enough RAM for a adequately-sized ARC, adding an L2ARC will not increase performance. Performance actually decreases in most cases, potentially causing system instability. RAM is always faster than disks, so always add as much RAM as possible before considering whether the system can benefit from an L2ARC device. +
- +
-When applications perform large amounts of random reads on a dataset small enough to fit into L2ARC, read performance can be increased by adding a dedicated cache device. SSD cache devices only help if the active data is larger than system RAM but small enough that a significant percentage fits on the SSD. As a general rule, L2ARC should not be added to a system with less than 32 GiB of RAM, and the size of an L2ARC should not exceed ten times the amount of RAM. In some cases, it may be more efficient to have two separate pools: one on SSDs for active data, and another on hard drives for rarely used content. After adding an L2ARC device, monitor its effectiveness using tools such as arcstat. To increase the size of an existing L2ARC, stripe another cache device with it. The web interface will always stripe L2ARC, not mirror it, as the contents of L2ARC are recreated at boot. Failure of an individual SSD from an L2ARC pool will not affect the integrity of the pool, but may have an impact on read performance, depending on the workload and the ratio of dataset size to cache size. Note that dedicated L2ARC devices cannot be shared between ZFS pools. +
- +
-ZFS was designed to provide redundancy while addressing some of the inherent limitations of hardware RAID such as the write-hole and corrupt data written over time before the hardware controller provides an alert. ZFS provides three levels of redundancy, known as RAIDZ, where the number after the RAIDZ indicates how many disks per vdev can be lost without losing data. ZFS also supports mirrors, with no restrictions on the number of disks in the mirror. ZFS was designed for commodity disks so no RAID controller is needed. While ZFS can also be used with a RAID controller, it is recommended that the controller be put into JBOD mode so that ZFS has full control of the disks. +
- +
-When determining the type of ZFS redundancy to use, consider whether the goal is to maximize disk space or performance: +
- +
-    RAIDZ1 maximizes disk space and generally performs well when data is written and read in large chunks (128K or more). +
-    RAIDZ2 offers better data availability and significantly better mean time to data loss (MTTDL) than RAIDZ1. +
-    A mirror consumes more disk space but generally performs better with small random reads. For better performance, a mirror is strongly favored over any RAIDZ, particularly for large, uncacheable, random read loads. +
-    Using more than 12 disks per vdev is not recommended. The recommended number of disks per vdev is between 3 and 9. With more disks, use multiple vdevs. +
-    Some older ZFS documentation recommends that a certain number of disks is needed for each type of RAIDZ in order to achieve optimal performance. On systems using LZ4 compression, which is the default for FreeNAS® 9.2.1 and higher, this is no longer true. See ZFS RAIDZ stripe width, or: How I Learned to Stop Worrying and Love RAIDZ for details. +
- +
-These resources can also help determine the RAID configuration best suited to the specific storage requirements: +
- +
-    Getting the Most out of ZFS Pools +
-    A Closer Look at ZFS, Vdevs and Performance +
- +
-Warning +
- +
-RAID AND DISK REDUNDANCY ARE NOT A SUBSTITUTE FOR A RELIABLE BACKUP STRATEGY. BAD THINGS HAPPEN AND A GOOD BACKUP STRATEGY IS STILL REQUIRED TO PROTECT VALUABLE DATA. See Periodic Snapshot Tasks and Replication Tasks to use replicated ZFS snapshots as part of a backup strategy. +
- +
-ZFS manages devices. When an individual drive in a mirror or RAIDZ fails and is replaced by the user, ZFS adds the replacement device to the vdev and copies redundant data to it in a process called resilvering. Hardware RAID controllers usually have no way of knowing which blocks were in use and must copy every block to the new device. ZFS only copies blocks that are in use, reducing the time it takes to rebuild the vdev. Resilvering is also interruptable. After an interruption, resilvering resumes where it left off rather than starting from the beginning. +
- +
-While ZFS provides many benefits, there are some caveats: +
- +
-    At 90% capacity, ZFS switches from performance- to space-based optimization, which has massive performance implications. For maximum write performance and to prevent problems with drive replacement, add more capacity before a pool reaches 80%. +
-    When considering the number of disks to use per vdev, consider the size of the disks and the amount of time required for resilvering, which is the process of rebuilding the vdev. The larger the size of the vdev, the longer the resilvering time. When replacing a disk in a RAIDZ, it is possible that another disk will fail before the resilvering process completes. If the number of failed disks exceeds the number allowed per vdev for the type of RAIDZ, the data in the pool will be lost. For this reason, RAIDZ1 is not recommended for drives over 1 TiB in size. +
-    Using drives of equal sizes is recommended when creating a vdev. While ZFS can create a vdev using disks of differing sizes, its capacity will be limited by the size of the smallest disk. +
- +
-For those new to ZFS, the Wikipedia entry on ZFS provides an excellent starting point to learn more about its features. These resources are also useful for reference: +
- +
-    FreeBSD ZFS Tuning Guide +
-    ZFS Administration Guide +
-    Becoming a ZFS Ninja Part 1 (video) and Becoming a ZFS Ninja Part 2 (video) +
-    The Z File System (ZFS) +
-    ZFS: The Last Word in File Systems - Part 1 (video) +
-    The Zettabyte Filesystem +
- +
-27.1. ZFS Feature Flags +
- +
-To differentiate itself from Oracle ZFS version numbers, OpenZFS uses feature flags. Feature flags are used to tag features with unique names to provide portability between OpenZFS implementations running on different platforms, as long as all of the feature flags enabled on the ZFS pool are supported by both platforms. FreeNAS® uses OpenZFS and each new version of FreeNAS® keeps up-to-date with the latest feature flags and OpenZFS bug fixes. +
- +
-See zpool-features(7) for a complete listing of all OpenZFS feature flags available on FreeBSD.+
  
 +===== 参考サイト =====
  
 +  * [[https://github.com/openzfs/zfs/pull/5182|Metadata Allocation Classes by don-brady · Pull Request #5182 · openzfs/zfs · GitHub]]
 +  * [[https://docs.google.com/presentation/d/17nYRgs-TAIOPODOMaq-VwuJ0LqJHEXBfM9sUDxJUJ54|Pool Allocation Classes - 5182]]
 +  * [[https://forums.servethehome.com/index.php?threads/zfs-allocation-classes-special-vdev.28862/|ZFS Allocation Classes / Special VDEV | ServeTheHome Forums]]
 +  * [[https://forum.level1techs.com/t/zfs-metadata-special-device-z/159954|ZFS Metadata Special Device: Z - Wikis & How-to Guides - Level1Techs Forums]]
 +  * [[https://zfs.datto.com/2017_slides/brady.pdf|Using Allocation Class]](PDF)
 +  * [[https://www.napp-it.org/doc/downloads/special-vdev.pdf|Allocation Classes Feature - Benchmarks and use case on OmniOS]]