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.

How to determine hiveserver2 automatically?

Highlighted

Re: How to determine hiveserver2 automatically?

Expert Contributor

@Ryan Cicak, I am using CDH api call. Here is it

curl -u admin:admin 'http://localhost:7180/api/v1/clusters/nameservice1/services/HIVE/components/HIVE_SERVER'

when I execute this I dont see anything.

I am not sure if I am entering the right cluster name. Do you know how to double check the cluster name?

Highlighted

Re: How to determine hiveserver2 automatically?

Expert Contributor

Here is the link to cdh api tutorial. If you can help me please ...

http://cloudera.github.io/cm_api/apidocs/v1/index.html

Highlighted

Re: How to determine hiveserver2 automatically?

Highlighted

Re: How to determine hiveserver2 automatically?

Expert Contributor

I get 'cluster name not found'. Do you know any command to find the cluster name.

Highlighted

Re: How to determine hiveserver2 automatically?

Re: How to determine hiveserver2 automatically?

Expert Contributor

Alex Raj

Run

http://cm_server_host:7180/api/v11/clusters

You should get clustername in output.

Highlighted

Re: How to determine hiveserver2 automatically?

Expert Contributor

Thanks. I got the cluster name.

Highlighted

Re: How to determine hiveserver2 automatically?

Expert Contributor

@Alex Raj, you can add this to your script the below command would print the hostname of the hs2server. But you would need to enter the ambari-server host and the clustername for the curl command to work. I do not see any other way to get this working. You would need to change this accordingly for your CDH cluster.

#!/bin/bash

hs2AMbarijsonData="$(curl -s -H \"X-Requested-By:\ ambari\" -X GET -u admin:admin AMbari-serverhost:8080/api/v1/clusters/<clusterName>/services/HIVE/components/HIVE_SERVER 2>&1)"

hs2ServerHost= echo "$jsonData" |grep host_name|awk -F ":" '{print $2}'|awk -F "\"" '{print $2}'

echo $hs2ServerHost;

Highlighted

Re: How to determine hiveserver2 automatically?

Explorer

I'm thinking that you just configure the hiveserver2 information in /etc/profile and let your script read it from the environment. In each cluster, you tweak /etc/profile to have the right configuration. It's pretty typical to configure environment specific information in environment variables. Seems like a nice and simple way, if not completely dynamic (for instance, if you change the hiveserver2 information).

Highlighted

Re: How to determine hiveserver2 automatically?

Expert Contributor

Thanks @Paul Boal , but I can't configure those information because in the near future if the ip gets changed, it would cause a huge impact because the scripts are very critical.

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