Support Questions

Find answers, ask questions, and share your expertise

How can i recommission Node managers and Data nodes through REST API?

avatar
Expert Contributor
curl -u admin:admin -i -H 'X-Requested-By: ambari' -X POST -d '{
"RequestInfo":{
"context":"Recommission DataNodes",
"command":"RECOMMISSION",
"parameters":{
"slave_type":"DATANODE",
"included_hosts":"c6401.ambari.apache.org,c6402.ambari.apache.org,c6403.ambari.apache.org"
},
"operation_level":{
"level":"HOST_COMPONENT",
"cluster_name":"c1"
}
},
"Requests/resource_filters":[
{
"service_name":"HDFS",
"component_name":"NAMENODE"
}
]
}' http://localhost:8080/api/v1/clusters/c1/requests

curl -u admin:admin -i -H 'X-Requested-By: ambari' -X POST -d '{
"RequestInfo":{
"context":"Recommission NodeManagers",
"command":"RECOMMISSION",
"parameters":{
"slave_type":"NODEMANAGER",
"included_hosts":"c6401.ambari.apache.org,c6402.ambari.apache.org,c6403.ambari.apache.org"
},
"operation_level":{
"level":"HOST_COMPONENT",
"cluster_name":"c1"
}
},
"Requests/resource_filters":[
{
"service_name":"YARN",
"component_name":"RESOURCEMANAGER"
}
]
}' http://localhost:8080/api/v1/clusters/c1/requests

@Artem Ervits .Can i use like this to recommission the data node and nodemanagers? Whcih one has to be excuted first? Datanodes ?

1 ACCEPTED SOLUTION

avatar
Master Mentor

You are becoming an advanced user of Ambari API. Your use case is definitely valid but i dont have an answer for exact steps or whether its even possible. What you can do is setup network capture with wireshark and see api calls ambari makes when you recommission a node. My guess is that that option is not available in API as you typically comission a node as part of adding a new node. So maybe as a workaround you would want to delete a node completely from cluster after decommissioning and then just add new node. Let us know if you do run netcapture.

View solution in original post

11 REPLIES 11

avatar
Master Mentor

You are becoming an advanced user of Ambari API. Your use case is definitely valid but i dont have an answer for exact steps or whether its even possible. What you can do is setup network capture with wireshark and see api calls ambari makes when you recommission a node. My guess is that that option is not available in API as you typically comission a node as part of adding a new node. So maybe as a workaround you would want to delete a node completely from cluster after decommissioning and then just add new node. Let us know if you do run netcapture.

avatar
Expert Contributor

Thank you @Artem Ervits I would like to give a try with the above curl commands, will post the result.

avatar
Master Mentor

Surprise us 🙂

avatar
Expert Contributor

@Artem Ervits Mostly, it wouldn't work because i didn't see any dfs.include and yarn.include parameters in configurations. 🙂

avatar
Master Mentor

Well then decommission, delete, add node is the way to go.

avatar
Expert Contributor

@Artem Ervits I tried to recommission by using above curl command. I got the following error..

"status" : 500, "message" : "An internal system exception occurred: Unsupported action RECOMMISSION for Service: YARN and Component: RESOURCEMANAGER"

avatar
Expert Contributor

@Artem Ervits I am still wondering, whatever we will do through ambari, we can do them through REST api right? Why REST api is having limitiation for RECOMMISSION? Is there any theoretical reason?

avatar
Master Mentor

avatar
Expert Contributor

Just to follow up on this one. You can recomission DataNodes and NodeManagers with the following calls. Replace the variables as needed. You may need to remove the line breaks.

Node Manager

curl -u admin:admin -H 'X-Requested-By:ambari' -X POST -d
'{  
   "RequestInfo":{  
      "context":"Recomissioning of host '$host': Recomission NodeManger via REST-API",
      "operation_level":{  
         "level":"HOST",
         "cluster_name":"'$clustername'",
         "host_name":"'$host'"
      },
      "command":"DECOMMISSION",
      "parameters":{  
         "slave_type":"NODEMANAGER",
         "included_hosts":"'$host'"
      }
   },
   "Requests/resource_filters":[  
      {  
         "service_name":"YARN",
         "component_name":"RESOURCEMANAGER"
      }
   ]
}' "http://$ambariHost:8080/api/v1/clusters/$clustername/requests"

DataNode:

curl -u admin:admin -H 'X-Requested-By:ambari' -X POST -d
'{  
   "RequestInfo":{  
      "context":"Scipt-based Recomissioning of host '$host': Recomission DataNode via REST-API",
      "operation_level":{  
         "level":"HOST",
         "cluster_name":"'$clustername'",
         "host_name":"'$host'"
      },
      "command":"DECOMMISSION",
      "parameters":{  
         "slave_type":"DATANODE",
         "included_hosts":"'$host'"
      }
   },
   "Requests/resource_filters":[  
      {  
         "service_name":"HDFS",
         "component_name":"NAMENODE"
      }
   ]
}' "http://$ambariHost:8080/api/v1/clusters/$clustername/requests"