Skip to main content
soumya
Gold ⭐️
October 18, 2019
Solved

unable to connect thrift server using beeline

when am connecting to thrift server using beeline it's showing  below error

Beeline version 1.2.1.spark2 by Apache Hive
beeline> !connect jdbc:hive2://host:10000
Connecting to jdbc:hive2://host:10000
Enter username for jdbc:hive2://host:10000: admin-sbarik2
Enter password for jdbc:hive2://host:10000: ********
org/apache/hive/service/cli/thrift/TCLIService$Iface
0: jdbc:hive2://host:10000 (closed)>

 

it's automatically closed.

soumya
soumyaAnswer
Gold ⭐️
October 24, 2019

actually in oracle Database previously am not entry  my user id and password 

after entry the same connection is established. It's a minor issue

 

thanks for your support.

 

20 replies

Shelton
Gold ⭐️⭐️⭐️
October 18, 2019

@soumya 

 

Have you tried the below method?

$ beeline -u jdbc:hive2://osaka.com:10000 -n hive -p hive
.........
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]
Connecting to jdbc:hive2://osaka.com:10000
Connected to: Apache Hive (version 3.1.0.3.1.0.0-78)
Driver: Hive JDBC (version 3.1.0.3.1.0.0-78)
Transaction isolation: TRANSACTION_REPEATABLE_READ
Beeline version 3.1.0.3.1.0.0-78 by Apache Hive
0: jdbc:hive2://osaka.com:10000> show databases;
INFO : Compiling command(queryId=hive_20191018215530_3f94b050-d36c-46c9-9582-40a0fef9b6e2): show databases
...........
INFO : Completed executing command(queryId=hive_20191018215530_3f94b050-d36c-46c9-9582-40a0fef9b6e2); Time taken: 0.037 seconds
INFO : OK
+---------------------+
| database_name |
+---------------------+
| default |
| information_schema |
| sparktest |
| sys |
+---------------------+
4 rows selected (0.392 seconds)
0: jdbc:hive2://osaka.com:10000>

 

 

Translate
soumya
soumyaAuthor
Gold ⭐️
October 19, 2019

no luck same issue it's automatically closed

Connecting to beeline
-n
log4j:WARN No appenders could be found for logger (org.apache.hive.beeline.SQLCompleter).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
0: beeline (closed)>

Translate
Shelton
Gold ⭐️⭐️⭐️
October 19, 2019

@soumya 

Following from my previous responses  can you get the connection string like below

 

Ambari UI --> Hive --> Summary (Tab) --> "HiveServer2 JDBC URL" --> Click on the at the right side of the URL to copy the URL and then try this URL with beeline once
At the prompt add beeline to the copied link above.

 connect1a.PNG

 

# beeline jdbc:hive2://osaka.com:2181/;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/usr/hdp/3.1.0.0-78/hive/lib/log4j-slf4j-impl-2.10.0.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/usr/hdp/3.1.0.0-78/hadoop/lib/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]
Connecting to jdbc:hive2://osaka.com:2181/default;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2
Enter username for jdbc:hive2://osaka.com:2181/default: hive
Enter password for jdbc:hive2://osaka.com:2181/default: ****
19/10/19 09:40:50 [main]: INFO jdbc.HiveConnection: Connected to osaka.com:10000
Connected to: Apache Hive (version 3.1.0.3.1.0.0-78)
Driver: Hive JDBC (version 3.1.0.3.1.0.0-78)
Transaction isolation: TRANSACTION_REPEATABLE_READ
Beeline version 3.1.0.3.1.0.0-78 by Apache Hive
0: jdbc:hive2://osaka.com:2181/default> show tables;
INFO : Compiling command(queryId=hive_20191019094333_357978cc-2f7d-433f-badc-6d8f20178361): show tables
..........
INFO : Completed executing command(queryId=hive_20191019094333_357978cc-2f7d-433f-badc-6d8f20178361); Time taken: 11.262 seconds
INFO : OK
+-------------+
| tab_name |
+-------------+
| hello_acid |
+-------------+
1 row selected (77.143 seconds)
0: jdbc:hive2://osaka.com:2181/default>

connect2.PNG

 

 

connect3.PNG

 

Specifying a database in the connect string

 

# beeline -u "jdbc:hive2://osaka.com:2181/sparktest;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2"
SLF4J: Class path contains multiple SLF4J bindings.
...........
Connecting to jdbc:hive2://osaka.com:2181/sparktest;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2
19/10/19 10:01:21 [main]: INFO jdbc.HiveConnection: Connected to osaka.com:10000
Connected to: Apache Hive (version 3.1.0.3.1.0.0-78)
Driver: Hive JDBC (version 3.1.0.3.1.0.0-78)
Transaction isolation: TRANSACTION_REPEATABLE_READ
Beeline version 3.1.0.3.1.0.0-78 by Apache Hive
0: jdbc:hive2://osaka.com:2181/sparktest> show tables;

 

Methods of Hs2 connections

HiveServer2 and a JDBC client (such as Beeline) as the primary way to access Hive. It uses SQL standard-based authorization or Ranger-based authorization. However if  wish to access Hive data from other applications, such as Pig. For these use cases, use the Hive CLI and storage-based authorization.
HS2 using Binary Transport Mode

beeline jdbc:hive2://<ZOOKEEPER QUORUM>/;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2HiveServer2

HS2 using HTTP Transport Mode

beeline jdbc:hive2://<ZOOKEEPER QUORUM>/;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2;transportMode=http;httpPath=cliservice

HS2 Interactive note zooKeeperNamespace=hiveserver2-hive2 in the below URL

beeline jdbc:hive2://<ZOOKEEPER QUORUM>/;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2-hive2

HS2 Scripts using Beeline, you can make use of -f option in Beeline.

beeline -u "jdbc:hive2://master01:2181,master02:2181,master03:2181/;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2" -f file.hql

The above methods should succeed.

 

 

Translate
soumya
soumyaAuthor
Gold ⭐️
October 19, 2019

can you share before i connecting to spark thrift server with beeline what configuration need to check ...???

what i  think something wrong with configuration file....

Translate
Shelton
Gold ⭐️⭐️⭐️
October 19, 2019

@soumya 

Can you share the output od the below

 

Ambari UI --> Hive --> Summary (Tab) --> "HiveServer2 JDBC URL" --> Click on the at the right side of the URL to copy the URL 

I see you using port 10001 ???

connect4.PNG

connect4a.PNG

 What is the output from your Linux console of

 

$ hostname  -f

You should append that derived  value i.e soumya.com to the connect string

 

 

 

Translate
rohitmalhotra
Gold ⭐️
Gold ⭐️
October 23, 2019

Hi @soumya,

 

It seems there is some confusion here.

As per my understanding, you are trying to connect to Spark Thrift Server via beeline. Please correct me, if I am wrong.

 

You you to be able to connect to Spark Thrift server via beeline, you need to make sure you are providing the correct hostname and portnumber in the JDBC URL you are using in the beeline.

 

For example:

jdbc:hive2://host:portnumber/

 

Here, the "host" will be the Hostname of the server where Spark Thriftserver is running.

Let us say it is running on abc.soumya.com.

The default portnumber for Spark Thriftserver is 10000.

But this portnumber can be configured to something else as well. You need to find the correct portnumber.

 

Thus, you connect string would look like below:

jdbc:hive2://abc.soumya.com:10000/

 

You can refer the below link for more information on this:

https://spark.apache.org/docs/latest/sql-distributed-sql-engine.html

Translate
soumya
soumyaAuthor
Gold ⭐️
October 23, 2019

Hi 

THANKS FOR THE INFO.

ISSUE RESOLVE .

 

Translate
Shelton
Gold ⭐️⭐️⭐️
October 23, 2019

@soumya 

Good to hear that can you share what solution worked for you this way other who encounter the same problem can quickly resolve it.

Thats what we csll community contribution 

Happy hadooping

 

Translate
rohitmalhotra
Gold ⭐️
Gold ⭐️
October 24, 2019

Hi @soumya,

 

Can you please confirm exactly how the issue was resolved.

Please do accept the answer which helped you.

Translate
soumya
soumyaAuthorAnswer
Gold ⭐️
October 24, 2019

actually in oracle Database previously am not entry  my user id and password 

after entry the same connection is established. It's a minor issue

 

thanks for your support.

 

Translate