Amazon FSx for Lustreを触ってみる

FSx for Lustreを触ってみた時のメモ書きです。

概要

Amazon FSx for Lustre とは、S3をバックエンドとするHSM(Hierarchical Storage Management)機能をもった、Managed Lustre File System Serviceと呼べるものです。

Lustreとは、スパコン領域で利用されるような分散ファイルシステムとなります。

Lustre is an open-source, distributed parallel file system software platform designed for scalability, high-performance, and high-availability.

Lustre is purpose-built to provide a coherent, global POSIX-compliant namespace for very large scale computer infrastructure, including the world's largest supercomputer platforms. It can support hundred's of petabytes of data storage and hundreds of gigabytes per second in simultaneous, aggregate throughput. Some of the largest current installations have individual file systems in excess of fifty petabytes of usable capacity, and have reported throughput speeds exceeding one terabyte/sec.

Lustre Wiki - Main Page

LustreのHSMとは、実際に利用対象のデータが保管された別途Storageからデータをインポートして、Lustreをキャッシュサーバー的に利用できるようにした方法、といった理解をしています。以下はwikipediaの説明文。

Lustre provides the capability to have multiple storage tiers within a single filesystem namespace. It allows traditional HSM functionality to copy (archive) files off the primary filesystem to a secondary archive storage tier. The archive tier is typically a tape-based system, that is often fronted by a disk cache. Once a file is archived, it can be released from the main filesystem, leaving only a stub that references the archive copy. If a released file is opened, the Coordinator blocks the open, sends a restore request to a copytool, and then completes the open once the copytool has completed restoring the file.

Wikipedia - Lustre (file system) - HSM (Hierarchical Storage Management))

blackbeltのスライドを見ることで、理解しやすいと思っています。

f:id:goodbyegangster:20201015142258p:plain

f:id:goodbyegangster:20201015142309p:plain

20190319 AWS Black Belt Online Seminar Amazon FSx for Lustre

利用してみる

公式ドキュメントにてチュートリアルが公開されていますので、そちらを参考にFSx for Lustreを利用してみてみます。

Getting Started with Amazon FSx for Lustre

Lustre filesystemの作成

FSx for Lustreファイルシステムを作成します。作成にあたり考慮すべきパラメーターがあるので、その点を確認。

DeploymentType

作成するファイルシステムの冗長性を、 PERSISTENT と SCRATCH から指定します。

Using Available Deployment Options for Amazon FSx for Lustre File Systems

StorageType

利用するストレージを、SSDHDD より選択できます。

DriveCacheType

HDDを利用する場合、ファイルシステムの20%をSSDとして設定でき、最新アクセスのあったファイルのキャッシュとして利用できます。

PerUnitStorageThroughput/StorageCapacity

ファイルシステムスループット、およびをプロビジョニングするディスクサイズを指定します。

指定できる値は、利用するDeploymentTypeやStorageTypeにより異なります。一覧表となる情報が、下記ドキュメント内で記載されており、分かりやすいです。

Amazon FSx for Lustre Update: Persistent Storage for Long-Term, High-Performance Workloads

ImportPath/ExportPath

バックエンドとして利用するS3のPath情報を指定します。ImportPathとは、バックエンドとして扱うS3上ファイルのPathを指定するものです。エクスポートとは、Lustreファイルシステム上で更新されたファイルを、S3側へアップデートする処理を指しており、ExportPathとは、そのアップデート時に利用されるS3のPathとなります。

ExportPathは、ImportPathで利用されるS3バケットと同一バケットである必要があり、利用するPrefix部分を以下の種類より指定することができます。

  • A unique prefix that Amazon FSx creates in your bucket
  • The same prefix that you imported from (replace existing objects with updated ones)
    • 上書き
  • A prefix you specify
    • 固定指定

AutoImportPolicy

S3側オブジェクト更新時のLustreファイルシステム側への更新処理(インポート処理)の動作を、以下の種類より指定できます。

  • NONE
    • Update my file and directory listing as objects are added to my S3 bucket
  • NEW
    • Update my file and directory listing as objects are added to or changed in my S3 bucket
  • NEW_CHANGED
    • Do not update my file and directly listing when objects are added to or changed in my S3 bucket

より詳しくはこちらです。

Automatically import updates from your S3 bucket


FSx Lustre ファイルシステム作成時の、サンプルとなるCloudFormationのテンプレートを置いておきます。

https://github.com/goodbyegangster/cloudformation/tree/master/fsx-lustre

Lustre Clientのインストール

作成したファイルシステムLinux OS上にマウントするため、Linux OSにLustre Clientモジュールをインストールします。公式マニュアルにて各ディストリビューションでのインストール方法が説明されているため、そちらを参考に。

Installing the Lustre Client

Amazon Linux2にてインストールする方法は下記。

$ sudo amazon-linux-extras install -y lustre2.10
$ lfs --version
lfs 2.10.8

filesystemのマウント

ファイルシステムをマウントします。こちらも公式ドキュメントにて参考情報を記載してくれています。

Mounting from an Amazon EC2 Instance

$ sudo mkdir -p /mnt/fsx
$ sudo mount -t lustre -o noatime,flock fs-XXXXXXXXXX.fsx.ap-northeast-1.amazonaws.com(file_system_dns_name)@tcp:/XXXXXXX(mountname) /mnt/fsx
$ df | grep fsx
172.31.39.22@tcp:/2pdblbmv 1168351232    4608 1168344576   1% /mnt/fsx

/etc/fstab ファイルを編集する場合の情報はこちら。

Mounting Your Amazon FSx File System Automatically

ファイル操作

実際にファイルを操作してみます。

ファイルシステムの作成時に、インポート先として指定したS3上ファイルのメタデータを、Lustreファイルシステム上に連携してくれています。

$ ls -l /mnt/fsx/lustre/*
-rwxr-xr-x 1 root root 12 Oct  7 04:42 /mnt/fsx/lustre/sample1.txt
-rwxr-xr-x 1 root root 12 Oct  7 04:39 /mnt/fsx/lustre/sample2.txt

実際にファイルアクセスすると、S3からLustreファイルシステム上にファイルがインポートされます。

$ cat /mnt/fsx/lustre/sample1.txt
sample file.

Lustreファイルシステム上でのファイル実体有無の確認

Lustreファイルシステム上でのファイル実体有無を確認するには、 lfs hsm_state コマンドを利用します。 lfs とはLustre Clientモジュールで利用するLustreファイルシステム管理用のコマンドラインとなります。Lustreファイルシステム上にファイル存在しない場合、 released というフラグが付与されています。

$ lfs hsm_state /mnt/fsx/lustre/*
/mnt/fsx/lustre/sample1.txt: (0x00000009) exists archived, archive_id:1
/mnt/fsx/lustre/sample2.txt: (0x0000000d) released exists archived, archive_id:1

ファイルのpreload

また、 lfs hsm_restore コマンドを利用することで、ファイルにアクセスせずとも、Lustreファイルシステム上にファイルをインポート(preload)できます。処理結果は、 lfs hsm_action コマンドにて確認ができます。 NOOP と表示されていれば、正常にインポート処理が終了していることを示しています。

Preloading files into your file system

$ lfs hsm_restore /mnt/fsx/lustre/sample2.txt
$
$ lfs hsm_state /mnt/fsx/lustre/*
/mnt/fsx/lustre/sample1.txt: (0x00000009) exists archived, archive_id:1
/mnt/fsx/lustre/sample2.txt: (0x00000009) exists archived, archive_id:1
$
$ lfs hsm_action /mnt/fsx/lustre/*
/mnt/fsx/lustre/sample1.txt: NOOP
/mnt/fsx/lustre/sample2.txt: NOOP

ファイルのエクスポート

続いて、Lustreファイルシステム上のファイルを更新し、S3側へエクスポート(ファイルのアップデート)をしてみます。とりあえず、Lustreファイルシステム上のファイルを更新します。

$ sudo chmod 777 /mnt/fsx/lustre/sample1.txt
$ echo zunda >> /mnt/fsx/lustre/sample1.txt
$ lfs hsm_state /mnt/fsx/lustre/*
/mnt/fsx/lustre/sample1.txt: (0x0000000b) exists dirty archived, archive_id:1
/mnt/fsx/lustre/sample2.txt: (0x00000009) exists archived, archive_id:1

更新されたファイルのステータスを確認すると、 dirty と未確定である旨を意味するフラグがついています。エクスポート処理には lfs hsm_archive というコマンドを利用します。

Exporting files using HSM commands

$ lfs hsm_archive /mnt/fsx/lustre/sample1.txt
$
$ lfs hsm_state /mnt/fsx/lustre/*
/mnt/fsx/lustre/sample1.txt: (0x00000009) exists archived, archive_id:1
/mnt/fsx/lustre/sample2.txt: (0x00000009) exists archived, archive_id:1

ファイルシステム作成時に指定したエクスポート先となるS3のPathに、S3オブジェクトが連携されています。

なお、エクスポートする方法では、 lfs hsm_archive コマンドを利用する以外にも、AWS側で用意されたデータリポジトリタスクの機能も利用できます。エクスポートしたいLustreファイルシステム上のPathを指定することで、エクスポート処理を実行してくれます。AWSコンソールの他、CLIでも実行できるため、Lambdaも用いることでエクスポート処理のスケジュール管理が可能となります。

Data Repository Tasks

ファイルのリリース

Lustreファイルシステム上からファイルを削除するには、 lsf hsm_release コマンドを利用します。

Releasing data from your file system

$ lfs hsm_state /mnt/fsx/lustre/*
/mnt/fsx/lustre/sample1.txt: (0x00000009) exists archived, archive_id:1
/mnt/fsx/lustre/sample2.txt: (0x00000009) exists archived, archive_id:1
$
$ lfs hsm_release /mnt/fsx/lustre/sample1.txt
$
$ lfs hsm_state /mnt/fsx/lustre/*
/mnt/fsx/lustre/sample1.txt: (0x0000000d) released exists archived, archive_id:1
/mnt/fsx/lustre/sample2.txt: (0x00000009) exists archived, archive_id:1