このページの改善にご協力ください
このユーザーガイドに貢献するには、すべてのページの右側のペインにある「GitHub でこのページを編集する」リンクを選択してください。
ノードでの Amazon FSx for Lustre のパフォーマンスを最適化する (EFA 以外)
起動テンプレートのユーザーデータを使用して、ノードの初期化中にチューニングパラメータを適用することで、Amazon FSx for Lustre のパフォーマンスを最適化することができます。
注記
-
FSx for Lustre CSI ドライバーの作成とデプロイの詳細については、「FSx for Lustre ドライバーをデプロイする」を参照してください。EFA 対応ノードでパフォーマンスを最適化するには、「ノードでの Amazon FSx for Lustre のパフォーマンスを最適化する (EFA)」を参照してください。
なぜ起動テンプレートのユーザーデータを使用するのか
-
ノードの初期化中にチューニングを自動的に適用するため。
-
すべてのノードで一貫した設定を確保するため。
-
手動でのノード設定を不要にするため。
スクリプトの概要の例
このトピックで定義されているスクリプト例では、以下の操作を実行します。
# 1. Install Lustre client
-
OS バージョン (Amazon Linux 2 (AL2) または Amazon Linux 2023 (AL2023)) を自動検出します。
-
適切な Lustre クライアントパッケージをインストールします。
# 2. Apply network and RPC tunings
-
並列 RPC 処理用に
ptlrpcd_per_cpt_max=64
を設定します。 -
ksocklnd credits=2560
を設定してネットワークバッファを最適化します。
# 3. Load Lustre modules
-
既存の Lustre モジュールがある場合は、安全に削除します。
-
既存のファイルシステムのアンマウントに対処します。
-
新しい Lustre モジュールをロードします。
# 4. Lustre Network Initialization
-
Lustre のネットワーク設定を初期化します。
-
必要なネットワークパラメータを設定します。
# 5. Mount FSx filesystem
-
このセクションでは、お使いの環境向けに値を調整する必要があります。
# 6. Apply tunings
-
LRU (ロックリソースユニット) の調整:
-
lru_max_age=600000
-
lru_size
CPU 数に基づいて計算
-
-
クライアントキャッシュコントロール:
max_cached_mb=64
-
RPC コントロール:
-
OST
max_rpcs_in_flight=32
-
MDC
max_rpcs_in_flight=64
-
MDC
max_mod_rpcs_in_flight=50
-
# 7. Verify tunings
-
適用されたすべてのチューニングを検証します。
-
各パラメータの成功または警告を報告します。
# 8. Setup persistence
-
このセクションでも同様にお使いの環境向けに値を調整する必要があります。
-
OS のバージョン (AL2 または AL2023) を自動検出し、どの
Systemd
サービスを適用するか判断します。 -
システムが起動します。
-
Systemd
がlustre-tunings
サービスを開始します (WantedBy=multi-user.target
により)。 -
サービスが
apply_lustre_tunings.sh
実行します。こちらは、-
ファイルシステムがマウントされているかどうかを確認します。
-
マウントされていない場合、ファイルシステムをマウントします。
-
マウントが完了するまで待機します (最大 5 分)。
-
マウントが完了すると、チューニングパラメータを適用します。
-
-
設定は、再起動するまでアクティブな状態のままです。
-
スクリプトが完成すると、サービスは終了します。
-
Systemd は、サービスを [アクティブ (終了済み)] にマークします。
-
-
次回の再起動時にプロセスが繰り返されます。
起動テンプレートの作成
-
Amazon EC2 コンソールの https://console.aws.amazon.com/ec2/
を開いてください。 -
[起動テンプレート] を選択します。
-
[起動テンプレートの作成] を選択してください。
-
[高度な詳細] で、[ユーザーデータ] のセクションを見つけます。
-
以下のスクリプトを貼り付け、必要に応じて更新します。
重要
セクション
# 5. Mount FSx filesystem
と、セクション# 8. Setup persistence
のapply_lustre_tunings.sh
のsetup_persistence()
関数の両方で、お使いの環境のこれらの値を調整します。FSX_DNS="<your-fsx-filesystem-dns>" # Needs to be adjusted. MOUNT_NAME="<your-mount-name>" # Needs to be adjusted. MOUNT_POINT="</your/mount/point>" # Needs to be adjusted.
MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="==MYBOUNDARY==" --==MYBOUNDARY== Content-Type: text/x-shellscript; charset="us-ascii" #!/bin/bash exec 1> >(logger -s -t $(basename $0)) 2>&1 # Function definitions check_success() { if [ $? -eq 0 ]; then echo "SUCCESS: $1" else echo "FAILED: $1" return 1 fi } apply_tunings() { local NUM_CPUS=$(nproc) local LRU_SIZE=$((100 * NUM_CPUS)) local params=( "ldlm.namespaces.*.lru_max_age=600000" "ldlm.namespaces.*.lru_size=$LRU_SIZE" "llite.*.max_cached_mb=64" "osc.*OST*.max_rpcs_in_flight=32" "mdc.*.max_rpcs_in_flight=64" "mdc.*.max_mod_rpcs_in_flight=50" ) for param in "${params[@]}"; do lctl set_param $param check_success "Set ${param%%=*}" done } verify_param() { local param=$1 local expected=$2 local actual=$3 if [ "$actual" == "$expected" ]; then echo "SUCCESS: $param is correctly set to $expected" else echo "WARNING: $param is set to $actual (expected $expected)" fi } verify_tunings() { local NUM_CPUS=$(nproc) local LRU_SIZE=$((100 * NUM_CPUS)) local params=( "ldlm.namespaces.*.lru_max_age:600000" "ldlm.namespaces.*.lru_size:$LRU_SIZE" "llite.*.max_cached_mb:64" "osc.*OST*.max_rpcs_in_flight:32" "mdc.*.max_rpcs_in_flight:64" "mdc.*.max_mod_rpcs_in_flight:50" ) echo "Verifying all parameters:" for param in "${params[@]}"; do name="${param%%:*}" expected="${param#*:}" actual=$(lctl get_param -n $name | head -1) verify_param "${name##*.}" "$expected" "$actual" done } setup_persistence() { # Create functions file cat << 'EOF' > /usr/local/bin/lustre_functions.sh #!/bin/bash apply_lustre_tunings() { local NUM_CPUS=$(nproc) local LRU_SIZE=$((100 * NUM_CPUS)) echo "Applying Lustre performance tunings..." lctl set_param ldlm.namespaces.*.lru_max_age=600000 lctl set_param ldlm.namespaces.*.lru_size=$LRU_SIZE lctl set_param llite.*.max_cached_mb=64 lctl set_param osc.*OST*.max_rpcs_in_flight=32 lctl set_param mdc.*.max_rpcs_in_flight=64 lctl set_param mdc.*.max_mod_rpcs_in_flight=50 } EOF # Create tuning script cat << 'EOF' > /usr/local/bin/apply_lustre_tunings.sh #!/bin/bash exec 1> >(logger -s -t $(basename $0)) 2>&1 # Source the functions source /usr/local/bin/lustre_functions.sh # FSx details FSX_DNS="<your-fsx-filesystem-dns>" # Needs to be adjusted. MOUNT_NAME="<your-mount-name>" # Needs to be adjusted. MOUNT_POINT="</your/mount/point>" # Needs to be adjusted. # Function to check if Lustre is mounted is_lustre_mounted() { mount | grep -q "type lustre" } # Function to mount Lustre mount_lustre() { echo "Mounting Lustre filesystem..." mkdir -p ${MOUNT_POINT} mount -t lustre ${FSX_DNS}@tcp:/${MOUNT_NAME} ${MOUNT_POINT} return $? } # Main execution # Try to mount if not already mounted if ! is_lustre_mounted; then echo "Lustre filesystem not mounted, attempting to mount..." mount_lustre fi # Wait for successful mount (up to 5 minutes) for i in {1..30}; do if is_lustre_mounted; then echo "Lustre filesystem mounted, applying tunings..." apply_lustre_tunings exit 0 fi echo "Waiting for Lustre filesystem to be mounted... (attempt $i/30)" sleep 10 done echo "Timeout waiting for Lustre filesystem mount" exit 1 EOF # Create systemd service cat << 'EOF' > /etc/systemd/system/lustre-tunings.service [Unit] Description=Apply Lustre Performance Tunings After=network.target remote-fs.target StartLimitIntervalSec=0 [Service] Type=oneshot ExecStart=/usr/local/bin/apply_lustre_tunings.sh RemainAfterExit=yes Restart=on-failure RestartSec=30 [Install] WantedBy=multi-user.target EOF chmod +x /usr/local/bin/lustre_functions.sh chmod +x /usr/local/bin/apply_lustre_tunings.sh systemctl enable lustre-tunings.service systemctl start lustre-tunings.service } echo "Starting FSx for Lustre configuration..." # 1. Install Lustre client if grep -q 'VERSION="2"' /etc/os-release; then amazon-linux-extras install -y lustre elif grep -q 'VERSION="2023"' /etc/os-release; then dnf install -y lustre-client fi check_success "Install Lustre client" # 2. Apply network and RPC tunings export PATH=$PATH:/usr/sbin echo "Applying network and RPC tunings..." if ! grep -q "options ptlrpc ptlrpcd_per_cpt_max" /etc/modprobe.d/modprobe.conf; then echo "options ptlrpc ptlrpcd_per_cpt_max=64" | tee -a /etc/modprobe.d/modprobe.conf echo "options ksocklnd credits=2560" | tee -a /etc/modprobe.d/modprobe.conf fi # 3. Load Lustre modules modprobe lustre check_success "Load Lustre modules" || exit 1 # 4. Lustre Network Initialization lctl network up check_success "Initialize Lustre networking" || exit 1 # 5. Mount FSx filesystem FSX_DNS="<your-fsx-filesystem-dns>" # Needs to be adjusted. MOUNT_NAME="<your-mount-name>" # Needs to be adjusted. MOUNT_POINT="</your/mount/point>" # Needs to be adjusted. if [ ! -z "$FSX_DNS" ] && [ ! -z "$MOUNT_NAME" ]; then mkdir -p $MOUNT_POINT mount -t lustre ${FSX_DNS}@tcp:/${MOUNT_NAME} ${MOUNT_POINT} check_success "Mount FSx filesystem" fi # 6. Apply tunings apply_tunings # 7. Verify tunings verify_tunings # 8. Setup persistence setup_persistence echo "FSx for Lustre configuration completed." --==MYBOUNDARY==--
-
Amazon EKS ノードグループを作成するときは、この起動テンプレートを選択します。詳細については、「クラスターのマネージドノードグループを作成する」を参照してください。