1

In order to get a list of the ip addresses of emr slave nodes, one must run the following code:

yarn node -list 2>/dev/null \
| sed -n "s/^\(ip[^:]*\):.*/\1/p"

yarn node -list happens to print off the ip of the master node to stderr:

19/04/02 18:59:26 INFO client.RMProxy: Connecting to ResourceManager at ip-10-1-0-238.ec2.internal/10.1.0.238:8032

How would I modify the above code to get the private ip of the emr master node instead?

Walrus the Cat
  • 2,314
  • 5
  • 35
  • 64

2 Answers2

3

If you are running on Amazon Elastic Map Reduce, this will read the master IP address from the jobflow JSON object and parse it out with jq:

jq .masterPrivateDnsName /emr/instance-controller/lib/info/job-flow.json
vy32
  • 28,461
  • 37
  • 122
  • 246
2

You could use:

yarn node -list |& sed 's/.*ip-\([^.]*\).*/\1/g'

where |& is a shorthand for 2>&1. This returns:

10-1-0-238
builder-7000
  • 7,131
  • 3
  • 19
  • 43