运行 bash 脚本作为 EMR 中的一个步骤的正确语法是什么?
What is the correct syntax for running a bash script as a step in EMR?
我正在尝试 运行 bash 脚本作为 EMR 完成引导后的一个步骤。以下是我的地形代码:
step { action_on_failure = "CONTINUE"
name = "Setup Hadoop configuration"
hadoop_jar_step {
jar = "command-runner.jar"
args = ["bash,-c,'cd /mnt; chmod +x ./userdata.sh; ./userdata.sh'"]
}}
这是行不通的,并且一直在提示找不到文件。
是否正确提供了参数? script-runner.jar 呢?
非常感谢任何帮助。 :(
来自 AWS 文档的片段。
The following is an example usage of command-runner.jar using the AWS
CLI:
aws emr add-steps --cluster-id j-2AXXXXXXGAPLF --steps Name="Command Runner",Jar="command-runner.jar",Args=["spark-submit","Args..."]
参考
使用 command-runner.jar
你可以执行很多程序,比如 bash 脚本,
并且您不必像 script-runner.jar
那样知道它的完整路径。推荐使用command-runner.jar
.
EMR是集群模式,不知道哪个节点执行shell脚本,所以推到S3:
{
"Name": "Setup Hadoop configuration",
"ActionOnFailure": "CONTINUE",
"HadoopJarStep": {
"Jar": "command-runner.jar",
"Args": [
"bash",
"-c",
" aws s3 cp s3://path_to_bucket_S3/userdata.sh .;
chmod +x userdata.sh;
./userdata.sh args...;
rm userdata.sh "
]
}
}
command-runner.jar
无法在 s3 上执行远程文件。我们必须使用 script-runner.jar
来执行远程 jar。我就是这样通过亚马逊 UI.
创建步骤-defn.json:(在 S3 存储桶中或本地 EMR 中)
[{
"Name": "shell_script_that_needs_to_be_executed_as_emr_step",
"ActionOnFailure": "CONTINUE",
"Type":"CUSTOM_JAR",
"Jar":"command-runner.jar",
"Args":["bash","-c","mkdir -p /tmp/script-for-s3-copy/; aws s3 cp s3://<bucket-name>/some-blah-blah-shell-script.sh /tmp/script-for-s3-copy/;chmod -R 777 /tmp/script-for-s3-copy/*.sh;cd /tmp/script-for-s3-copy;sh some-blah-blah-shell-script.sh.sh"]
}]
使用bootstrap脚本下载EMR本地文件夹中的步骤定义(如果步骤-defn.json存储在S3中)
aws emr add-steps --cluster-id j-xxxxxxxxxxxx --steps file:///<folder_where_the_json_is_downloaded>/step-defn.json
可在此处找到详细文档:https://docs.aws.amazon.com/cli/latest/reference/emr/add-steps.html
我正在尝试 运行 bash 脚本作为 EMR 完成引导后的一个步骤。以下是我的地形代码:
step { action_on_failure = "CONTINUE"
name = "Setup Hadoop configuration"
hadoop_jar_step {
jar = "command-runner.jar"
args = ["bash,-c,'cd /mnt; chmod +x ./userdata.sh; ./userdata.sh'"]
}}
这是行不通的,并且一直在提示找不到文件。 是否正确提供了参数? script-runner.jar 呢? 非常感谢任何帮助。 :(
来自 AWS 文档的片段。
The following is an example usage of command-runner.jar using the AWS CLI:
aws emr add-steps --cluster-id j-2AXXXXXXGAPLF --steps Name="Command Runner",Jar="command-runner.jar",Args=["spark-submit","Args..."]
参考
使用 command-runner.jar
你可以执行很多程序,比如 bash 脚本,
并且您不必像 script-runner.jar
那样知道它的完整路径。推荐使用command-runner.jar
.
EMR是集群模式,不知道哪个节点执行shell脚本,所以推到S3:
{ "Name": "Setup Hadoop configuration", "ActionOnFailure": "CONTINUE", "HadoopJarStep": { "Jar": "command-runner.jar", "Args": [ "bash", "-c", " aws s3 cp s3://path_to_bucket_S3/userdata.sh .; chmod +x userdata.sh; ./userdata.sh args...; rm userdata.sh " ] } }
command-runner.jar
无法在 s3 上执行远程文件。我们必须使用 script-runner.jar
来执行远程 jar。我就是这样通过亚马逊 UI.
创建步骤-defn.json:(在 S3 存储桶中或本地 EMR 中)
[{
"Name": "shell_script_that_needs_to_be_executed_as_emr_step",
"ActionOnFailure": "CONTINUE",
"Type":"CUSTOM_JAR",
"Jar":"command-runner.jar",
"Args":["bash","-c","mkdir -p /tmp/script-for-s3-copy/; aws s3 cp s3://<bucket-name>/some-blah-blah-shell-script.sh /tmp/script-for-s3-copy/;chmod -R 777 /tmp/script-for-s3-copy/*.sh;cd /tmp/script-for-s3-copy;sh some-blah-blah-shell-script.sh.sh"]
}]
使用bootstrap脚本下载EMR本地文件夹中的步骤定义(如果步骤-defn.json存储在S3中)
aws emr add-steps --cluster-id j-xxxxxxxxxxxx --steps file:///<folder_where_the_json_is_downloaded>/step-defn.json
可在此处找到详细文档:https://docs.aws.amazon.com/cli/latest/reference/emr/add-steps.html