Created on 12-23-2017 07:36 PM
Beeline is a JDBC client tool which is used to connect to HiveServer2 or HiveServer2Interactive(LLAP). Beeline, which connects to HiveServer2 and requires access to only one .jar file: hive-jdbc-<version>-standalone.jar
Hortonworks recommends using HiveServer2 and a JDBC client (such as Beeline) as the primary way to access Hive. This approach uses SQL standard-based authorization or Ranger-based authorization. However, some users may wish to access Hive data from other applications, such as Pig. For these use cases, use the Hive CLI and storage-based authorization.
Connecting to Hive with Beeline
The following examples demonstrate how to use Beeline to connect to Hive for all possible variations of these modes.
Embedded Client
Use the following syntax to connect to Hive from Beeline in embedded mode:
!connect jdbc:hive2://
Remote Client with HiveServer2 TCP Transport Mode and SASL Authentication
Use the following syntax to connect to HiveServer2 in TCP mode from a remote Beeline client:
!connect jdbc:hive2://<hiveserver2host>:<port>/<db>
The default port for HiveServer2 in TCP mode is 10000
, and db
is the name of the database to which you want to connect.
Connecting to HiveServer2 using Zookeeper Discovery Mode
Note: You can also find the below HiveServer2 JDBC URL from Ambari from Hive -> Summary page. To copy the JDBC URL, you can use the copy to clipboard icon next to the URL
Observe the / after the <ZOOKEEPER QUORUM> in each string below
- HiveServer2 using Binary Transport Mode:
jdbc:hive2://<ZOOKEEPER QUORUM>/;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2HiveServer2
- HiveServer2 using HTTP Transport Mode:
jdbc:hive2://<ZOOKEEPER QUORUM>/;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2;transportMode=http;httpPath=cliservice
jdbc:hive2://<ZOOKEEPER QUORUM>/;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2-hive2
beeline -u "jdbc:hive2://master01:2181,master02:2181,master03:2181/;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2" -f file.hql
Created on 12-23-2017 09:51 PM
@Tamil Selvan K nice article !!
Created on 12-28-2018 03:49 AM
I believe, Beeline JDBC client can also be used to connect to Spark SQL thru Spark Thrift server.