如何在引导阶段之后更新所有的 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 年前