连接hive有2种形式,hive cli 和 beeline

hive提供了以表的形式访问hdfs文件的功能,metastore对外提供表的元数据信息。有了元数据,就可以结构化的表的形式访问hdfs上的文件了
cli模式是通过metaStroe来访问元数据;beeline模式是通过hiveServer2==》metastore访问元数据。
hs2依赖于metastore。
官方建议使用beeline模式连接hive执行操作。

hive-cli和beeline区别 官网说明

1.在使用hive命令的时候,会提示CLI已经过期,建议用beeline

通过hadoop version 找到hive的home,发现有一个hive-old 的文件,通过检查测试发现这就是原来hive cli的文件。hive3.0只支持beeline

2.cli连接不需要hs2,而beeline需要启动hs2服务

将hs2关闭后

hive可以正常连,但beeline连不上

3.CDH的beeline在运行load data local inpath的时候总是提示找不到文件的错误(可以用hdfs上的地址),但在同一节点使用hive却可以。这是因为启动hivecli的时候,是会在本地启动一个metastore的服务,但hs2可以远程的,自然加载不到本地的文件。

可以使用 hive -e ‘load data local inpath’ 和 hive -f

hive cli 之于hive 就相当于sql plus之于oracle. 需要和server安装在一起。

而beeline只需要一个jdbc jar包就可以了,可以不需要与hive server 2装在一台server.

他们认证的方式也不同,hive cli可以直接访问hdfs和hive meta store,感觉更稳定快捷一些。

而beeline 则需要把请求提交到hive server2,通过安全验证,然后在队列中等待。

beeline的并发性和安全性得到了提高。

4.beeline的功能更强大,支持jdbc,并发性和安全性更高,cs架构,更轻。但速度理论上更慢。

hs2提供了代理功能,能够以一个更安全的用户访问hive。
本身是基于jdbc的,并发性能有保障。
beeline功能更多,比如,可以设置输出数据的分隔符、高亮显示、数据转换等功能

一、hive cli

二、hive beeline

1. overview

beeline 可以连接hive和impala,基于SQLLine CLI的JDBC客户端,beeline 要与HiveServer2配合使用,支持嵌入模式和远程模式两种,也即既可以像hive client一样访问本机的hive服务,也可以通过指定ip和端口远程访问某个hive服务。
metaStroe是提供元数据访问服务,hiveServer2是提供jdbc的方式访问hive。
Beeline支持嵌入模式(embedded mode)和远程模式(remote mode)。在嵌入式模式下,运行嵌入式的Hive(类似Hive CLI),而远程模式可以通过Thrift连接到独立的HiveServer2进程上。从Hive 0.14版本开始,Beeline使用HiveServer2工作时,它也会从HiveServer2输出日志信息到STDERR。
hive 官网是推荐使用beeline,它还提供了更为友好的显示方式(类似mysql client)。Beeline是从 Hive 0.11版本引入的,它是基于SQLLine CLI的JDBC客户端。后续将使用Beeline 替代HiveCLI ,并且后续版本也会废弃掉HiveCLI 客户端工具。

2. usage

nohup beeline
-u jdbc:hive2://10.180.0.26:10000;principal=hive/z4.idss.com@TEST.COM
-n hive -p hive
--color=true
--silent=false
--hivevar p_date=${partitionDate} --hivevar f_date=${fileLocDate}
-f hdfs_add_partition_dmp_clearlog.hql
>> $logdir/load_${curDate}.log
&
指定要连接的hiveserver2的主机、端口
beeline -u jdbc:hive2://hd1:10000
如果是本机的hiveserver2,则可省略主机、端口
beeline -u jdbc:hive2://

整合kerberos时设置要principal是hive服务的,登录用户是krb认证的,krb认证谁beeline当前用户就是谁。
如果principal这个单词写错了
beeline -u “jdbc:hive2://n105:10000/;principal=hive/node105@XYYH.COM”

3.beeline的使用

官网参数详解,注意版本号

Usage: java org.apache.hive.cli.beeline.BeeLine -u <database url>               the JDBC URL to connect to-n <username>                   the username to connect as-p <password>                   the password to connect as-w (or) --password-file <password file>  the password file to read password from-d <driver class>               the driver class to use-e <query>                      query that should be executed-i <init file>                  script file for initialization一般用来和-f配合,用来给-f中的sql文件设置变量,值也是一个文件-f <exec file>                  script file that should be executed可以设置多个 -f sqlFile1 -f sqlFile2  --hiveconf property=value       Use value for given property--hivevar name=value            hive variable name and valueThis is Hive specific settings in which variablescan be set at session level and referenced in Hivecommands or queries.--color=[true/false]            control whether color is used for display用于在beeline中设置多种颜色,便于查看--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 transaction commit--verbose=[true/false]          show verbose error messages and debug info显示详细错误信息和调试信息--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]           be more silent--autosave=[true/false]         automatically save preferences--outputformat=[table/vertical/csv2/tsv2/dsv/csv/tsv]  format mode for result displayNote that csv, 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--nullemptystring=[true/false]  set to true to get historic behavior of printing null as empty string--addlocaldriverjar=DRIVERJARNAME Add driver jar file in the beeline client side--addlocaldrivername=DRIVERNAME Add drvier name needs to be supported in the beeline client side--help                          display this message
Beeline version 1.2.1.spark2 by Apache Hive

进入beeline后的命令

!addlocaldriverjar  Add driver jar file in the beeline client side.
!addlocaldrivername Add driver name that needs to be supported in the beelineclient side.
!all                Execute the specified SQL against all the current connections
!autocommit         Set autocommit mode on or off
!batch              Start or execute a batch of statements
!brief              Set verbose mode off
!call               Execute a callable statement
!close              Close the current connection to the database
!closeall           Close all current open connections
!columns            List all the columns for the specified table
!commit             Commit the current transaction (if autocommit is off)
!connect            Open a new connection to the database.
!dbinfo             Give metadata information about the database
!describe           Describe a table
!dropall            Drop all tables in the current database
!exportedkeys       List all the exported keys for the specified table
!go                 Select the current connection
!help               Print a summary of command usage
!history            Display the command history
!importedkeys       List all the imported keys for the specified table
!indexes            List all the indexes for the specified table
!isolation          Set the transaction isolation for this connection
!list               List the current connections
!manual             Display the BeeLine manual
!metadata           Obtain metadata information
!nativesql          Show the native SQL for the specified statement
!nullemptystring    Set to true to get historic behavior of printing null asempty string. Default is false.
!outputformat       Set the output format for displaying results(table,vertical,csv2,dsv,tsv2,xmlattrs,xmlelements, anddeprecated formats(csv, tsv))
!primarykeys        List all the primary keys for the specified table
!procedures         List all the procedures
!properties         Connect to the database specified in the properties file(s)
!quit               Exits the program
!reconnect          Reconnect to the database
!record             Record all output to the specified file
!rehash             Fetch table and column names for command completion
!rollback           Roll back the current transaction (if autocommit is off)
!run                Run a script from the specified file
!save               Save the current variabes and aliases
!scan               Scan for installed JDBC drivers
!script             Start saving a script to a file将一个命令保存为脚本文件
!set                Set a beeline variable
!sh                 Execute a shell command执行一个本地命令,就不用在切出去执行了
!sql                Execute a SQL command
!tables             List all the tables in the database
!typeinfo           Display the type map for the current connection
!verbose            Set verbose mode onComments, bug reports, and patches go to ???

三、WebHCat

WebHCat是为HCatalog提供REST API的服务,自hive 0.11.0 版本之后,hive 中也自带了 webhcat (官网介绍说明),如下图,通过WebHCat,程序能够通过REST的API很安全的链接和操作HCatalog提供的服务,方便Hive、Pig、MapReduce等应用使用。(类似于通过WebHDFS以web的方式来操作HDFS)

hive、impala的客户端,cli、beeline、WebHCat相关推荐

  1. Hive第二代客户端远程连接

    目录 hive第二代客户端 两种模式解读​ 启动 相关配置文件 前提:启动hadoop集群 初始化元数据库 ​踩坑 启动metastore 启动hiveserver2 远程连接 测试 IDEA连接hi ...

  2. 记录python使用pymysql连接mysql数据库,使用impyla、ibis-framework[impala]连接hive\impala(kerberos)数据库(备以后查阅)

    记录python使用pymysql连接mysql数据库,使用impyla.ibis-framework[impala]连接hive\impala(kerberos)数据库(备以后查阅) 连接mysql ...

  3. 数仓工具—Hive源码之cli 模块(2)

    hive 源码 cli 模块 关于hive 的cli 模块其实是我们日常工作中使用最多的模块了,主要包括两部分 Hive 这是hive 提供的老版本的命令行交互工具了 beeline 这是hive 新 ...

  4. hive集群部署以及beeline和hive

    我们会发现一个奇怪的现象就是 hbase是一条命令可以启动整个集群的,但是hive却不是,这是怎么回事呢? 因为hive只是一个SQL客户端而已. 数据并不在hive中,hive只是帮忙从hdfs-& ...

  5. Hive(Impala)测试数据生成与加载

    1.通过shell脚本生成测试数据. 脚本如下,生成的每条记录包括四个字段,如果感觉不够的话可根据自己需求增加字段. rm -rf ./data.txt touch data.txt delimite ...

  6. Hive 03_DML、SerDe、Beeline、JDBC

    Hive DML --LOAD DATA [LOCAL] INPATH 'filepath' [OVERWRITE] INTO TABLE tablename [PARTITION (partcol1 ...

  7. Hive 3.x详细笔记

    Hive 数据仓库 概念 数据仓库(Data Warehouse,简称数仓.DW),是一个用于存储,分许,报告的数据系统. 数据仓库的目的是构建面向分析的集成数据环境,分析结果为企业提供决策支持. 数 ...

  8. 大数据开发平台:数仓组件Apache Kylin详细安装暨使用教程

    前言: Kylin依赖于Hive和Hbase,所以必须保证Hive和Hbase能够正常使用. Hive安装教程[传送门] Hbase安装教程[传送门] 简介: Apache Kylin是一个开源的分布 ...

  9. Apache Hive 2.1.1 安装配置超详细过程,配置hive、beeline、hwi、HCatalog、WebHCat等组件...

    2019独角兽企业重金招聘Python工程师标准>>> 在Docker环境成功搭建了Apache Hadoop 2.8 分布式集群,并实现了NameNode HA.ResourceM ...

最新文章

  1. 利用 GPU 加速人工智能:新型计算模式
  2. 小程序二次贝塞尔曲线,购物车商品曲线飞入效果
  3. python中怎么创建配置文件_在Python中创建游戏配置/选项(config.cfg)文件
  4. 假设以带头结点的循环链表表示队列_[leetcode链表系列]2 删除链表中的节点
  5. 新服务器安装和配置zabbix的playbook
  6. jzoj1246-挑剔的美食家【set,贪心】
  7. 《精通Python设计模式》学习之原型模式
  8. Java二十三种设计模式 之代理(proxy)
  9. 模拟赛 10-14考试再次翻车记
  10. Uber 提出损失变化分配方法 LCA,揭秘神经网络“黑盒” 60s测试:你是否适合转型人工智能? https://edu.csdn.net/topic/ai30?utm_source=csdn_bw
  11. python 微信自动发图片,批量发送
  12. 三菱 J2 J2S J3 J4 编码器 电机文件 修改ID 修改功率 修改型号
  13. 小编告诉你关于阿里云商标注册靠不靠普
  14. 我的练习项目: 模拟淘宝搜索商品、添加商品到购物车功能、修改商品信息功能
  15. PS 模块BAPI新建修改项目、WBS、网络、作业 (一)
  16. SPCA5XX摄像头驱动源码分析
  17. Turtle图形绘制(绘制奥运五环)
  18. 软件开发视频资源分享
  19. 使用腾讯企业邮箱为什么强烈建议启用安全登录?怎么启用?
  20. Statement和PreparedStatement的区别/PreparedStatement和Statement比较的优点

热门文章

  1. Maven学习:依赖管理
  2. char ch= 中 什么意思java_在 Java 语言中定义了如下变量: char ch; 下列赋值语句正确的是_韩语初下答案_学小易找答案...
  3. c语言程序设计施莹答案,C语言课件-位运算.ppt
  4. Java对List中的中文属性按照拼音排序
  5. linux 下视频编辑软件下载,在Linux系统中下载和安装Shotcut视频编辑工具
  6. html模仿微信好友列表,微信的模拟登陆及获取好友列表
  7. 【Kaggle从入门到放弃】(01):竞赛类型
  8. mac版idea下载(亲测有效)
  9. 【学员心得】如何三招通关云计算HCIE认证
  10. smartforms如何打印横向纵向