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.

Run HIVE queries in command shell (cmd), not in Ambari Hive View

Solved Go to solution
Highlighted

Run HIVE queries in command shell (cmd), not in Ambari Hive View

New Contributor

I have installed Ambari and I can use Hive View 2.0 for executing Hive Queries. Due to my hardware issues (less RAM), Ambari server is very slow sometimes. For this reason, I wana run Hive queries in a command shell not in Hive View in Ambari. Is it possible? If so, how is it possible?

I would appreciate any help.

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Run HIVE queries in command shell (cmd), not in Ambari Hive View

Guru

Hi @Mike Bit

If you want to use a CLI to access Hive, the recommend client tool to use is called beeline. It is normally included in the client tools installation, so you probably already have it ready to go. From your client tools machine/host/server, you will use the beeline client to connect to the HiveServer2 JDBC URL, and everything from there is the usual SQL commands.

In Ambari, you can easily copy the HiveServer2 JDBC URL directly from the Hive service config screen, and paste it right into a beeline connect string. So for example, if my machines were ssahi[0-2].hortonworks.com, where I was running ZooKeeper, and I was using hive/hive as the user/password, my beeline command to open the client and connect to Hive may look like:

beeline -u "jdbc:hive2://ssahi1.hortonworks.com:2181,ssahi0.hortonworks.com:2181,ssahi2.hortonworks.com:2181/;ServiceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2" -n hive -p hive

You can find more on Beeline from the project documentation here, including example syntax, and config to have things display nicer, etc:

https://cwiki.apache.org/confluence/display/Hive/HiveServer2+Clients#HiveServer2Clients-Beeline–Comm...

1 REPLY 1

Re: Run HIVE queries in command shell (cmd), not in Ambari Hive View

Guru

Hi @Mike Bit

If you want to use a CLI to access Hive, the recommend client tool to use is called beeline. It is normally included in the client tools installation, so you probably already have it ready to go. From your client tools machine/host/server, you will use the beeline client to connect to the HiveServer2 JDBC URL, and everything from there is the usual SQL commands.

In Ambari, you can easily copy the HiveServer2 JDBC URL directly from the Hive service config screen, and paste it right into a beeline connect string. So for example, if my machines were ssahi[0-2].hortonworks.com, where I was running ZooKeeper, and I was using hive/hive as the user/password, my beeline command to open the client and connect to Hive may look like:

beeline -u "jdbc:hive2://ssahi1.hortonworks.com:2181,ssahi0.hortonworks.com:2181,ssahi2.hortonworks.com:2181/;ServiceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2" -n hive -p hive

You can find more on Beeline from the project documentation here, including example syntax, and config to have things display nicer, etc:

https://cwiki.apache.org/confluence/display/Hive/HiveServer2+Clients#HiveServer2Clients-Beeline–Comm...

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