Support Questions

Find answers, ask questions, and share your expertise

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

avatar
Explorer

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

avatar
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...

View solution in original post

1 REPLY 1

avatar
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...