Created on 01-14-2021 02:25 PM - edited 01-14-2021 03:08 PM
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.
Created 01-14-2021 08:13 PM
@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
Created 01-14-2021 08:13 PM
@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