You are currently viewing Hive – Start HiveServer2 and Beeline

HiveServer2 is the second generation of the Hive server, the first being HiveServer1 which has been deprecated and will be removed in future versions of Hive, so let’s start using HiveServer2.

In this Hive article, I will explain what is HiveServer2, how to start, accessing Web UI, benefits using HiveServer2, and finally using the Beeline Command Interface.

Prerequisites: Have Hive installed and setup to run on Hadoop cluster.

HiveServer2 a.k.a HS2 is a second-generation Hive server that enables

  • Remote clients to execute queries against the Hive server.
  • Multi-client concurrency and authentication
  • Better supports for API client like JDBC and ODBC

Before you proceed to start HiveServer2, make sure you have created the Hive Metastore and data warehouse location and able to run Hive CLI.

Start HiverServer2

Hive distribution comes with hiveserver2 which is located at $HIVE_HOME/bin/ directory, run this command without any arguments to start the HiveServer2.


prabha@namenode:~/hive$ $HIVE_HOME/bin/hiveserver2
hive start hiveserver2

In Order to run it as a service run the same command as nohup $HIVE_HOME/bin/hiveserver2 &. This creates a nohup.out file that contains the log.

You can also start Hive server HS2 (HiveServer2) using hive --service command.


prabha@namenode:~/hive$ $HIVE_HOME/bin/hive --service hiveserver2
(or)
# Start in nohup mode
prabha@namenode:~/hive$ nohup $HIVE_HOME/bin/hive --service hiveserver2 & 

By default HiveServer2 runs on port 10000, If you wanted to change the port, you can do it by changing the value for hive.server2.thrift.port  property on $HIVE_HOME/conf/hive-site.xml file.

Check if the HiveServer2 service is running and listening on port 10000 using netstat command.


prabha@namenode:~/hive$ netstat -anp | grep 10000
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
tcp6       0      0 :::10000                :::*                    LISTEN      17820/java

Since Hive is written in Java, you can also use jps command to check HiveServer2 is running.


prabha@namenode:~/hive$ jps
18025 Jps
17820 RunJar

HiveServer2 Web UI

HiveServer2 also starts a Jetty Http server on port 1002 which provides you with Web UI. This Web User Interface (UI) for HiveServer2 provides configuration, logging, metrics, and active session information. The Web UI is available at port 10002 (127.0.0.1:10002) by default.  

Hive start hiveserver2
HiveServer2 Web UI

Using Beeline CLI

HiveServer2 supports a command shell Beeline CLI that works with HiveServer2. It’s a JDBC client that is based on the SQLLine CLI. beeline is located at $HIVE_HOME/bin directory. For more information on Beeline check out Starting Beeline in Standalone Embedded and Remote modes.


prabha@namenode:~/hive$ bin/beeline -u jdbc:hive2://127.0.0.1:10000 scott tiger
Beeline version 2.3.7 by Apache Hive
beeline>

Hive by default provides user scott and password tiger.

If you get a connection error User: is not allowed to impersonate, as shown below. set property hive.server2.enable.doAs to false on $HIVE_HOME/conf/hive-site.xml file. and, restart the HiveServer2 and try to run the beeline command again.

Now, you should see beeline CLI prompt.

Hope you like this article.

Happy Learning !

Naveen Nelamali

Naveen Nelamali (NNK) is a Data Engineer with 20+ years of experience in transforming data into actionable insights. Over the years, He has honed his expertise in designing, implementing, and maintaining data pipelines with frameworks like Apache Spark, PySpark, Pandas, R, Hive and Machine Learning. Naveen journey in the field of data engineering has been a continuous learning, innovation, and a strong commitment to data integrity. In this blog, he shares his experiences with the data as he come across. Follow Naveen @ LinkedIn and Medium

Leave a Reply