gpt4 book ai didi

bash - 如何使用 bash 命令将 EMR 步骤添加到 cloudformation

转载 作者:行者123 更新时间:2023-12-03 07:33:47 26 4
gpt4 key购买 nike

我尝试通过 Cloudformation 将以下步骤添加到我的 EMR 集群,但失败并提示文件未找到错误。我尝试转义双引号但没有用。

 SetupHiveStep:
Type: AWS::EMR::Step
Properties:
Name: SetupHive
ActionOnFailure: CANCEL_AND_WAIT
JobFlowId: !Ref Cluster
HadoopJarStep:
Jar: "command-runner.jar"
Args:
- !Sub bash -c "aws s3 cp s3://test-emr/scripts/init.sh /home/hadoop/init.sh;sudo chmod +x /home/hadoop/init.sh;sh /home/hadoop/init.sh;"

以下是 EMR 的实际步骤配置:

JAR location :command-runner.jar
Main class :None
Arguments :bash -c "aws s3 cp s3://test-emr/scripts/init.sh /home/hadoop/init.sh;sudo chmod +x /home/hadoop/init.sh;sh /home/hadoop/init.sh;"
Action on failure:Terminate cluster

以下是 EMR 失败步骤的错误:

Exception in thread "main" java.lang.RuntimeException: java.io.IOException: Cannot run program "bash -c "aws s3 cp s3://test-emr/scripts/init.sh /home/hadoop/init.sh;sudo chmod +x /home/hadoop/init.sh;sh /home/hadoop/init.sh;"" (in directory "."): error=2, No such file or directory
at com.amazonaws.emr.command.runner.ProcessRunner.exec(ProcessRunner.java:139)
at com.amazonaws.emr.command.runner.CommandRunner.main(CommandRunner.java:13)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.hadoop.util.RunJar.run(RunJar.java:323)
at org.apache.hadoop.util.RunJar.main(RunJar.java:236)
Caused by: java.io.IOException: Cannot run program "bash -c "aws s3 cp s3://preddy-test-emr/scripts/init.sh /home/hadoop/init.sh;sudo chmod +x /home/hadoop/init.sh;sh /home/hadoop/init.sh;"" (in directory "."): error=2, No such file or directory
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
at com.amazonaws.emr.command.runner.ProcessRunner.exec(ProcessRunner.java:92)
... 7 more
Caused by: java.io.IOException: error=2, No such file or directory
at java.lang.UNIXProcess.forkAndExec(Native Method)
at java.lang.UNIXProcess.<init>(UNIXProcess.java:247)
at java.lang.ProcessImpl.start(ProcessImpl.java:134)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
... 8 more

最佳答案

我可以通过修改命令来完成这项工作,如下所示。必须添加 && 以及 bash -c

SetupHiveStep:
Type: AWS::EMR::Step
Properties:
Name: SetupHive
ActionOnFailure: CANCEL_AND_WAIT
JobFlowId: !Ref Cluster
HadoopJarStep:
Jar: "command-runner.jar"
Args:
- "bash"
- "-c"
- !Sub "aws s3 cp s3://${S3ConfPrefix}/scripts/init.sh /home/hadoop/init.sh && sudo chmod +x /home/hadoop/init.sh && sh /home/hadoop/init.sh"
- !Ref S3ConfPrefix

关于bash - 如何使用 bash 命令将 EMR 步骤添加到 cloudformation,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71380084/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com