beeline: 新版连接Hive server的工具

beeline 连接SPARK /Hive hiveclient所在主机的jdk 1.7_51,hive 0.12和hadoop 2.3.0是从服务器端拷贝过来的,环境变量一切OK. 执行连接报了Invalid URL的错误: $ beeline Beeline version 0.12.0 by Apache Hive beeline> !connect jdbc:hive2://cloud011:10000 scan com... 阅读详情

HiveServer2 支持一个新的命令行Shell,称为Beeline,它是基于SQLLine CLI的JDBC客户端。它是从 Hive 0.11版本引入的,是Hive新的命令行客户端工具。Hive客户端工具后续将使用Beeline 替代HiveCLI ,并且后续版本也会废弃掉HiveCLI 客户端工具。

Beeline支持嵌入模式(embedded mode)和远程模式(remote mode)。在嵌入式模式下,运行嵌入式的Hive(类似Hive CLI),而远程模式可以通过Thrift连接到独立的HiveServer2进程上。从Hive 0.14版本开始,Beeline使用HiveServer2工作时,它也会从HiveServer2输出日志信息到STDERR。
下面是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
   -d <driver class>               the driver class to use
   -i <init file>                  script file for initialization
   -e <query>                      query that should be executed
   -f <exec file>                  script file that should be executed
   -w (or) --password-file <password file>  the password file to read password from
   --hiveconf property=value       Use value for given property
   --hivevar name=value            hive variable name and value
                                   This is Hive specific settings in which variables
                                   can be set at session level and referenced in Hive
                                   commands or queries.
   --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 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 display
                                   Note 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

中文意思为:

The Beeline CLI 支持以下命令行参数:    
Option    
Description    
--autoCommit=[true/false] ---进入一个自动提交模式:beeline --autoCommit=true    
--autosave=[true/false]   ---进入一个自动保存模式:beeline --autosave=true    
--color=[true/false]    ---显示用到的颜色:beeline --color=true    
--delimiterForDSV= DELIMITER ---分隔值输出格式的分隔符。默认是“|”字符。    
--fastConnect=[true/false]  ---在连接时,跳过组建表等对象:beeline --fastConnect=false    
--force=[true/false]    ---是否强制运行脚本:beeline--force=true    
--headerInterval=ROWS   ---输出的表间隔格式,默认是100: beeline --headerInterval=50    
--help ---帮助  beeline --help    
--hiveconf property=value  ---设置属性值,以防被hive.conf.restricted.list重置:beeline --hiveconf prop1=value1     
--hivevar name=value   ---设置变量名:beeline --hivevar var1=value1    
--incremental=[true/false]  ---输出增量  
--isolation=LEVEL  ---设置事务隔离级别:beeline --isolation=TRANSACTION_SERIALIZABLE    
--maxColumnWidth=MAXCOLWIDTH ---设置字符串列的最大宽度:beeline --maxColumnWidth=25    
--maxWidth=MAXWIDTH ---设置截断数据的最大宽度:beeline --maxWidth=150    
--nullemptystring=[true/false]  ---打印空字符串:beeline --nullemptystring=false    
--numberFormat=[pattern]     ---数字使用DecimalFormat:beeline --numberFormat="#,###,##0.00"    
--outputformat=[table/vertical/csv/tsv/dsv/csv2/tsv2] ---输出格式:beeline --outputformat=tsv     
--showHeader=[true/false]   ---显示查询结果的列名:beeline --showHeader=false    
--showNestedErrs=[true/false] ---显示嵌套错误:beeline --showNestedErrs=true    
--showWarnings=[true/false] ---显示警告:beeline --showWarnings=true    
--silent=[true/false]  ---减少显示的信息量:beeline --silent=true    
--truncateTable=[true/false] ---是否在客户端截断表的列       
--verbose=[true/false]  ---显示详细错误信息和调试信息:beeline --verbose=true    
-d <driver class>  ---使用一个驱动类:beeline -d driver_class    
-e <query>  ---使用一个查询语句:beeline -e "query_string"    
-f <file>  ---加载一个文件:beeline -f filepath  多个文件用-e file1 -e file2  
-n <username>  ---加载一个用户名:beeline -n valid_user    
-p <password>  ---加载一个密码:beeline -p valid_password    
-u <database URL> ---加载一个JDBC连接字符串:beeline -u db_URL  

参数说明:

这里比较相近的两个参数是 -i 与 -f  其中两个参数的主要区别从字面上就可以很好的区分了

-f 执行SQL文件后就直接退出Beeline客户端,一般编写需要执行的 HQL

-i  执行SQL文件后进行Beeline客户端。一般为初始化的参数设置  hive 中的变量。。 

看下参数说明

 -i <init file>                  script file for initialization
 -f <exec file>                  script file that should be executed

beeline 使用示例:

beeline 的用法基本与 hive-cli 用法相同,下面是一个连接示例: 以cloudera-scm 的身份 以jdbc 的方式连接远程的 hiveserver2。

执行脚本功能如下:

nohup beeline -u jdbc:hive2://10.180.0.26:10000  -n cloudera-scm 
--color=true --silent=false  
--hivevar p_date=${partitionDate} --hivevar f_date=${fileLocDate} 
-f hdfs_add_partition_dmp_clearlog.hql  >> $logdir/load_${curDate}.log

通过jdbc 连接到beeline 就可以对 hive 进行操作了。

过程示意图如下:

我们再来看看看beeline 中除了SQL 操作,还支持什么别的操作。

执行help,则输出如下

!addlocaldriverjar  Add driver jar file in the beeline client side.
!addlocaldrivername Add driver name that needs to be supported in the beeline
                    client 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 as
                    empty string. Default is false.
!outputformat       Set the output format for displaying results
                    (table,vertical,csv2,dsv,tsv2,xmlattrs,xmlelements, and
                    deprecated 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 on
 
Comments, bug reports, and patches go to ???

常用的几个指令:

1、!connect url –连接不同的Hive2服务器  
2、!exit –退出shell  
3、!help –显示全部命令列表  
4、!verbose –显示查询追加的明细  

Hive beeline方式连接Could not open connection to the HS2 server。 首先,这其实是一个悲伤的故事。 中午装了一个三台测试机,一顿操作猛如喵之后,终于轮到hive的安装配置了。 在淡定的解压完,配置文件都配置完,启动了hiveserver2之后,就在我颤抖的小手在键盘上输入 bin/beeline beeline> !connect jdbc:hive2://node03.hadoop.com:10000 哦豁 Could not open connecti... 阅读详情

相关推荐

Spark-SQL连接Hive 的五种方法

因为 Spark Thrift Server 的接口和协议都和 HiveServer2 完全一致,因此我们部署好 Spark Thrift Server 后,可以直接使用 hive 的 beeline 访问 Spark Thrift Server 执行相关语句。3.运行bin/目录下的spark-sql.cmd 或者打开cmd,在 D:\spark\spark-3.0.0-bin-hadoop3.2\bin当中直接运行spark-sql。5.到spark的bin目录下打开spark-shell.cmd。

weixin_60343288的博客 6381

hive的两种连接方式1.Cli 2.Beeline

l 任务:启动hiveserver2服务,并通过beeline命令连接hive和基本的HQL操作。//DISTRIBUTE BY类似于mysql的group by,进行分区操作。2. 用beeline客户端连接hive 注意替换为自己的主机名。//hive不区分大小写,这里将关键字用大写表示,以作提示之用。在xshell中,直接输入hive,即可连接hive。// 执行TDH Client的init.sh脚本。1. 通过hive命令来连接hive。//sort进行的时map端排序。

weixin_53589204的博客 1264

codesys【modbusRTU】主站

【代码】modbusRTU【codesys】

cfqq1989的博客 4371

新一代Hive客户端工具:Beeline

Hive客户端工具后续将使用Beeline 替代HiveCLI ,并且后续版本也会废弃掉HiveCLI 客户端工具。 Beeline是Hive新的命令行客户端工具。Beeline是从 Hive 0.11版本引入的。 HiveServer2 支持一个新的命令行Shell,称为Beeline,它是基于SQLLine CLI的JDBC客户端。Beeline支持嵌入模式(embedded mode)和远程

DataFlow范式 2万+

COMSOL实战:如何用有限元法(FEM)准确仿真电磁场问题?避坑指南

本文是一份COMSOL电磁场仿真实战指南,重点讲解如何运用有限元法(FEM)准确模拟电磁场问题。文章通过矩形波导和偶极子天线两大经典案例,详细剖析了从几何建模、物理场设置、网格剖分到结果验证的全流程,并提供了处理非线性材料、求解器收敛失败等高级问题的避坑技巧,旨在帮助工程师建立可靠的仿真工作流。

weixin_29297127的博客 512

视觉辅助RIS波束追踪:用摄像头“看见”用户,实现毫秒级波束对准

在无线通信领域,波束成形技术是提升高频段信号覆盖与质量的核心手段,其原理是通过调整天线阵列的相位,使信号能量在特定方向相干叠加,形成高增益定向波束。这项技术的价值在于能有效克服高频信号路径损耗大、穿透性差的瓶颈,广泛应用于5G/6G、毫米波通信及室内定位等场景。然而,传统波束追踪依赖信道估计或波束扫描,存在训练开销大、实时性差的问题。本文聚焦于一种创新解决方案:将计算机视觉与可重构智能表面(RIS)相结合。通过摄像头直接感知用户位置,并利用RIS快速重构反射波束方向,实现了近乎零开销、毫秒级延迟的波束追踪,

weixin_33552698的博客 620

华为MRS_HADOOP集群 beeline使用操作

后面通过请教开发得知,华为集群采kerberos认证方式,需要先安装hive客户端并在每次执行beeline前进行kerberos认证(类似登录)且仅在当前ssh会话中有效,然后再执行相关命令即可。由于项目测试需要,计划在华为hadoop集群hive上创建大量表,并且每表植入10w数据,之前分享过如何快速构造hive大表,感兴趣的可以去找一下。但是执行过程中发现速度远不及预期,单表复制新建耗时约1.5s,但是批量sql执行后,越来越慢,目标需要创建上万数据表,因此速度上不满足使用需求。

qy_getforward的博客 1253

迪文串口屏开发环境搭建全流程:从DGUS Tool到串口联调

串口屏作为嵌入式人机交互的核心组件,通过串口通信实现主控MCU与显示终端的指令交互。其工作原理基于变量地址映射,主控读写VP地址即可驱动屏上控件,兼具低功耗与高稳定性。在工业控制、医疗设备及智能家居面板等场景中,串口屏能显著降低开发门槛与硬件成本。迪文屏凭借DGUS Tool上位机与自定义串口协议,成为主流选择。掌握DGUS Tool版本匹配、串口驱动安装及VP地址规划,是快速搭建开发环境的关键。

weixin_33937499的博客 603

hive学习总结

目录 一、是什么 (1)Hive的几个特点 (2)Hive架构 (3)Hive的核心 (4)Hive的底层存储 (5)Hive语句的执行过程 二、安装部署 三、连接hive (1)通过beeline连接 (2)直接连接 四、表 1 、表的分类 (1)管理表(内部表) (2)外部表 (3)分区表 2、创建表 3、重命名表 4、增加/修改/替换列信息 5、复...

大雄号的博客 2550

Embedding理解及keras中Embedding参数详解,代码案例说明

Embedding理解 嵌入层将正整数(下标)转换为具有固定大小的向量 ------官网 词嵌入是一种语义空间到向量空间的映射,简单说就是把每个词语都转换为固定维数的向量,并且保证语义接近的两个词转化为向量后,这两个向量的相似度也高。 举例说明embedding过程: “Could have done better” 通过索引对该句子进行编码,每个单词分配一个索引,上面的句子就会变成这样: 122 8 114 12 创建嵌入矩阵,即每一个索引需要分配多少维向量,也就是说每个词需要转化为多少维

wo的博客 1万+

vectorCast——Probe point 功能实现故障注入,局部变量打印,断点调试。

选择一个测试用例,选择coverage窗口进行查看。点击edit probe point,如图所示绿色的小圆圈。 选代码中选择需要打断点的地方进行点击。黑色的小圆点都可以选。 点击黑色小圆点,小圆点变绿,表示打断点成功。 此时就可以根据自己的需求在打断点的位置编写一些C语言的命令语句。 点击编译,成功会弹出窗口显示编译成功,失败会在下方报错error,并显示错误的原因。 点击应用保存,选择yes to all就可以了。 点击用例执行就可以看到打断点情况下的执行结果了。

weixin_59334478的博客 2068

shell一键启动hive脚本

hive交互方式一般有三种: 1) bin/hive 2)使用SQL脚本或文件进行交互 3)beeline client 本文的一键启动脚本采用第三种交互方式beeline client,以下是建立脚本需要的步骤: 1.安装except yum install -y except 2.建立expect脚本启动beeline,并登入hive #!/bin/expect spawn beeline set timeout 5 expect "beeline>"...

浩瀚蓝天dep的博客 1644

SAP_FI模块_固定资产期初导入全流程(含导入代码)

SAP 期初导入资产主数据以及金额相关的操作全流程记录,包含了批导程序的代码,以及错误记录

风沙的博客 1404

hive的beeline使用

Hive CLI是一种重客户端,在新版本中已移除,推荐使用Hive beeline客户端,可以更好地实现安全控制,下面讲讲beeline的使用。 在hive1.1.0中使用Hive CLI会提示WARNING: Hive CLI is deprecated and migration to Beeline is recommended. 无kerberos的hive beeline !connect jdbc:hive2://centos:10000 username password 对于没有开启.

data2tech的博客 3546

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

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

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

远程连接hive server

hiveserver2 1、在hive服务器上启动hive server2,在你的hive主目录/bin/下找到并执行下面的命令,默认监听10000端口 #hiveserver2 2、使用cli在本机连接 #beeline beeline> !connect jdbc:hive2://localhost:10000 user pwd user和pwd可以随便写的,连接后,可以执

will的成长之路 1万+

android 蓝牙通讯demo

android 下蓝牙通讯demo,实现了发现蓝牙,使能蓝牙,通过蓝牙发送消息。

hive后台运行另外使用beeline进行连接 *

命令 nohup hive --service hiveserver2 & hive默认账号密码 如果没进行特殊设置的话, hive默认账号密码是 NONE 使用beeline进行连接 打开另外一个crt终端 [root@zjj101 ~]# beeline Beeline version 1.2.1 by Apache Hive beeline> !connect jdbc:hive2://ip:10000/default Connecting to jdbc:hive2://ip

张俊杰 的博客 1037

霍尼韦尔SoftMaster使用说明

霍尼韦尔SoftMaster使用说明

用 beeline 连接 SparkSQL

用 beeline 连接 SparkSQL

wzy0623的专栏 1万+

hiveserver2 和beeline_Hive-cli与Beeline的区别

Hive-cli与Beeline的区别hive-cli 是hive连接hivesever的命令行工具,从hive出生就一直存在,但随着hive功能的增强、bug的修复、版本升级,hive-cli结构的局限性跟不上hive的发展,如果强行更改就不能满足向下兼容,就出现了全新的beeline命令行结构,即就是hive-cli能做的事beeline都能做,而beeline能做的事hive-cli不一定能...

weixin_39928844的博客 1059

beeline连接hive的hiveserver2报错

问题: Connecting to jdbc:hive2://hadoop102:10000 20/06/27 14:17:38 [main]: WARN jdbc.HiveConnection: Failed to connect to hadoop102:10000 Could not open connection to the HS2 server. Please check the server URI and if the URI is correct, then ask the admin

zhuyao3582的博客 3576

thriftserver和beeline的使用,代码连接server(连接hive)

启动thriftserver: ./sbin/start-thriftserver.sh --master local --jars ~/software/mysql-connector-java-5.1.27-bin.jar –master ;指定运行模式 –jars :导入mysql依赖包 这样就算启动成功了 接下来启动beeline ./bin/beeline -u jdbc:hi...

weixin_46235157的博客 633

Hive beeline和Spark SQL兼容Hive – 配置

Hive beeline和Spark SQL兼容Hive – 配置 Hive beeline 上面安装后直接输入hive是CLI的操作方式,在后面可能会被舍弃掉,换用beeline方式去连接,因为目前使用CLI的人比较多,所以还暂未舍弃 1.打开hiveserver2的服务:nohup KaTeX parse error: Expected 'EOF', got '&' at positi...

没有合适的昵称 3180

hive 配置用户名_HIVE2 :beeline连接设置用户名和密码注意问题

beeline connect有几种方式,见hive-site.xml,缺省为NONE。hive.server2.authenticationNONEExpects one of [nosasl, none, ldap, kerberos, pam, custom].Client authentication types.NONE: no authentication checkLDAP: LDA...

weixin_39816024的博客 2365

hivecontex释放mysql连接_通过beeline连接到hive时,自动关闭连接了

这个server2的log... 41 more2016-05-05 08:36:02,911 WARN [main]: hive.metastore (HiveMetaStoreClient.java:open(439)) - set_ugi() not successful, Likely cause: new client talking to old server. Continuing...

weixin_36165398的博客 783

beeline连接hive时报错<小记>

由于权限配置问题导致的。具体来说,User: guohailong is not allowed to impersonate anonymous 表示当前用户在尝试以匿名身份进行操作时没有足够的权限。在hive-site.xml添加配置。

m0_74195889的博客 694
上一篇: 清理 Nexus 中无用的 Docker 镜像 步骤
下一篇: Node.js web Docker 化
大树叶
博客等级 码龄12年 1171粉丝 664原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值