Decommission and recommission in Ambari API

It’s pretty easy to find how to decommission something in Ambari API.

For example, let’s decommission a datanode :

curl -u admin:admin -i -H 'X-Requested-By: ambari' -X POST -d '{
"RequestInfo":{
"context":"Decommission DataNodes dn1,dn2",
"command":"DECOMMISSION",
"parameters":{
"slave_type":"DATANODE",
"excluded_hosts":"dn1.example.com,dn2.example.com"
},
"operation_level":{
"level":"HOST_COMPONENT",
"cluster_name":"MY_CLUSTER"
}
},
"Requests/resource_filters":[
{
"service_name":"HDFS",
"component_name":"NAMENODE"
}
]
}' http://gw.example.com:8080/api/v1/clusters/MY_CLUSTER/requests

 

I then tried to recommission these datanodes using the “RECOMMISSION” command, and it failed.

The thing here is to change excluded_hosts (which is the list of hosts to be decommissioned), for included_hosts.

 

curl -u admin:admin -i -H 'X-Requested-By: ambari' -X POST -d '{
"RequestInfo":{
"context":"Recommission DataNodes dn1,dn2",
"command":"DECOMMISSION",
"parameters":{
"slave_type":"DATANODE",
"included_hosts":"dn1.example.com,dn2.example.com"
},
"operation_level":{
"level":"HOST_COMPONENT",
"cluster_name":"MY_CLUSTER"
}
},
"Requests/resource_filters":[
{
"service_name":"HDFS",
"component_name":"NAMENODE"
}
]
}' http://gw.example.com:8080/api/v1/clusters/MY_CLUSTER/requests

4 Comments

  • Reply Prasad |

    curl -u admin:admin -i -H ‘X-Requested-By: ambari’ -X POST -d ‘{
    “RequestInfo”:{
    “context”:”Recommission DataNodes dn1,dn2″,
    “command”:”RECOMMISSION”,
    “parameters”:{
    “slave_type”:”DATANODE”,
    “included_hosts”:”dn1.example.com,dn2.example.com”
    },
    “operation_level”:{
    “level”:”HOST_COMPONENT”,
    “cluster_name”:”MY_CLUSTER”
    }
    },
    “Requests/resource_filters”:[
    {
    “service_name”:”HDFS”,
    “component_name”:”NAMENODE”
    }
    ]
    }’ http://gw.example.com:8080/api/v1/clusters/MY_CLUSTER/requests

    I thought it may work, i have the same requirement. I didn’t find any doc in google and didn’t get response from hotonworks blog.

  • Reply Vincent |

    Thanks for the curl to recommission a node.
    You have a typo in your recommission code, it’s included_hosts instead of excluded_hosts

    Thanks

    • Reply administrator |

      thanks Vincent, I said that in the comment and missed the most important, the code !
      corrected.

So, what do you think ?

  • Time limit is exhausted. Please reload CAPTCHA.