協助改善此頁面
本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
若要提供此使用者指南,請選擇位於每個頁面右窗格中的在 GitHub 上編輯此頁面連結。
本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
最佳化節點上的 Amazon FSx for Lustre 效能 (非 EBA)
您可以使用啟動範本使用者資料,在節點初始化期間套用調校參數,以最佳化 Amazon FSx for Lustre 效能。
注意
-
如需建立和部署 FSx for Lustre CSI 驅動程式的詳細資訊,請參閱 部署 FSx for Lustre 驅動程式。如需使用啟用 EFA 的節點最佳化效能,請參閱 最佳化節點上的 Amazon FSx for Lustre 效能 (EFA)。
為什麼要使用啟動範本使用者資料?
-
在節點初始化期間自動套用調校。
-
確保所有節點的組態一致。
-
無需手動節點組態。
範例指令碼概觀
本主題中定義的範例指令碼會執行這些操作:
# 1. Install Lustre client
-
自動偵測您的作業系統版本:Amazon Linux 2 (AL2) 或 Amazon Linux 2023 (AL2023)。
-
安裝適當的 Lustre 用戶端套件。
# 2. Apply network and RPC tunings
-
ptlrpcd_per_cpt_max=64
用於平行 RPC 處理的集合。 -
設定
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
-
您也必須在本節中調整環境的值。
-
自動偵測您的作業系統版本 (AL2 或 AL2023),以決定要套用
Systemd
的服務。 -
系統啟動。
-
Systemd
啟動lustre-tunings
服務 (由於WantedBy=multi-user.target
)。 -
服務執行
apply_lustre_tunings.sh
:-
檢查檔案系統是否已掛載。
-
如果未掛載,則掛載檔案系統。
-
等待成功掛載 (最多五分鐘)。
-
成功掛載後套用調校參數。
-
-
設定會保持作用中狀態,直到重新啟動為止。
-
服務會在指令碼完成後結束。
-
Systemd 會將服務標記為「作用中 (已結束)」。
-
-
程序會在下次重新開機時重複。
建立啟動範本
-
前往 https://console.aws.amazon.com/ec2/
開啟 Amazon EC2 主控台。 -
選擇啟動範本。
-
選擇 Create launch template (建立啟動範本)。
-
在進階詳細資訊中,找到使用者資料區段。
-
貼上以下指令碼,並視需要更新任何項目。
重要
在 區段和 區段
# 5. Mount FSx filesystem
中的setup_persistence()
函數apply_lustre_tunings.sh
中,為您的環境調整這些值# 8. 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 節點群組時,請選取此啟動範本。如需詳細資訊,請參閱為您的叢集建立受管節點群組。