Hive客户端工具后续将使用Beeline替代HiveCLI,并且后续版本也会废弃掉HiveCLI客户端工具。

BeelineHive新的命令行客户端工具。

Beeline是从 Hive 0.11版本引入的。

HiveServer2支持一个新的命令行Shell,称为Beeline,它是基于SQLLine CLIJDBC客户端。

Beeline支持嵌入模式(embedded mode)和远程模式(remote mode)。在嵌入式模式下,运行嵌入式的Hive(类似Hive CLI),而远程模式可以通过Thrift连接到独立的HiveServer2进程上。从Hive 0.14版本开始,Beeline使用HiveServer2工作时,它也会从HiveServer2输出日志信息到STDERR

[root@SZB-L0007970 bin]# hive --service beeline

Beeline version 0.13.1-cdh5.3.4 by Apache Hive

beeline> !connect jdbc:hive2://SZB-L0007970:10000/annuity_safe

scan complete in 3ms

Connecting to jdbc:hive2://SZB-L0007970:10000/annuity_safe

Enter username for jdbc:hive2://SZB-L0007970:10000/annuity_safe: hive

Enter password for jdbc:hive2://SZB-L0007970:10000/annuity_safe: ****

Connected to: Apache Hive (version 0.13.1-cdh5.3.4)

Driver: Hive JDBC (version 0.13.1-cdh5.3.4)

Transaction isolation: TRANSACTION_REPEATABLE_READ

0: jdbc:hive2://SZB-L0007970:10000/annuity_sa> show tables;

+---------------------------------+--+

|            tab_name             |

+---------------------------------+--+

| orc_table                       |

| parquet_t                       |

| parquet_test                    |

| simple_table                    |

| spark_create                    |

| src                             |

| test_t                          |

| ylx_hbase_hive                  |

| ylx_hivehbase_cid               |

| ylx_map                         |

| ylx_multi_mapping               |

| ylx_pops                        |

+---------------------------------+--+

16 rows selected (0.227 seconds)

我们也可以通过命令行去执行SQL命令或脚本:

[root@SZB-L0007970 bin]# beeline -u jdbc:hive2://SZB-L0007970:10000/annuity_safe --color=true --silent=false -e"show tables"

scan complete in 3ms

Connecting tojdbc:hive2://SZB-L0007970:10000/annuity_safe

Connected to: Apache Hive (version0.13.1-cdh5.3.4)

Driver: Hive JDBC (version 0.13.1-cdh5.3.4)

Transaction isolation:TRANSACTION_REPEATABLE_READ

+---------------------------------+--+

|           tab_name             |

+---------------------------------+--+

| orc_table                       |

| parquet_t                       |

| parquet_test                    |

| simple_table                    |

| spark_create                    |

| src                             |

| test_t                          |

| ylx_hbase_hive                  |

| ylx_hivehbase_cid               |

| ylx_map                         |

| ylx_multi_mapping               |

| ylx_pops                        |

+---------------------------------+--+

16 rows selected (0.151 seconds)

Beeline version 0.13.1-cdh5.3.4 by ApacheHive

Closing: 0:jdbc:hive2://SZB-L0007970:10000/annuity_safe

也可以执行SQL脚本:

[root@SZB-L0007970 ~]# beeline -u jdbc:hive2://SZB-L0007970:10000/annuity_safe  -f  beeline.sql

scan complete in 3ms

Connecting tojdbc:hive2://SZB-L0007970:10000/annuity_safe

Connected to: Apache Hive (version0.13.1-cdh5.3.4)

Driver: Hive JDBC (version 0.13.1-cdh5.3.4)

Transaction isolation:TRANSACTION_REPEATABLE_READ

0: jdbc:hive2://SZB-L0007970:10000/annuity_sa>use annuity_safe;

No rows affected (0.052 seconds)

0:jdbc:hive2://SZB-L0007970:10000/annuity_sa> show tables;

+---------------------------------+--+

|           tab_name             |

+---------------------------------+--+

| orc_table                       |

| parquet_t                       |

| parquet_test                    |

| simple_table                    |

| spark_create                    |

| src                             |

| test_t                          |

| ylx_hbase_hive                  |

| ylx_hivehbase_cid               |

| ylx_map                         |

| ylx_multi_mapping               |

| ylx_pops                        |

+---------------------------------+--+

16 rows selected (0.132 seconds)

0:jdbc:hive2://SZB-L0007970:10000/annuity_sa>

Closing: 0: jdbc:hive2://SZB-L0007970:10000/annuity_safe

[root@SZB-L0007970 ~]#

执行初始化SQL文件:

[root@SZB-L0007970 ~]# beeline -u jdbc:hive2://SZB-L0007970:10000/annuity_safe -i beeline.sql

scan complete in 2ms

Connecting tojdbc:hive2://SZB-L0007970:10000/annuity_safe

Connected to: Apache Hive (version0.13.1-cdh5.3.4)

Driver: Hive JDBC (version 0.13.1-cdh5.3.4)

Transaction isolation:TRANSACTION_REPEATABLE_READ

Running init script beeline.sql

0:jdbc:hive2://SZB-L0007970:10000/annuity_sa> use annuity_safe;

No rows affected (0.052 seconds)

0:jdbc:hive2://SZB-L0007970:10000/annuity_sa> show tables;

+---------------------------------+--+

|           tab_name             |

+---------------------------------+--+

| orc_table                       |

| parquet_t                       |

| parquet_test                    |

| simple_table                    |

| spark_create                    |

| src                             |

| test_t                          |

| ylx_hbase_hive                  |

| ylx_hivehbase_cid               |

| ylx_map                         |

| ylx_multi_mapping               |

| ylx_pops                        |

+---------------------------------+--+

16 rows selected (0.136 seconds)

0:jdbc:hive2://SZB-L0007970:10000/annuity_sa>

Beeline version 0.13.1-cdh5.3.4 by ApacheHive

0: jdbc:hive2://SZB-L0007970:10000/annuity_sa>select max(key) from test_t;

Error: Error while processing statement: FAILED: ExecutionError, return code 1 from org.apache.hadoop.hive.ql.exec.mr.MapRedTask(state=08S01,code=1)

解释:这个如果不跟用户名和密码登陆beeline的话,就会报这个错误。

下面我们通过Beeline登陆Hive服务器时要指定用户名和密码。

[root@SZB-L0007970 ~]# beeline -ujdbc:hive2://SZB-L0007970:10000/annuity_safe -n hive -p hive -i beeline.sql

scan complete in 2ms

Connecting tojdbc:hive2://SZB-L0007970:10000/annuity_safe

Connected to: Apache Hive (version0.13.1-cdh5.3.4)

Driver: Hive JDBC (version 0.13.1-cdh5.3.4)

Transaction isolation:TRANSACTION_REPEATABLE_READ

Running init script beeline.sql

0:jdbc:hive2://SZB-L0007970:10000/annuity_sa> use annuity_safe;

No rows affected (0.043 seconds)

0:jdbc:hive2://SZB-L0007970:10000/annuity_sa> show tables;

+---------------------------------+--+

|           tab_name             |

+---------------------------------+--+

| orc_table                       |

| parquet_t                       |

| parquet_test                    |

| simple_table                    |

| spark_create                    |

| src                             |

| test_t                          |

| ylx_hbase_hive                  |

| ylx_hivehbase_cid               |

| ylx_map                         |

| ylx_multi_mapping               |

| ylx_pops                        |

+---------------------------------+--+

16 rows selected (0.145 seconds)

0:jdbc:hive2://SZB-L0007970:10000/annuity_sa> select * from test_t;

+-------------+---------------+--+

| test_t.key  | test_t.value  |

+-------------+---------------+--+

| 1           | pingan        |

| 2           | huazhong      |

+-------------+---------------+--+

2 rows selected (0.227 seconds)

0:jdbc:hive2://SZB-L0007970:10000/annuity_sa> select max(key) from test_t;

+------+--+

| _c0 |

+------+--+

| 2   |

+------+--+

1 row selected (30.606 seconds)

0:jdbc:hive2://SZB-L0007970:10000/annuity_sa>

这样就可以在Beeline里面对Hive执行相关操作了。

说明一下:

参数-f和-i的区别是:

-f执行SQL文件后就直接退出Beeline客户端

而-i执行SQL文件后进行Beeline客户端。

 

如果想查看beeline的帮助信息,执行如下命令:

[root@SZB-L0007970 bin]# beeline --help

Usage: javaorg.apache.hive.cli.beeline.BeeLine

 -u <database url>               the JDBC URL to connect to

-n <username>                   the username to connect as

-p<password>                   thepassword to connect as

-d<driver class>               thedriver class to use

-i <initfile>                  script file forinitialization

-e<query>                      query that should be executed

-f <execfile>                  script filethat should be executed

--hiveconf property=value      Use value for given property

--hivevar name=value           hive variable name and value

This is Hive specificsettings in which variables

can be setat session level and referenced in Hive

commands orqueries.

--color=[true/false]           control whether color is used for display

--showHeader=[true/false]      show column names in query results

--headerInterval=ROWS;         the interval between which heades are displayed

--fastConnect=[true/false]     skip building table/column list for tab-completion

--autoCommit=[true/false]       enable/disable automatic transactioncommit

--verbose=[true/false]          show verbose error messages and debuginfo

--showWarnings=[true/false]    display connection warnings

--showNestedErrs=[true/false]  display nested errors

--numberFormat=[pattern]       format numbers using DecimalFormat pattern

--force=[true/false]           continue running script even after errors

--maxWidth=MAXWIDTH            the maximum width of the terminal

--maxColumnWidth=MAXCOLWIDTH   the maximum width to use when displaying columns

--silent=[true/false]           bemore silent

--autosave=[true/false]        automatically save preferences

--outputformat=[table/vertical/csv2/tsv2/dsv/csv/tsv]  format mode for result display

Note thatcsv, and tsv are deprecated - use csv2, tsv2 instead

--truncateTable=[true/false]   truncate table column when it exceeds length

--delimiterForDSV=DELIMITER    specify the delimiter for delimiter-separated values output format(default: |)

--isolation=LEVEL              set the transaction isolation level

Setthe transaction isolation level to TRANSACTION_READ_COMMITTED 
or TRANSACTION_SERIALIZABLE.

--nullemptystring=[true/false] set to true to get historic behavior of printing null as empty string

--help                         display this message

Beeline version 0.13.1-cdh5.3.4 by ApacheHive

常用的一些命令总结:

(1)    reset

还原Beeline客户端对Hive参数的设置

(2)    dfs

0:jdbc:hive2://SZB-L0007970:10000/annuity_sa> dfs -ls /apps-data;

+-----------------------------------------------------------------------------------+--+

|        DFS Output                                     |

+-----------------------------------------------------------------------------------+--+

|Found 1 items                                           |

| drwxr-xr-x - hdfs supergroup 0 2015-10-2216:13 /apps-data/hduser0103  |

+-----------------------------------------------------------------------------------+--+

2 rows selected (0.008 seconds)

0:jdbc:hive2://SZB-L0007970:10000/annuity_sa>

新一代Hive客户端工具:Beeline相关推荐

  1. Hive 客户端工具

    一.SQuirrel SQL Client 可以连接Hive,SparkThriftServer 网址 http://squirrel-sql.sourceforge.net/ 安装 启动安装程序 启 ...

  2. Hive 客户端 Beeline 、IDEA|Eclipse使用JDBC连接hiveserver2

    1.Beline Beeline 要与HiveServer2配合使用 服务端启动hiveserver2 客户的通过beeline两种方式连接到hive a.beeline -u jdbc:hive2: ...

  3. Hive Cli 和 Beeline

    前言 你们怎么直接用hive命令进hive呢?为什么不使用beeline,另一个部门的同事,看到我直接输入hive 回车进入hive,感到很困惑.我说有什么区别吗?我一直都用的cli,从未用过beel ...

  4. Hive(番外):Hive可视化工具IntelliJ IDEA

    1 Hive CLI.Beeline CLI Hive自带的命令行客户端 优点:不需要额外安装 缺点:编写SQL环境恶劣,无有效提示,无语法高亮,误操作几率高 2 文本编辑器 Sublime.Emac ...

  5. 新一代需求管理工具Trufun Bacon X正式发布!

    备受关注的新一代需求管理工具Trufun Bacon X正式发布! 它集现有需求管理工具Telelogic 和Requisite Pro之大成,为用户的需求管理提供了一个新的.更加强大的选择! Tru ...

  6. Hive thrift服务--beeline使用

    hive提供了thrift服务,只要客户端符合thrift标准就可以与它对接. 这样可以以在一台服务器上启动一个hive,其他用户通过thrift访问hive. hive自带了一个thrift的客户端 ...

  7. 如何使用TFTP客户端工具修复路由器固件

    如何使用TFTP客户端工具修复路由器固件 编号:12083       来自:NetGear       更新日期:2013-10-14       访问数量:24650 NETGEAR无线路由器中, ...

  8. spring-boot项目优雅的http客户端工具,太香了!

    点击上方"方志朋",选择"设为星标" 回复"666"获取新整理的面试文章 来源:https://juejin.im/post/6854573 ...

  9. elasticsearch 客户端工具_elasticsearch初使用

    elasticsearch下载安装 elasticsearch以下相关内容安装~ 原创链接:https://www.cnblogs.com/hualess/p/11540477.html 下载地址 h ...

  10. 终于有人把 SpringBoot 项目的Http客户端工具说清楚了!

    大家都知道okhttp是一款由square公司开源的java版本http客户端工具.实际上,square公司还开源了基于okhttp进一步封装的retrofit工具,用来支持通过接口的方式发起http ...

最新文章

  1. micropythonesp8266的温度湿度_用ESP8266上传温湿度给ONENET(不需要arduino)
  2. Oracle 数据泵(IMPDP/EXPDP)导入导出总结
  3. mybatis的mapper.xml中使用java类中的全局变量
  4. TensorFlow预训练模型在新图中权重部分加载
  5. Crazy Drops 3
  6. android应用程序优化之布局优化
  7. [史上最全]数学符号参考手册大全
  8. 有道单词本添加js实现自动阅读单词
  9. m4s格式转换mp3_音乐怎么转换mp3格式
  10. markdown如何调整行距_Markdown基础语法
  11. 企业生产中,APS系统有哪些具体应用场景?
  12. 回归学习算法---偏最小二乘回归、PCA降维与理论
  13. shell 命令下载软件 安装软件
  14. Qt VTK软件开发问题学习记录
  15. MongoDB相关概念
  16. Android发送短信的两种方法
  17. RocksDB问题点解决及相关学习记录
  18. vivo X21使用AS“解析包错误”问题解决
  19. Win11强制删除文件
  20. 2020年系统分析师考试经验分享

热门文章

  1. JAVA缴税_根据工资和税率计算应缴税(java)
  2. 密钥创建ssh-keygen
  3. 荣耀7升级android8,华为+荣耀7款老爷机齐升安卓8.0:最近两年全覆盖
  4. 数据库应用系统的四个层次划分
  5. python自动视频剪辑_python剪切视频与合并视频的实现
  6. OpenGL法线贴图
  7. 淘宝订单接口|订单插旗备注,API稳定、QPS高的方案
  8. DW_axi_dmac控制器(概述)
  9. 1971旗舰cpu intel_这就是近年来Intel最良心CPU!我彻底服了
  10. 排除美颜相机等第三方相机直接调用系统相机处理方法