Support Questions

Find answers, ask questions, and share your expertise

Ambari API to put a node in Maintenance Mode

avatar
New Contributor

I am writing a script to remove a worker node. So I need Ambari api to put the node in maintenance mode before removing host components and deleting the node from the cluster.

1 ACCEPTED SOLUTION

avatar
Master Collaborator

@Christy09  Use the below API to put a node/host in maintenance mode

 

curl -u <Username>:<Password> -H 'X-Requested-By:ambari' -i -X PUT -d '{"RequestInfo":{"context":"Turn On Maintenance Mode for host","query":"Hosts/host_name.in(<HOST_NAME>)"},"Body":{"Hosts":{"maintenance_state":"ON"}}}' http://<AMBARI_HOST>:8080/api/v1/clusters/<CLUSTER_NAME>/hosts

 

Example: 

curl -u admin:<PASSWORD> -H 'X-Requested-By:ambari' -i -X PUT -d '{"RequestInfo":{"context":"Turn On Maintenance Mode for host","query":"Hosts/host_name.in(c486-node2.coelab.cloudera.com)"},"Body":{"Hosts":{"maintenance_state":"ON"}}}' http://c486-node1.coelab.cloudera.com:8080/api/v1/clusters/c486/hosts

 

 

View solution in original post

1 REPLY 1

avatar
Master Collaborator

@Christy09  Use the below API to put a node/host in maintenance mode

 

curl -u <Username>:<Password> -H 'X-Requested-By:ambari' -i -X PUT -d '{"RequestInfo":{"context":"Turn On Maintenance Mode for host","query":"Hosts/host_name.in(<HOST_NAME>)"},"Body":{"Hosts":{"maintenance_state":"ON"}}}' http://<AMBARI_HOST>:8080/api/v1/clusters/<CLUSTER_NAME>/hosts

 

Example: 

curl -u admin:<PASSWORD> -H 'X-Requested-By:ambari' -i -X PUT -d '{"RequestInfo":{"context":"Turn On Maintenance Mode for host","query":"Hosts/host_name.in(c486-node2.coelab.cloudera.com)"},"Body":{"Hosts":{"maintenance_state":"ON"}}}' http://c486-node1.coelab.cloudera.com:8080/api/v1/clusters/c486/hosts