Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

Rest api to get host address in which particular service is installed ?

Rest api to get host address in which particular service is installed ?

How to get host address for particular service (like hbase, hive, ..etc) installed ?

2 REPLIES 2
Highlighted

Re: Rest api to get host address in which particular service is installed ?

@Anurag Mishra

this is sample curl request to get information of zookeeper service, hope this will serve your purpose

curl -u admin:admin -H "X-Requested-By: ambari" -X GET http://<AMBARI_HOST>:8080/api/v1/clusters/<CLUSTERNAME>/services/ZOOKEEPER

Re: Rest api to get host address in which particular service is installed ?

Super Mentor

@Anurag Mishra

Services are not installed on hosts, Instead the Components are installed on individual hosts.

For example HDFS is service name, But actually it's components like "NameNode", "DataNode", "JournalNode" ...etc are installed on individual hosts.

You can get the list of components installed on a particular host using the following API:

To get the list of hosts of your cluster.

http://$AMBARI_HOST:8080/api/v1/clusters/$CLUSTER_NAME/hosts/

To get the list of components installed on $HOSTNAME

http://$AMBARI_HOST:8080/api/v1/clusters/$CLUSTER_NAME/hosts/$HOSTNAME/host_components

Another approach will be to use the following call:

Syntax:

curl -u admin:admin -H "X-Requested-By: ambari" -X GET  http://$AMBARI_HOST:8080/api/v1/clusters/$CLUSTER_NAME/services/HDFS/components/NAMENODE?fields=host...

Example:

curl -u admin:admin -H "X-Requested-By: ambari" -X GET  http://amb25101.example.com:8080/api/v1/clusters/plain_ambari/services/HDFS/components/NAMENODE?fiel...

.

Example Output: (Find All the Host that have "NameNode" Installed)

curl -u admin:admin -H "X-Requested-By: ambari" -X GET  http://amb25101.example.com:8080/api/v1/clusters/plain_ambari/services/HDFS/components/NAMENODE?fiel...
{
  "href" : "http://amb25101.example.com:8080/api/v1/clusters/plain_ambari/services/HDFS/components/NAMENODE?fields=host_components/HostRoles/host_name",
  "ServiceComponentInfo" : {
    "cluster_name" : "plain_ambari",
    "component_name" : "NAMENODE",
    "service_name" : "HDFS"
  },
  "host_components" : [
    {
      "href" : "http://amb25101.example.com:8080/api/v1/clusters/plain_ambari/hosts/amb25101.example.com/host_components/NAMENODE",
      "HostRoles" : {
        "cluster_name" : "plain_ambari",
        "component_name" : "NAMENODE",
        "host_name" : "amb25101.example.com"
      }
    },
    {
      "href" : "http://amb25101.example.com:8080/api/v1/clusters/plain_ambari/hosts/amb25102.example.com/host_components/NAMENODE",
      "HostRoles" : {
        "cluster_name" : "plain_ambari",
        "component_name" : "NAMENODE",
        "host_name" : "amb25102.example.com"
      }
    }
  ]
}

.

Similarly the following API can be used to find DATANODE is installed on what all nodes:

curl -u admin:admin -H "X-Requested-By: ambari" -X GET  http://amb25101.example.com:8080/api/v1/clusters/plain_ambari/services/HDFS/components/DATANODE?fiel...

.

Don't have an account?
Coming from Hortonworks? Activate your account here