如何在啟動程序階段之後更新所有 Amazon EMR 節點?

1 分的閱讀內容
0

我想在 BOOTSTRAPPING 狀態完成後更新 Amazon EMR 叢集上的所有節點。

簡短描述

啟動程序階段發生在 Amazon EMR 安裝和設定 Apache Hadoop 和 Apache Spark 等應用程式之前。若要在 Amazon EMR 安裝和設定應用程式後在所有叢集節點上進行其他變更,請執行可下載和執行其他指令碼的啟動程序動作。

解決方法

1.    建立 bash 指令碼,指定您要在所有叢集節點上進行的變更。請參閱下列範例。

範例 1: 此指令碼會等待組態檔 (/etc/hadoop/conf/hadoop-env.sh) 變為可用,然後執行其他工作。

#!/bin/bash
#
# This is an example of script_b.sh
#
while [ ! -f /etc/hadoop/conf/hadoop-env.sh ]
do
  sleep 1
done
#
# Now the file is available, do your work here
#

exit 0

範例 2: 此指令碼會等待 EMR 叢集進入 WAITING 狀態,然後再實作其他自訂。這可讓 EMR 叢集完成安裝及設定 Hadoop 和其他應用程式。

#!/bin/bash
#
# This is an example of script_b.sh
#
# Wait for EMR provisioning to become successful.
#
while [[ $(sed '/localInstance {/{:1; /}/!{N; b1}; /nodeProvision/p}; d' /emr/instance-controller/lib/info/job-flow-state.txt | sed '/nodeProvisionCheckinRecord {/{:1; /}/!{N; b1}; /status/p}; d' | awk '/SUCCESSFUL/' | xargs) != "status: SUCCESSFUL" ]];
do
  sleep 1
done
#
# Now the EMR cluster is ready. Do your work here.
#

exit 0

2.    啟動 EMR 叢集並新增如下啟動程序動作。此指令碼會下載您在上一個步驟 (script_b.sh) 中建立的指令碼,然後在背景中執行。

#!/bin/bash
aws s3 cp s3://doc-example-bucket/script_b.sh .
chmod +x script_b.sh
nohup ./script_b.sh &>/dev/null &

相關資訊

了解叢集生命週期

AWS 官方
AWS 官方已更新 2 年前