How to install a Beeline Client to connect to Hive Metastore

hive metastore

Fig.1. Remote Metastore Architecture

The Hive metastore service stores the metadata for Hive tables and partitions in a relational database, and provides Hive access to this information using the metastore service API. Hevo Data Lake uses Hive tables to store data. Hive metastore service runs in its own JVM process. HiverServer2, HCatalog, Impala, and other processes communicate with it using the Thrift network API. The metastore service communicates with the metastore database over JDBC. Our Hive metastore service runs in the Remote mode which provides better availability and scalability. Beeline is a JDBC client based on SQLLine CLI. It connects to HiveServer2 to access the metastore database.

In this article, we’ll check how to connect to Hive using Beeline client.

1 Download Hadoop dependency specifically version 2.5.1

wget [https://archive.apache.org/dist/hadoop/core/hadoop-2.5.1/hadoop-2.5.1.tar.gz](https://archive.apache.org/dist/hadoop/core/hadoop-2.5.1/hadoop-2.5.1.tar.gz)

2 Download Hive dependency specifically version 1.2.1

wget [https://archive.apache.org/dist/hive/hive-1.2.1/apache-hive-1.2.1-bin.tar.gz](https://archive.apache.org/dist/hive/hive-1.2.1/apache-hive-1.2.1-bin.tar.gz)

3 Extract both tar files.

tar -xvzf hadoop-2.5.1.tar.gz 
tar -xvzf apache-hive-1.2.1-bin.tar.gz

4 Configure .bashrc file by exporting the dependency

export HADOOP_HOME=/path/to/hadoop-2.5.1
export HIVE_HOME=/path/to/apache-hive-1.2.1-bin
PATH=$PATH:$HIVE_HOME/bin

5 Open beeline client using below command

beeline --incremental=true

Note: The command line option —-incremental=true is optional, but will extend the amount of time that you can remain idle and not have your connection dropped.

6 Connect to the JDBC server from the beeline client. You can find the host-address in the Hevo Destination Config.

!connect jdbc:hive2://<host-address>:<port>

Some other helpful commands

  • Reconnect to the inactive session
!reconnect jdbc:hive2://<host-address>:<port>/default;
  • Quitting Beeline Client
!quit
  • Queries You can run SQL commands to do some basic operations here. Don’t forget to put semicolons to end the SQL commands.
/* to list out all the databases */
SHOW DATABASES;
  
/* to list our all the tables */
SHOW TABLES IN <database-name>;
  
/* to drop database */
DROP DATABASE <database-name>;

For more information on HiveServer2 Clients, you can always check out this.