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
Contributor

Thank you very much @Roland Simonis

I had the same problem (reinstalled a slave from scratch, and decommisioned via Ambari both DN and NM) but Ambari doesn't have a GUI option for recommissioning the NM, so the ResourceManager was always denying access. With the API call you posted I easily recommissioned the NM and now everything is working again as expected.

Thanks!

avatar
New Contributor

In ambari version AMBARI-2.5.1.7 we needed to do another step after recommissioning steps above mentioned. The nodemanger was going to stopped state after the recommissioning call. Needed to change the state from installed to started.

curl -u user:pass -i -H 'X-Requested-By: ambari' -X PUT -d '{"HostRoles": {"state": "STARTED"}}' http://{$ambari_master_host}:{$ambari_master_port}/api/v1/clusters/{$clustername}hosts/{$host}/host_...;

Same steps are followed by the ambari server when doing the recommission. PFA the logs

// Recomission ( Decommission with include host )

14 Feb 2018 13:28:23,479 INFO [ambari-client-thread-75749] AmbariManagementControllerImpl:3984 - Received action execution request, clusterName=xxxx , request=isCommand :true, action :null, command :DECOMMISSION, inputs :{included_hosts=xxxx, slave_type=NODEMANAGER}, resourceFilters: [RequestResourceFilter{serviceName='YARN', componentName='RESOURCEMANAGER', hostNames=[]}], exclusive: false, clusterName :xxxx

14 Feb 2018 13:28:23,488 INFO [ambari-client-thread-75749] AmbariCustomCommandExecutionHelper:967 - Recommissioning NODEMANAGER and marking Maintenance=OFF on xxx

14 Feb 2018 13:28:32,906 INFO [qtp-ambari-agent-75726] HeartBeatHandler:332 - HeartBeatHandler.sendCommands: sending ExecutionCommand for host xxx role RESOURCEMANAGER, roleCommand CUSTOM_COMMAND, and command ID 25366-0, task ID 45097

// Ambari changes state from Started to Installed

14 Feb 2018 13:28:44,295 INFO [ambari-heartbeat-processor-0] HeartbeatProcessor:609 - State of service component NODEMANAGER of service YARN of cluster xxx has changed from STARTED to INSTALLED at host xxxx according to STATUS_COMMAND report

14 Feb 2018 13:30:29,889 INFO [ambari-client-thread-75692] AbstractResourceProvider:939 - Received a updateHostComponent request, clusterName=xxx , serviceName=YARN, componentName=NODEMANAGER, hostname=xxxxx request={ clusterName=xxxx , serviceName=YARN, componentName=NODEMANAGER, hostname= xxxx , publicHostname=null, desiredState=STARTED, state=null, desiredStackId=null, staleConfig=null, adminState=null, maintenanceState=null}

// Ambari changes state again from Started to Installed

14 Feb 2018 13:30:29,890 INFO [ambari-client-thread-75692] AbstractResourceProvider:650 - Handling update to host component, clusterName=xxx, serviceName=YARN, componentName=NODEMANAGER, hostname=xxxxx , currentState=INSTALLED, newDesiredState=STARTED

14 Feb 2018 13:30:29,910 INFO [ambari-action-scheduler] ServiceComponentHostImpl:1028 - Host role transitioned to a new state, serviceComponentName=NODEMANAGER, hostName=xxxx oldState=INSTALLED, currentState=STARTING