17.2. beeline

简介:

beeline 是 hive 提供的一个新的命令行工具,基于SQLLine CLI的JDBC客户端,beeline 与HiveServer2配合使用,支持嵌入模式和远程模式两种,可以像hive client一样访问本机的hive服务,也可以通过指定ip和端口访问远程hive服务。

hive 官方是推荐使用beeline,因为它还提供了更为友好的交互方式(类似mysql client)

连接到本机的Hive

		
[hadoop@localhost ~]$ /srv/apache-hive/bin/beeline -u jdbc:hive2://
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/srv/apache-hive-2.1.1/lib/log4j-slf4j-impl-2.4.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/srv/apache-hadoop-2.8.0/share/hadoop/common/lib/slf4j-log4j12-1.7.10.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://
17/06/29 22:01:16 [main]: WARN session.SessionState: METASTORE_FILTER_HOOK will be ignored, since hive.security.authorization.manager is set to instance of HiveAuthorizerFactory.
Connected to: Apache Hive (version 2.1.1)
Driver: Hive JDBC (version 2.1.1)
17/06/29 22:01:16 [main]: WARN jdbc.HiveConnection: Request to set autoCommit to false; Hive does not support autoCommit=false.
Transaction isolation: TRANSACTION_REPEATABLE_READ
Beeline version 2.1.1 by Apache Hive
0: jdbc:hive2://> show databases;
OK
+----------------+--+
| database_name  |
+----------------+--+
| default        |
+----------------+--+
1 row selected (1.318 seconds)
0: jdbc:hive2://> use default;
OK
No rows affected (0.03 seconds)
0: jdbc:hive2://> show tables;
OK
+-----------+--+
| tab_name  |
+-----------+--+
| invites   |
| member    |
| passwd    |
| v_test    |
| vipuser   |
+-----------+--+
5 rows selected (0.068 seconds)
0: jdbc:hive2://> 			
		
		

连接远程主机

		
[hadoop@localhost ~]$ /srv/apache-hive/bin/beeline -u jdbc:hive2://hadoop@localhost:10000
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/srv/apache-hive-2.1.1/lib/log4j-slf4j-impl-2.4.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/srv/apache-hadoop-2.8.0/share/hadoop/common/lib/slf4j-log4j12-1.7.10.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://hadoop@localhost:10000
Connected to: Apache Hive (version 2.1.1)
Driver: Hive JDBC (version 2.1.1)
17/06/29 23:05:35 [main]: WARN jdbc.HiveConnection: Request to set autoCommit to false; Hive does not support autoCommit=false.
Transaction isolation: TRANSACTION_REPEATABLE_READ
Beeline version 2.1.1 by Apache Hive
0: jdbc:hive2://hadoop@localhost:10000> show databases;
+----------------+--+
| database_name  |
+----------------+--+
| default        |
+----------------+--+
1 row selected (1.332 seconds)
0: jdbc:hive2://hadoop@localhost:10000> use default;
No rows affected (0.038 seconds)
0: jdbc:hive2://hadoop@localhost:10000> show tables;
+-----------+--+
| tab_name  |
+-----------+--+
| invites   |
| member    |
| passwd    |
| t_hive    |
| v_test    |
| vipuser   |
+-----------+--+
6 rows selected (0.049 seconds)
0: jdbc:hive2://hadoop@localhost:10000> select * from member;
+--------------+-------------+-------------+---------------+--+
| member.name  | member.age  | member.sex  | member.phone  |
+--------------+-------------+-------------+---------------+--+
| Neo          | 30          | 1           | 13113668890   | 
+--------------+-------------+-------------+---------------+--+
No rows selected (1.137 seconds)
1: jdbc:hive2://hadoop@localhost:10000> 
		
		





原文出处:Netkiller 系列 手札
本文作者:陈景峯
转载请与作者联系,同时请务必标明文章原始出处和作者信息及本声明。

目录
相关文章
|
SQL Java 数据管理
HiveServer2&beeline
HiveServer2&beeline
73 0
HiveServer2&beeline
|
SQL HIVE
71 Azkaban HIVE脚本任务
71 Azkaban HIVE脚本任务
62 0
|
SQL HIVE Python
[Hive]HiveServer2配置
HiveServer2(HS2)是一个服务器接口,能使远程客户端执行Hive查询,并且可以检索结果。HiveServer2是HiveServer1的改进版,HiveServer1已经被废弃。
4097 0
|
6月前
|
SQL 存储 分布式计算
bigdata-15-Hive初步了解
bigdata-15-Hive初步了解
38 0
|
SQL 分布式计算 关系型数据库
启动hive
启动hive
|
SQL Java 数据库连接
Hive beeline初次使用
Hive beeline初次使用
|
SQL 分布式计算 数据管理
spark SQL配置连接Hive Metastore 3.1.2
Hive Metastore作为元数据管理中心,支持多种计算引擎的读取操作,例如Flink、Presto、Spark等。本文讲述通过spark SQL配置连接Hive Metastore,并以3.1.2版本为例。
spark SQL配置连接Hive Metastore 3.1.2
|
SQL Java 关系型数据库
其它语言通过HiveServer2访问Hive
其它语言访问hive主要是通过hiveserver2服务,HiveServer2(HS2)是一种能使客户端执行Hive查询的服务。HiveServer2可以支持对 HiveServer2 的嵌入式和远程访问,支持多客户端并发和身份认证。旨在为开放API客户端(如JDBC和ODBC)提供更好的支持。
301 0
其它语言通过HiveServer2访问Hive
|
Java SQL HIVE
CDP中的Hive3系列之启动Apache Hive3
由于Hive3版本的变动,在我们使用Hive3前需要我们了解如何正确的启动Hive3.
704 0
CDP中的Hive3系列之启动Apache Hive3
|
Java 数据库连接