Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

beeline not able to connect to hiveserver2

I have a CDH 5.3 instance. I start the hive-server2 by first starting the hive-metastore and then the hive-server from command line. After this I use beeline to connect to my hive-server2 but apparently it is not able to so.

Could not open connection to jdbc:hive2://localhost:10000: java.net.ConnectException: Connection refused (state=08S01,code=0)

Another issue, I tried to see if the hive-server2 was listening on port 10000. I did " sudo netstat -tulpn | grep :10000" but none of the applications came up. I also added the following property in the hive-site.xml but to no avail. Why it doesn't show up on the netstat?

<property>
   <name>hive.server2.thrift.port</name>
   <value>10000</value>
   <description>TCP port number to listen on, default 10000</description>
 </property>

The connect command on beeline:

!connect jdbc:hive2://localhost:10000 org.apache.hive.jdbc.HiveDriver

when asked for username and password, I just enter test "user" and "password" for the respective values and then it throws the error. Any help will be appreciated

like image 256
tinus91 Avatar asked Mar 06 '15 12:03

tinus91


People also ask

What is the difference between HiveServer2 and Beeline?

Beeline is a thin client that also uses the Hive JDBC driver but instead executes queries through HiveServer2, which allows multiple concurrent client connections and supports authentication.

How do I check my HiveServer2 status?

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

How do I connect to HiveServer2?

Configuring the ConnectionSpecify your Hive password for use with LDAP and custom authentication. Specify the host node for Hive Server2. Specify your Hive Server2 port number. Specify the name for the database you would like to connect to with Hive Server2.


2 Answers

Hive Connecting to beeline from client having various Modes.

1.Embedded Mode: Both Server and Client runs in same machine. No TCP Connection required.

 If hive.server2.authentication is "NONE" in HIVE_HOME/conf/hive-site.xml then connect beeline with below url

Connection URL:
               !connect jdbc:hive2://

2. Remote Mode: It supports multiple clients to execute queries with help of following Authentication schemes.

Authentication Schemes:

i.)SASL Authentication:

   If value of "hive.server2.authentication" property in HIVE_HOME/conf/hive-site.xml to be set as "SASL" then connect hive beeline with below url

   Beeline URL:
             !connect jdbc:hive2://<host>:<port>/<db>

ii.)NOSASL Authentication:
   If "hive.server2.authentication" is nosasl then connect the beeline like below.
   Beeline URL:

             !connect jdbc:hive2://<host>:<port>/<db>;auth=noSasl

Hope this really helps you

References:

https://docs.hortonworks.com/HDPDocuments/HDP2/HDP-2.3.2/bk_dataintegration/content/beeline-vs-hive-cli.html

like image 123
Mister X Avatar answered Sep 21 '22 15:09

Mister X


I had the same problem here. This is simply because hiveserver2 failed to start -- the error does not show up in console, but in hive logs. In my case, hive logs are located in /tmp/ubuntu/hive.log

There might be different reason for you to cause hive-server2 failed to start, but it definitely worth to look into this log file.

like image 44
Gavin Huang Avatar answered Sep 21 '22 15:09

Gavin Huang