Support Questions
Find answers, ask questions, and share your expertise

How to get backup hmaster in Hbase HA mode in ambari using command

Solved Go to solution
Highlighted

How to get backup hmaster in Hbase HA mode in ambari using command

Hi, guys, I am tryign to write a autotest shell script killing the hmasters in HA mode, do you know how can I get the backup hmaster host address by using the command? I can manully find it in the ambari UI, but can not locate it by using the command

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

Re: How to get backup hmaster in Hbase HA mode in ambari using command

Expert Contributor

@Qinglin Xia

This can be achieved with single Ambari REST API as @yusaku suggested. Following is the actual working API

{
  "href" : "http://c6401.ambari.apache.org:8080/api/v1/clusters/c1/components/HBASE_MASTER?host_components/metrics/hbase/master/IsActiveMaster=true&fields=host_components/HostRoles/host_name",
  "ServiceComponentInfo" : {
    "cluster_name" : "c1",
    "component_name" : "HBASE_MASTER",
    "service_name" : "HBASE"
  },
  "host_components" : [
    {
      "href" : "http://c6401.ambari.apache.org:8080/api/v1/clusters/c1/hosts/c6401.ambari.apache.org/host_components/HBASE_MASTER",
      "HostRoles" : {
        "cluster_name" : "c1",
        "component_name" : "HBASE_MASTER",
        "host_name" : "c6401.ambari.apache.org"
      },
      "metrics" : {
        "hbase" : {
          "master" : {
            "IsActiveMaster" : "true"
          }
        }
      }
    }
  ]
}

View solution in original post

6 REPLIES 6
Highlighted

Re: How to get backup hmaster in Hbase HA mode in ambari using command

Super Mentor

@Qinglin Xia

You can use the Ambari APIs to find that out using simple "curl" GET you should be able to find the Active HBase Master:

http://erie1.example.com:8080/api/v1/clusters/ErieCluster/components/HBASE_MASTER?ServiceComponentIn...

Example Output:

{
  "href" : "http://erie1.example.com:8080/api/v1/clusters/ErieCluster/components/HBASE_MASTER?ServiceComponentInfo/category=MASTER&fields=ServiceComponentInfo/service_name,host_components/HostRoles/display_name,host_components/metrics/hbase/master/IsActiveMaster",
  "ServiceComponentInfo" : {
    "category" : "MASTER",
    "cluster_name" : "ErieCluster",
    "component_name" : "HBASE_MASTER",
    "service_name" : "HBASE"
  },
  "host_components" : [
    {
      "href" : "http://erie1.example.com:8080/api/v1/clusters/ErieCluster/hosts/erie3.example.com/host_components/HBASE_MASTER",
      "HostRoles" : {
        "cluster_name" : "ErieCluster",
        "component_name" : "HBASE_MASTER",
        "display_name" : "HBase Master",
        "host_name" : "erie3.example.com"
      },
      "metrics" : {
        "hbase" : {
          "master" : {
            "IsActiveMaster" : "false"
          }
        }
      }
    },
    {
      "href" : "http://erie1.example.com:8080/api/v1/clusters/ErieCluster/hosts/erie4.example.com/host_components/HBASE_MASTER",
      "HostRoles" : {
        "cluster_name" : "ErieCluster",
        "component_name" : "HBASE_MASTER",
        "display_name" : "HBase Master",
        "host_name" : "erie4.example.com"
      },
      "metrics" : {
        "hbase" : {
          "master" : {
            "IsActiveMaster" : "true"
          }
        }
      }
    }
  ]
}

Notice:

 "IsActiveMaster" : "false"

.

Highlighted

Re: How to get backup hmaster in Hbase HA mode in ambari using command

Super Mentor

@Qinglin Xia

More easy command to access this info using curl by hitting the URL:

http://erie1.example.com:8080/api/v1/clusters/ErieCluster/hosts/erie3.example.com/host_components/HB...

 curl -u admin:admin -H "X-Requested-By: ambari"  -X GET http://erie1.example.com:8080/api/v1/clusters/ErieCluster/hosts/erie4.example.com/host_components/HB...


{
  "href" : "http://erie1.example.com:8080/api/v1/clusters/ErieCluster/hosts/erie4.example.com/host_components/HBASE_MASTER?fields=metrics/hbase/master/IsActiveMaster",
  "HostRoles" : {
    "cluster_name" : "ErieCluster",
    "component_name" : "HBASE_MASTER",
    "host_name" : "erie4.example.com"
  },
  "host" : {
    "href" : "http://erie1.example.com:8080/api/v1/clusters/ErieCluster/hosts/erie4.example.com"
  },
  "metrics" : {
    "hbase" : {
      "master" : {
        "IsActiveMaster" : "true"
      }
    }
  }
}

.

Re: How to get backup hmaster in Hbase HA mode in ambari using command

Contributor

You should also be able to specify the condition IsActiveMaster=false to have the API respond with non-active HBaseMasters only. Instead of saying "fields=metrics/hbase/master/IsActiveMaster" in the query, you can turn that into a predicate by saying "metrics/hbase/master/IsActiveMaster=false".

Highlighted

Re: How to get backup hmaster in Hbase HA mode in ambari using command

Expert Contributor

@Qinglin Xia

This can be achieved with single Ambari REST API as @yusaku suggested. Following is the actual working API

{
  "href" : "http://c6401.ambari.apache.org:8080/api/v1/clusters/c1/components/HBASE_MASTER?host_components/metrics/hbase/master/IsActiveMaster=true&fields=host_components/HostRoles/host_name",
  "ServiceComponentInfo" : {
    "cluster_name" : "c1",
    "component_name" : "HBASE_MASTER",
    "service_name" : "HBASE"
  },
  "host_components" : [
    {
      "href" : "http://c6401.ambari.apache.org:8080/api/v1/clusters/c1/hosts/c6401.ambari.apache.org/host_components/HBASE_MASTER",
      "HostRoles" : {
        "cluster_name" : "c1",
        "component_name" : "HBASE_MASTER",
        "host_name" : "c6401.ambari.apache.org"
      },
      "metrics" : {
        "hbase" : {
          "master" : {
            "IsActiveMaster" : "true"
          }
        }
      }
    }
  ]
}

View solution in original post

Highlighted

Re: How to get backup hmaster in Hbase HA mode in ambari using command

Highlighted

Re: How to get backup hmaster in Hbase HA mode in ambari using command

Super Mentor

@Qinglin Xia

Additionally if you due to some reason if the Ambari is down (not accessible) and still if you want to get the Active HBase Master detail then you can simply use the HBase JMX for the same. Here "16010" is HBase JMX ui port.

Exampe:

$ curl -v --silent 'http://erie4.example.com:16010/jmx?qry=Hadoop:service=HBase,name=Master,sub=Server'  2>&1 | grep isActiveMaster
    "tag.isActiveMaster" : "true",


$ curl -v --silent 'http://erie3.example.com:16010/jmx?qry=Hadoop:service=HBase,name=Master,sub=Server'  2>&1 | grep isActiveMaster
    "tag.isActiveMaster" : "false",