Support Questions
Find answers, ask questions, and share your expertise

how to stop all data node services by REST API

hi all



is it possible to stop only the data node services on all datanodes machines?


in the following example , we can see example of datanode service from worker machine


and the 3/3 datanodes services






example of the full services on each worker machine:




Super Mentor

You can try this.

1. Get the list of DataNode hosts. When you can get like following:

# curl -s -u admin:admin -H "X-Requested-By: ambari" -X GET http://$AMBARI_FQDN:8080/api/v1/clusters/CLUSTER_NAME/services/HDFS/components/DATANODE | grep 'host_name'

2. The. run the following kind of API call by passing the hostnames where the datanode are running. Suppose datanodes are running on 3 Hosts with name ",," then you can do the following:

# curl -s -u admin:admin -H "X-Requested-By: ambari" -X PUT -d '{"RequestInfo":{"context":"Stop DataNodes","operation_level":{"level":"SERVICE","cluster_name":"$CLUSTER_NAME"},"query":"HostRoles/component_name=DATANODE&HostRoles/,,"},"Body":{"HostRoles":{"state":"INSTALLED"}}}' "h ttp://$AMBARI_FQDN:8080/api/v1/clusters/$CLUSTER_NAME/host_components"


Please replace all $CLUSTER_NAME and $AMBARI_FQDN accordingly.

Dear Jay , give me some time I will verify the API on my cluster


is it possible to use the API from your answer , to stop all NodeManager on all workers machines?


Dear Jay


lets say we want to set instead,,



we want to set variable,,


so the val - $all_DN_machines will be instead of all real machines - is it possible ? 


Super Mentor

Dear Jay - can we use this API to stop all NodeManager  on all workers machines ? if yes , can you show me please how ? 

; ;