Beeline 要与HiveServer2配合使用,支持嵌入模式和远程模式

Hive与Hadoop实现整合实战 顾名思义,这是hive上启动的一个服务,早期的hive版本中,启动的服务是HiveServer,此服务启动后,hive客户端就可以通过IP加端口的方式对hive进行访问,此服务主要用于远程客户端使用各种编程语言向Hive提交请求并查询结果的情况。beeline模式是将SQL提交到hiveserver2,然后由hiveserver2负责编译,接着hiveserver2再去访问MetaStore,最后将分析任务提交到hadoop上,相对于Hive CLI,beeline是轻客户端模式。下载hive二进制版本。 阅读详情

 

启动HiverServer2 , ./bin/hiveserver2 

启动Beeline 

wangyue@wangyue-um:~/opt/hive/hive-0.12.0-cdh5.1.0$ ./bin/beeline 

beeline> !connect jdbc:hive2://localhost:10000

默认 用户名就是登录账号 密码为空

 

Beeline with NoSASL connection

If you'd like to connect via NOSASL mode, you must specify the authentication mode explicitly:

% bin/beeline
beeline> !connect jdbc:hive2://<host>:<port>/<db>;auth=noSasl hiveuser pass org.apache.hive.jdbc.HiveDriver

 

Beeline Commands

Command

Description

!<SQLLine command>

List of SQLLine commands available at http://sqlline.sourceforge.net/.

Example: !quit exits the Beeline client.

 

 

 

Beeline Command Options

 

The Beeline CLI supports these command line options:

Option

Description

-u <database URL>

The JDBC URL to connect to.

Usage: beeline -u db_URL 

-n <username>

The username to connect as.

Usage: beeline -n valid_user

-p <password>

The password to connect as.

Usage: beeline -p valid_password

-d <driver class>

The driver class to use.

Usage: beeline -d driver_class

-e <query>

Query that should be executed. Double or single quotes enclose the query string. This option can be specified multiple times.

Usage: beeline -e "query_string"

Support to run multiple sql statements separated by semicolons in a single query_string: 1.2.0 (HIVE-9877)
Bug to be fixed (running -e in background): workaround available (HIVE-6758)Bug fix (null pointer exception): 0.13.0 (HIVE-5765)

Bug fix (--headerInterval not honored): 0.14.0 (HIVE-7647)

-f <file>

Script file that should be executed.

Usage: beeline -f filepath

Version: 0.12.0 (HIVE-4268)
Note: If the script contains tabs, query compilation fails in version 0.12.0. This bug is fixed in version 0.13.0 (HIVE-6359).

Bug to be fixed (running -f in background): workaround available (HIVE-6758)

--hiveconf property=value

Use value for the given configuration property. Properties that are listed in hive.conf.restricted.list cannot be reset with hiveconf (see Restricted List and Whitelist).

Usage: beeline --hiveconf prop1=value1

Version: 0.13.0 (HIVE-6173)

--hivevar name=value

Hive variable name and value. This is a Hive-specific setting in which variables can be set 
at the session level and referenced in Hive commands or queries.

Usage: beeline --hivevar var1=value1

--color=[true/false]

Control whether color is used for display. Default is false.

Usage: beeline --color=true

(Not supported for Separated-Value Output formats. See HIVE-9770)

--showHeader=[true/false]

Show column names in query results (true) or not (false). Default is true.

Usage: beeline --showHeader=false

--headerInterval=ROWS

The interval for redisplaying column headers, in number of rows, when outputformat is table. 
Default is 100.

Usage: beeline --headerInterval=50

(Not supported for Separated-Value Output formats. See HIVE-9770)

--fastConnect=[true/false]

When connecting, skip building a list of all tables and columns for tab-completion of 
HiveQL statements (true) or build the list (false). Default is true.

Usage: beeline --fastConnect=false

--autoCommit=[true/false]

Enable/disable automatic transaction commit. Default is false.

Usage: beeline --autoCommit=true

--verbose=[true/false]

Show verbose error messages and debug information (true) or do not show (false). 
Default is false.

Usage: beeline --verbose=true

--showWarnings=[true/false]

Display warnings that are reported on the connection after issuing any HiveQL commands. 
Default is false.

Usage: beeline --showWarnings=true

--showNestedErrs=[true/false]

Display nested errors. Default is false.

Usage: beeline --showNestedErrs=true

--numberFormat=[pattern]

Format numbers using a DecimalFormat pattern.

Usage: beeline --numberFormat="#,###,##0.00"

--force=[true/false]

Continue running script even after errors (true) or do not continue (false). Default is false.

Usage: beeline--force=true

--maxWidth=MAXWIDTH

The maximum width to display before truncating data, in characters, when outputformat is table. 
Default is to query the terminal for current width, then fall back to 80.

Usage: beeline --maxWidth=150

--maxColumnWidth=MAXCOLWIDTH

The maximum column width, in characters, when outputformat is table. Default is 15.

Usage: beeline --maxColumnWidth=25

--silent=[true/false]

Reduce the amount of informational messages displayed (true) or not (false). It also stops displaying the log messages for the query from HiveServer2 (Hive 0.14 and later) and the HiveQL commands (Hive 1.2.0 and later). Default is false.

Usage: beeline --silent=true

--autosave=[true/false]

Automatically save preferences (true) or do not autosave (false). Default is false.

Usage: beeline --autosave=true

--outputformat=[table/vertical/csv/tsv/dsv/csv2/tsv2]

Format mode for result display. Default is table. See Separated-Value Output Formats below for description of recommended sv options.

Usage: beeline --outputformat=tsv

Version: dsv/csv2/tsv2 added in 0.14.0 (HIVE-8615)

--truncateTable=[true/false]

If true, truncates table column in the console when it exceeds console length.

Version: 0.14.0 (HIVE-6928)

--delimiterForDSV= DELIMITER

The delimiter for delimiter-separated values output format. Default is '|' character.

Version: 0.14.0 (HIVE-7390)

--isolation=LEVEL

Set the transaction isolation level to TRANSACTION_READ_COMMITTED 
or TRANSACTION_SERIALIZABLE. 
See the "Field Detail" section in the Java Connection documentation.

Usage: beeline --isolation=TRANSACTION_SERIALIZABLE

--nullemptystring=[true/false]

Use historic behavior of printing null as empty string (true) or use current behavior of printing 
null as NULL (false). Default is false.

Usage: beeline --nullemptystring=false

Version: 0.13.0 (HIVE-4485)

--incremental=[true/false]

Print output incrementally.

--help

Display a usage message.

Usage: beeline --help

 

 

 

Server Connection

Hive CLI connects to a remote HiveServer1 instance using the Thrift protocol. To connect to a server, you specify the host name and optionally the port number of the remote server:

 

 

 

1

2

>hive-h<hostname>-p

<port>

 

 

In contrast, Beeline connects to a remote HiveServer2 instance using JDBC. Thus, the connection parameter is a JDBC URL that’s common in JDBC-based clients:

 

 

 

1

2

>beeline-u  <url>-n<username>-p

<password>

 

 

Query Execution

Executing queries in Beeline is very similar to that in Hive CLI. In Hive CLI:

 

 

 

1

2

>hive-e<query inquotes>

>hive-f<query file name>

 

 

In Beeline:

 

 

 

1

2

>beeline-e<queryinquotes>

>beeline-f<queryfilename>

 

 

 

Another important command is !quit (or !q), which allows you to exit interactive mode:

 

 

 

1

2

0:jdbc:hive2://> !quit

Closing:org.apache.hive.jdbc.HiveConnection

 

 

https://cwiki.apache.org/confluence/display/Hive/HiveServer2+Clients

http://blog.cloudera.com/blog/2014/02/migrating-from-hive-cli-to-beeline-a-primer/

尊重原创,未经允许不得转载:http://blog.youkuaiyun.com/stark_summer/article/details/45844403

 

0 
顶

0 
踩

分享到:  

基于spark1.3.1的spark-sql实战-02 | 基于spark1.3.1的spark-sql实战-01

评论

发表评论

 您还没有登录,请您登录后再发表评论

相关资源推荐

上滑加载更多

Cadence Virtuoso实战:3分钟搞定反相器参数化设计(附CDF配置避坑指南) 本文详细介绍了如何在Cadence Virtuoso中利用CDF参数传递功能实现反相器的参数化设计,包括PMOS和NMOS的基础搭建、CDF配置技巧及常见报错解决方案。通过实战案例和避坑指南,帮助工程师快速掌握高效设计方法,提升集成电路设计效率。 阅读详情

相关推荐

ubuntu20.04升级OpenSSH

业务需求,需要将服务器的OpenSSH版本从8.2升级到最新版本(9.9),由于apt能提供的最新版本就是8.2,所以需要采用源码安装的方式。

xiamu66的博客 1527

Hudi同步Hive表报“Cannot create hive connection jdbc:hive2://localhost:10000/”错误的解决方法

让Hudi自动同步元数据到Hive Metastore,我们需要对Hudi进行一些必要的配置,根据官方文档( https://hudi.apache.org/docs/configurations.html#hive-sync-options )给出的说明,标准的Hudi Hive Sync配置应该是这样的: 首先是最基本的三项: DataSourceWriteOptions.HIVE_SYNC_ENABLED_OPT_KEY -> "true" DataSourceWriteOptions.HIVE

Laurence的技术博客 2056

Outlook邮件规则实战:从自动化分类到GTD工作流整合

在信息过载的数字化办公环境中,自动化处理技术成为提升效率的关键。其核心原理是基于“条件-动作”的触发器模型,通过预设逻辑让系统自动执行重复性任务。这种自动化机制的技术价值在于将用户从繁琐的机械操作中解放出来,实现信息流的智能管控。在邮件管理这一典型应用场景中,自动化规则能精准处理项目邮件聚合、优先级分流等复杂需求。本文聚焦于微软Outlook的规则引擎,深入解析如何利用**规则引擎**和**触发器模型**构建高效的邮件处理系统,并进一步将其融入GTD(Getting Things Done)个人生产力框架,

weixin_31083901的博客 313

启动hiveserver2连接不上jdbc:hive2://localhost:10000

启动hiveserver2连接不上localhost:10000 进入hive的bin目录 $ cd /Users/zheng/hive/hive-3.1.2/bin #启动hivever2 $ hiveserver2 #显示如下表示已经成功打开 2020-04-09 22:34:21: Starting HiveServer2 SLF4J: Class path contains mult...

记录 1万+

RK3588开发板RKNPU2环境部署实战:更新rknn_server与librknnrt.so详解

本文详细介绍了在RK3588开发板上更新rknn_server与librknnrt.so核心组件的完整实战流程。通过adb工具推送文件、设置权限并执行同步操作,确保RKNPU2环境部署成功,从而解决推理速度慢或初始化失败等问题,提升AI模型运行效率与稳定性。

weixin_29194817的博客 347

MacOS多次踩坑后成功安装Homebrew

来一次性成功安装Homebrew吧 官网提供的安装脚本无法成功安装Homebrew,原因大家都懂的,故采用脚本安装的方式。 下载homebrew的安装脚本brew_install 在Download路径下执行如下脚本 curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install >> brew_install 修改brew_install脚本 修改brew_install脚本。如果你的脚本打开之后是如下

weixin_41847116的博客 1983

beeline安装_hive beeline详解

Hive客户端工具后续将使用Beeline替代HiveCLI,并且后续版本也会废弃掉HiveCLI客户端工具,Beeline是Hive 0.11版本引入的新命令行客户端工具,它是基于SQLLine CLI的JDBC客户端。Beeline支持嵌入模式(embedded mode)和远程模式(remote mode)。在嵌入式模式下,运行嵌入式的Hive(类似Hive CLI),而远程模式可以...

weixin_39774644的博客 3814

Ollama运行DeepSeek大模型调优指南:GPU与CPU协同实现性能最大化

Ollama运行DeepSeek大模型调优指南

qq_32358423的博客 3999

hive -e 和 -f 通过beeline执行文件中的hive sql语句

1. 在服务器命令行中直接执行sql语句或者sql文件中的内容 有时需要在命令行中直接执行hive sql语句,希望不进入hive模式执行,这时候就可以使用hive -e 或者 hive -f 来实现 1. hive -e 和 hive -f 2. beeline -f ,beeline使用 beeline -u "jdbc:hive2://localhost:10000" -n yourname -p passwore -f hivescript.sql beeline使用方式请..

litlit023的专栏 1万+

W25N01GV SPI NAND Flash驱动开发避坑指南:详解2KB缓冲区机制与状态寄存器正确用法

本文深入解析W25N01GV SPI NAND Flash芯片的2KB缓冲区机制与状态寄存器正确用法,提供STM32 HAL和ESP-IDF项目的实战解决方案。涵盖双阶段操作原理、状态寄存器深度解析、时序控制优化及跨平台驱动设计要点,帮助开发者避免常见错误并提升存储性能。

aizhouqian5537的博客 640

使用Python爬取在线图书馆的图书馆藏和阅读记录

通过使用Python编写爬虫程序,我们可以从在线图书馆上获取图书馆藏和阅读记录,帮助人们更好地管理和利用图书馆资源。本文简要介绍了爬虫程序的准备工作、网页解析和数据提取、数据的保存和处理的关键步骤,并提供了一个示例代码。在实际应用中,我们需要注意遵守在线图书馆的使用规则和爬虫道德准则,确保合法、合规地进行爬取操作。以上仅为概述,实际应用的过程中可能需要根据具体需求进行适当的调整和改进。

2201_76125393的博客 730

hive之beeline连接与操作

hive之beeline连接与操作一、连接配置1.连接测试1.1前提1.2启动hive服务1.3测试连接2.问题解决1.解决方式2.连接二、操作1.beeline操作 一、连接配置 1.连接测试 1.1前提 hadoop集群、hive已正常安装,hadoop集群已启动 1.2启动hive服务 先启动 metastore 服务:nohup metastore 2>/usr/data/hive/log/metastore/metastore.err & 再启动 hiveserver2 服务:noh

tiki的博客 3万+

【2023年】云计算比赛——金砖挑战赛正式题

文章摘要 本文详细记录了OpenStack私有云平台与Kubernetes容器云平台的部署与运维过程,涵盖环境初始化、组件安装、服务配置及自动化运维等关键任务。主要内容包括: OpenStack部署 环境初始化(主机名、Yum源、FTP服务等) 核心组件安装(Keystone、Glance、Nova、Neutron等) 运维任务(安全组管理、镜像上传、存储服务配置等) Kubernetes集群搭建 节点配置(时间同步、免密登录) 容器运行时(Docker)与网络插件(Flannel)部署 Harbor私有仓

geekgold的博客 313

Hive详解之beeline和Hive jdbc

1、Hive2 beeline Beeline 要与HiveServer2配合使用,支持嵌入模式和远程模式 启动beeline 打开两个Shell窗口,一个启动Hive2 一个beeline连接hive2 #启动HiverServer2 ,./bin/hiveserver2 [root@node5 ~]# hiveserver2 16/02/23 22:55:25 WARN con...

lixinkuan的博客 3699

jre9下载 jdk9

(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

Hive2 beeline 使用方法

Hive2 beeline –Beeline 要与HiveServer2配合使用,支持嵌入模式和远程模式 –启动HiverServer2 ,./bin/hiveserver2 –启动Beeline –wangyue@wangyue-um:~/opt/hive/hive-0.12.0-cdh5.1.0$ ./bin/beeline –beeline&gt...

677

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

HiveServer2 入门使用

Beeline – 一个新的命令行Shell HiveServer2 supports a new command shell Beeline that works with HiveServer2. It's a JDBC client that is based on the SQLLine CLI (http://sqlline.sourceforge.net/). There’s

stark_summer的专栏 3万+

Outlook Express 6 (OE6) for Win7/Win8/Win10

英文版 Outlook Express6.0, 兼容Win7/Win10/WinXP,解压就可用。

Hive 8、Hive2 beeline 和 Hive jdbc

1、Hive2 beeline Beeline 要与HiveServer2配合使用,支持嵌入模式和远程模式 启动beeline 打开两个Shell窗口,一个启动Hive2 一个beeline连接hive2 #启动HiverServer2 , ./bin/hiveserver2 [root@node5 ~]# hiveserver2 16/02/23 22:55:25 ...

aohuang8877的博客 163

hive、impala的客户端,cli、beeline、WebHCat

连接hive有2种形式,shell和jdbc(beeline) 一、shell 二、beeline 整合kerberos时设置要principal是hive服务的,登录用户是krb认证的,krb认证谁beeline当前用户就是谁。 ...

DCHAO的博客 3845

hive的元数据Derby,命令行工具 beeline

安装mysql用于存储hive的元数据 Hive默认数据库类型Derby hive 默认使用Derby作为Hive metastore的存储数据库,这个数据库更多用于单元测试,只支持一个用户访问,在生产环境,建议改成功能更强大的关系型数据库,根据官网的介绍,支持用于存储hive元数据的数据库如下: hive元数据支持的数据库 最低版本要求 MySQL 5.6.17 Postgres 9.1.13 Oracle 11g MS SQL Server 2008.

now 459

17.2. beeline

beeline 是 hive 提供的一个新的命令行工具,基于SQLLine CLI的JDBC客户端,beeline 与HiveServer2配合使用,支持嵌入模式和远程模式两种,可以像hive client一样访问本机的hive服务,也可以通过指定ip和端口访问远程hive服务。 hive 官方是推荐使用beeline,因为它还提供了更为友好的交互方式(...

weixin_34260991的博客 359

Hive 8、Hive2 beeline 和 Hive jdbc,Hive的UDF、UDAF、UDTF

1、Hive2 beeline  Beeline 要与HiveServer2配合使用,支持嵌入模式和远程模式 启动beeline 打开两个Shell窗口,一个启动Hive2 一个beeline连接hive2 #启动HiverServer2 , ./bin/hiveserver2  [root@node5 ~]# hiveserver2 16/02/23 22:55:25 WARN co

HuFeiHu 1837
上一篇: 邮件、短信、微信、电话发送接口
下一篇: hive中简单介绍分区表(partition table),含动态分区(dynamic partition)与静态分区(static partition)
王树民
博客等级 码龄10年 912粉丝 560原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值