简体   繁体   中英

How to run script on specific instance group in EMR

I am stuck with a task, where I have to run 1 script only on Task instance group instances.

My current approach-

For this, I passes script as a Bootstrap Actions while cluster launch, but it run scripts on all machines. (master, core, task instance groups).

Can you please help me to run that script only on specific(task) instance group ?

Actual task is to run termination notice polling script on task instance groups instances. - https://blog.fugue.co/2015-01-06-spot-termination-notices.html

You can look at the file /mnt/var/lib/info/extraInstanceData.json which contains the key instanceRole value which is either master, core or task. For example, add this to your script:

INSTANCE_ROLE=$(jq .instanceRole /mnt/var/lib/info/extraInstanceData.json)

Or, you can use this file /mnt/var/lib/info/instance.json that exists on any node in the cluster, it looks like this:

  {
    "instanceGroupId": "ig-XXXXXXXXXX",
    "isMaster": false
  }

You can match the ig-XXXXXXXXXX to your cluster's TASK group ID.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM