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 to stop all data node services by REST API

Highlighted

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

 

Capture.PNG

 

Capture1.PNG

 

example of the full services on each worker machine:

 

Capture.PNG

Michael-Bronson
5 REPLIES 5

Re: how to stop all data node services by REST API

Super Mentor

@mike_bronson7 
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 "dn1.example.com, dn2.example.com, dn3.example.com" 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/host_name.in(dn1.example.com,dn2.example.com,dn3.example.com)&HostRoles/maintenance_state=OFF"},"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.

Highlighted

Re: how to stop all data node services by REST API

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?

Michael-Bronson
Highlighted

Re: how to stop all data node services by REST API

Dear Jay

 

lets say we want to set instead

 

 

dn1.example.com,dn2.example.com,dn3.example.com

 

 

we want to set variable

 

all_DN_machines=dn1.example.com,dn2.example.com,dn3.example.com

 

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

Michael-Bronson
Highlighted

Re: how to stop all data node services by REST API

Super Mentor
Highlighted

Re: how to stop all data node services by REST API

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

Michael-Bronson
Don't have an account?
Coming from Hortonworks? Activate your account here