Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Highlighted the note on backup / decommissioning

At times you may need to delete a service or all host components on a host. This article talks about how to do that using APIs. Be aware of losing data when performing any delete operations. Ensure that your data is backed up and decommissioning of nodes are performed as needed.

From 1.4.3 onwards you need to add "X-Requested-By" header to all curl calls.

E.g. curl -i -uadmin:admin -H "X-Requested-By: ambari" -d '{"HostRoles": { "state": "STARTED"}}' -X PUT 'http://localhost:8080/api/v1/clusters/c1/host_components?HostRoles/stale_configs=false

Removing a Service (2.1.

...

0)

Verified against releases 2.1.

...

0

Note: These API calls do not uninstall the packages associated with the service and neither they remove the config or temp folders associated with the service components. 

...

Code Block
 curl -u admin:admin -H "X-Requested-By: ambari" -X GET  http://AMBARI_SERVER_HOST:8080/api/v1/clusters/c1/services/SERVICENAME

...

Code Block
 curl -u admin:admin -H "X-Requested-By: ambari" -X PUT -d '{"RequestInfo":{"context":"Stop Service"},"Body":{"ServiceInfo":{"state":"INSTALLED"}}}' http://AMBARI_SERVER_HOST:8080/api/v1/clusters/c1/services/SERVICE_NAME

...

Code Block
 curl -u admin:admin -H "X-Requested-By: ambari" -X PUT -d '{"RequestInfo":{"context":"Stop Component"},"Body":{"HostRoles":{"state":"INSTALLED"}}}' http://AMBARI_SERVER_HOST:8080/api/v1/clusters/c1/hosts/HOSTNAME/host_components/COMPONENT_NAME

Stop all component instances (ensure correct values are provided for AMBARI_SERVER_HOST, SERVICE_NAME, COMPONENT_NAME) - just another way to stop Service members:

Code Block
 curl -u admin:admin -H "X-Requested-By: ambari" -X PUT -d '{"RequestInfo":{"context":"Stop All Components"},"Body":{"ServiceComponentInfo":{"state":"INSTALLED"}}}' http://AMBARI_SERVER_HOST:8080/api/v1/clusters/c1/services/SERVICE_NAME/components/COMPONENT_NAME

 

3. Delete the whole SERVICE

Code Block
 curl -u admin:admin -H "X-Requested-By: ambari" -X DELETE  http://AMBARI_SERVER_HOST:8080/api/v1/clusters/c1/services/SERVICENAME

...

Code Block
 curl -u admin:admin -X DELETE  http://AMBARI_SERVER_HOST:8080/api/v1/clusters/c1/services/SERVICENAME

Removing a Host (2.1.

...

0)

Verified against releases 2.1.

...

0

The preferred way to remove a host is to move the master services from the host, decommission the slave nodes and then remove the host after deleting all the host components. However, there are situations such as the host is lost and cannot be brought back online for graceful removal. Under this circumstances the following API calls can be used to clean up the host. 

...

Code Block
 curl -u admin:admin -H "X-Requested-By: ambari" -X GET  http://AMBARI_SERVER_HOST:8080/api/v1/clusters/c1/hosts/HOSTNAME

...

Code Block
 E.g. Delete DATANODE
curl -u admin:admin -H "X-Requested-By: ambari" -X DELETE http://AMBARI_SERVER_HOST:8080/api/v1/clusters/CLUSTERNAME/hosts/HOSTNAME/host_components/DATANODE

...

Code Block
curl -u admin:admin -H "X-Requested-By: ambari" -X DELETE http://AMBARI_SERVER_HOST:8080/api/v1/clusters/CLUSTERNAME/hosts/HOSTNAME