Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

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

Solved Go to solution
Highlighted

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

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

Accepted Solutions

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

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.

11 REPLIES 11

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

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.

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

Expert Contributor

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

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

Mentor

Surprise us :)

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

Expert Contributor

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

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

Mentor

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

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

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"

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

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?

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

Mentor

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

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"
Don't have an account?
Coming from Hortonworks? Activate your account here