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 (1.4.1)
...
1. Note all the host components associated with the service.
Code Block |
---|
curl -u admin:admin -X GET http://AMBARI_SERVER_HOST:8080/api/v1/clusters/c1/services/SERVICENAME
|
...
Stop the whole service (ensure correct values are provided for AMBARI_SERVER_HOST, SERVICE_NAME):
Code Block |
---|
curl -u admin:admin -X PUT -d '{"RequestInfo":{"context":"Stop Service"},"Body":{"ServiceInfo":{"state":"INSTALLED"}}}' http://AMBARI_SERVER_HOST:8080/api/v1/clusters/c1/services/SERVICE_NAME
|
Stop individual components (ensure correct values are provided for AMBARI_SERVER_HOST, HOSTNAME, COMPONENT_NAME):
Code Block |
---|
curl -u admin:admin -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
|
3. Delete the whole SERVICE
Code Block |
---|
curl -u admin:admin -X DELETE http://AMBARI_SERVER_HOST:8080/api/v1/clusters/c1/services/SERVICENAME
|
...
1. Note all the host components associated with the service.
Code Block |
---|
curl -u admin:admin -X GET http://AMBARI_SERVER_HOST:8080/api/v1/clusters/c1/services/SERVICENAME
|
...
Stop the whole service (ensure correct values are provided for AMBARI_SERVER_HOST, SERVICE_NAME):
Code Block |
---|
curl -u admin:admin -X PUT -d '{"RequestInfo":{"context":"Stop Service"},"Body":{"ServiceInfo":{"state":"INSTALLED"}}}' http://AMBARI_SERVER_HOST:8080/api/v1/clusters/c1/services/SERVICE_NAME
|
Stop individual components (ensure correct values are provided for AMBARI_SERVER_HOST, HOSTNAME, COMPONENT_NAME):
Code Block |
---|
curl -u admin:admin -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
|
3. Put MASTER and SLAVE components into MAINTENANCE mode
Code Block |
---|
curl -u admin:admin -X PUT -d '{"HostRoles": {"state": "MAINTENANCE"}}' http://AMBARI_SERVER_HOST:8080/api/v1/clusters/c1/hosts/HOSTNAME/host_components/COMPONENTNAME
|
4. Delete MASTER and SLAVE components
Code Block |
---|
curl -u admin:admin -X DELETE http://AMBARI_SERVER_HOST:8080/api/v1/clusters/c1/hosts/HOSTNAME/host_components/COMPONENTNAME
|
5. Delete the whole SERVICE
Code Block |
---|
curl -u admin:admin -X DELETE http://AMBARI_SERVER_HOST:8080/api/v1/clusters/c1/services/SERVICENAME
|
...
1. Get a list of host components mapped to the host
Code Block |
---|
curl -u admin:admin -X GET http://AMBARI_SERVER_HOST:8080/api/v1/clusters/c1/hosts/HOSTNAME
|
See the property, "host_components" for all the host.
Sample:
Code Block |
---|
Output:
...
"host_components" : [
{
"href" : "http://AMBARI_SERVER_HOST:8080/api/v1/clusters/CLUSTERNAME/hosts/HOSTNAME/host_components/DATANODE",
"HostRoles" : {
"cluster_name" : "CLUSTERNAME",
"component_name" : "DATANODE",
"host_name" : "HOSTNAME"
}
},
{
"href" : "http://AMBARI_SERVER_HOST:8080/api/v1/clusters/CLUSTERNAME/hosts/HOSTNAME/host_components/GANGLIA_MONITOR",
"HostRoles" : {
"cluster_name" : "CLUSTERNAME",
"component_name" : "GANGLIA_MONITOR",
"host_name" : "HOSTNAME"
}
}]
...
|
2. DELETE all host components mapped to this host
Code Block |
---|
E.g. Delete DATANODE
curl -u admin:admin -X DELETE http://AMBARI_SERVER_HOST:8080/api/v1/clusters/CLUSTERNAME/hosts/HOSTNAME/host_components/DATANODE
|
3. DELETE the host
Code Block |
---|
curl -u admin:admin -X DELETE http://AMBARI_SERVER_HOST:8080/api/v1/clusters/CLUSTERNAME/hosts/HOSTNAME
|