With Apache Ambari we can achieve ease of management and administration of Apache Hadoop clusters. But it has it’s own limitations for now. We are going to discuss one of its limitations here – Removing or Deleting a service.

Apache Ambari Overview

Apache Ambari is a framework able to provision, manage, and monitor Apache Hadoop deployments. It includes tools and a robust set of APIs. We have an extensive discussion on Apache Ambari here.

apache-ambari-project

Apache Hadoop & Apache Ambari

Ambari is a completely open-source tool which is its biggest advantage. This means we have a number of contributors helping Ambari become a better and more robust framework tool. Ambari provides a platform framework which you can use to provision, manage, and monitor a Hadoop cluster.

Hadoop

Ambari provides the tools to simplify the cluster management. The web interface allows you to modify the configurations and manage the cluster growth. It also allows you to manage and control the entire lifecycle of a Hadoop services and components. However as we mentioned in the beginning of this article – Apache Ambari does have some limitations. One of the limitations is removing or deleting a service.

Before I proceed I would like to mention that the focus here is to remove or delete a service completely. We will not be focusing on the importance or relevance of any given service to a Apache Hadoop cluster.

Remove or Delete Service from Ambari

Adding a service to your Apache Hadoop cluster has been really simplified by Apache Ambari. Once you have the service in the stack for Ambari all you need is to click from the Web interface for Ambari to add the service. It will walk you through the various configurations required for the service.

Now how can we remove a service from the Apache Hadoop cluster which is managed by Ambari?

The answer is – using REST APIs for Ambari.

With web interface for Ambari is still evolving. The REST APIs helps you makeup for the missing functionalities in the Web Interface for Apache Ambari.

We will use an example for removing the HBase service from my lab cluster in order to provide the examples going forward.

The process will involve the following steps:

  • Identify the different components for the service.
  • Identify the hosts where the components are running.
  • Stop the service.
  • Stop the components of service, if required.
  • Delete the service using DELETE API Call.

While using the Ambari REST APIs I will be using random cluster name and hostnames. Please make sure that you replace them with values pertaining to your environment.

Identify Service Components

I will begin with identifying the components which are running under HBase on my Apache Hadoop cluster.

The following is the command that I will be using:

curl -s -u admin:admin -H “X-Requested-By: Ambari” -X GET http://localhost:8080/api/v1/clusters/LAB_CLUSTER/services/HBASE

In the above command you will have to replace some of the values with the ones relevant to your environment.

Like,

localhost - With the address for Ambari host.
admin:admin - With the username and password for Ambari Web Interface.
LAB_CLUSTER - With the target Apache Hadoop cluster name in Ambari.
HBASE - With the service name you want to query for.

The above command will provide the list of various components involved in this service. The output will be in a JSON format, so you can use some JSON parsers to parse some output if you need to.

In my case, I have HBASE_MASTER, HBASE_REGIONSERVER & HBASE_CLIENT.

Identify Hosts for Service

This step is not of any relevance if the service stops gracefully. You will need the hosts where certain components are running in case some component(s) do not stop for any reason.

Here you will have to query individual service component to find the hosts associated with the components. In my example, if I have to find the host running the HBASE_MASTER component I will use the following command:

curl -s -u admin:admin -H “X-Requested-By: Ambari” -X GET http://localhost:8080/api/v1/clusters/LAB_CLUSTER/services/HBASE/components/HBASE_MASTER

You will have to repeat this for each service component if you need to identify the host where the service component is running.

Stop Service & Components

Time to stop the service now. You can use the Web Interface for Ambari to stop the service. However I prefer to use the command line. The API does allow you to start as well as stop a service.

The following is the command to stop the service.

curl -s -u admin:admin -H “X-Requested-By: Ambari” -X PUT -d ‘{“RequestInfo”:{“context”:”Stop Service”},”Body”:{“ServiceInfo”:{“state”:”INSTALLED”}}}’ http://AMBARI-HOST:8080/api/v1/clusters/CLUSTER_NAME/services/SERVICE_NAME

In my case I will use the following command to stop the service.

curl -s -u admin:admin -H “X-Requested-By: Ambari” -X PUT -d ‘{“RequestInfo”:{“context”:”Stop HBASE”},”Body”:{“ServiceInfo”:{“state”:”INSTALLED”}}}’ http://localhost:8080/api/v1/clusters/LAB_CLUSTER/services/HBASE

Verify that the service and its components are stopped. If for some reason certain service components aren’t stopped you can run the following command to stop them on their respective hosts.

curl -s -u admin:admin -H “X-Requested-By: Ambari” -X PUT -d ‘{“RequestInfo”:{“context”:”Stop Component”},”Body”:{“HostRoles”:{“state”:”INSTALLED”}}}’ http://AMBARI-HOST:8080/api/v1/clusters/CLUSTER_NAME/hosts/HOST_NAME/host_components/SERVICE_COMPONENT_NAME

Make sure you replace the AMBARI-HOST, HOST_NAME & SERVICE_COMPONENT_NAME with the one relevant to you.

Delete Service

Finally time to delete the service. This can be done by running the DELETE API call against the REST API for Ambari.

The following is the syntax.

curl -s -u admin:admin -H “X-Requested-By: Ambari” -X DELETE http://AMBARI-HOST:8080/api/v1/clusters/CLUSTER_NAME/services/SERVICE_NAME

Continuing our example, we will use the following command here.

curl -s -u admin:admin -H “X-Requested-By: Ambari” -X DELETE http://localhost:8080/api/v1/clusters/LAB_CLUSTER/services/HBASE

That should remove the service from your Ambari managed Hadoop cluster.

Please make sure that you modify the monitoring services/tools (like Nagios) to remove the service checks. As this procedure does not take care of it. You may have your own Nagios server or the one provided by Ambari. The removal of the service checks from monitoring tools is to be accomplished manually.