Run custom shell script on all slave nodes in EMR

Viewed 1201

AWS Step documentation says steps only execute on the master, does that mean even if I am logged in to any of the slave nodes and execute the add-steps command on it, the command would go and add the step on to the master node only? How can I then execute a custom shell script on all the slave nodes? Bootstrapping is not an option since the shell script requires the emrf-site.xml to be already created which does not happen until the EMR is completely up and running.

1 Answers

You can use "Custom JAR" step type to run "script-runner.jar" that will run any bash script on every cluster node:

aws emr create-cluster --name ... --steps Type=CUSTOM_JAR,Name=CustomJAR,ActionOnFailure=CONTINUE,Jar=s3://region.elasticmapreduce/libs/script-runner/script-runner.jar,Args=["s3://mybucket/script-path/my_script.sh"]

More info here: https://docs.aws.amazon.com/emr/latest/ReleaseGuide/emr-hadoop-script.html

Related