Ambari Delete or Remove Service

Ambari Delete or Remove Service

The Ambari UI for 1.7 does not provide any option to remove a service from the cluster.

However, if you want to do that a good way to accomplish that is to use the Ambari API.

The process is straightforward:

  • Identify the hosts associated with the service where the service components are running.
  • Stop the service in question.
  • Stop the individual service components from the hosts.
  • Delete the service.

Ambari Delete or Remove Service

Let’s look at the process.

  • Identify all the Hosts associated with the service

Run the following to ensure find the list of hosts running the components:

curl -u admin:admin -H “X-Requested-By: ambari” -X GET http://AMBARI_SERVER_HOST:8080/api/v1/clusters/c1/services/SERVICE_NAME

Where,

Replace “admin:admin” with the username and password for your Ambari installation.
Replace “AMBARI_SERVER_HOST” with the host address for your Ambari server.
Replace “c1” with the cluster under which the service is to be removed.
Replace “SERVICE_NAME” with the service you want to remove.

Going forward, you have to make sure you replace these values based on your Ambari and Hadoop cluster installation.

I will take an example of HBASE in my case.

[[email protected] ~]# curl -u admin:admin -H “X-Requested-By: ambari” -X GET http://localhost:8080/api/v1/clusters/HDP2/services/HBASE

You now “may” have to query the individual component to find the actual host they are running on.

For instance in my case, I found HBASE_CLIENT, HBASE_MASTER & HBASE_REGIONSERVER. I will have to query each of this component to find the hosts they are running on.

[[email protected] ~]# curl -u admin:admin -H “X-Requested-By: ambari” -X GET http://localhost:8080/api/v1/clusters/HDP2/services/HBASE/components/HBASE_CLIENT

Ambari Delete or Remove Service

  • Stop the service in question

Using Ambari API, stop the service you want to remove.

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

In my case I used the following:

[[email protected] ~]# curl -u admin:admin -H “X-Requested-By: ambari” -X PUT -d ‘{“RequestInfo”:{“context”:”Stop Service”},”Body”:{“ServiceInfo”:{“state”:”INSTALLED”}}}’ http://localhost:8080/api/v1/clusters/HDP2/services/HBASE

Ambari Delete or Remove Service

  • Stop the individual service components from the hosts

Stop all the individual components for the service running on different hosts.

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/HOST_NAME/host_components/COMPONENT_NAME

Where,

Replace “HOST_NAME” with the actual host you want to remove the component from.
Replace “COMPONENT_NAME” with the host component which is running on the specific host (found in the host list earlier).

You can perform the above using the following command as well:

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

Ambari Delete or Remove Service

  • Delete the service

Finally, let’s delete or remove the service from Ambari

You need to run the following API call.

curl -u admin:admin -H “X-Requested-By: ambari” -X DELETE http://AMBARI_SERVER_HOST:8080/api/v1/clusters/c1/services/SERVICE_NAME

That should do it for you.

Refresh the Ambari UI and the service should be gone.

Ambari Delete or Remove Service

3 Comments

Post a Comment

Time limit is exhausted. Please reload CAPTCHA.