Skip to content

Instantly share code, notes, and snippets.

@lokkju
Last active April 1, 2020 08:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lokkju/33f94126494faa8e27f98d588ff43bb3 to your computer and use it in GitHub Desktop.
Save lokkju/33f94126494faa8e27f98d588ff43bb3 to your computer and use it in GitHub Desktop.
Run a command on all nodes in a hadoop cluster
# ssh -A hadoop@<masternode>
# SCRIPT=<yourscriptfile.sh>
declare nodes=`yarn node -list 2> /dev/null | grep internal | cut -d' ' -f1 | cut -d: -f1`
for node in $nodes
do
ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null hadoop@$node 'bash -s' < $SCRIPT
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment