Hive Beeline

简介

连接hive的driver是有3种方式的,我们这里介绍一下常用的beeline.beeline是使用jdbc去连接hive.

使用

在使用beeline去连接hive之前,我们要打开hive的hiveserver2服务,这样beeline才能通过jdbc去连接hive.

--启动hiveserver2的两种方式
hiveserver2
hive --service hiveserver2

然后我们在terminal下执行beeline,然后输入jdbc的uri

beeline
jdbc:hive2://master:10000/default

thriftserver的默认端口为10000,因此我们使用beeline去连接hiveserver2所在节点上的10000端口.
成功连接之后,还要输入连接的用户名和密码.(这个地方有个问题,要输入有执行MR程序的用户,否则在使用beeline去做查询时,会爆出权限错误.报错信息如下)

Job Submission failed with exception 'org.apache.hadoop.security.AccessControlException(Permission denied: user=hive, access=EXECUTE, inode="/tmp/hadoop-yarn":root:staff:drwx------
Hive有多种连接方式,其中一种是通过客户端beeline访问。以下是关于Hive Beeline连接的详细信息: ### 连接方式概述 Hive连接方式有cli方式(在bin目录下执行hive,相当于执行hive --service cli)、通过客户端beeline访问以及通过web ui访问,这里着重介绍通过beeline客户端访问的方法 [^1]。 ### 连接配置示例 在主机上进行连接配置的示例如下: ```plaintext [root@hadoop001 apache-hive-3.1.2-bin]# beeline beeline> !connect jdbc:hive2://192.xxx.x.xxx:10000 Enter username for jdbc:hive2://192.xxx.x.xxx:10000: root Enter password for jdbc:hive2://192.xxx.x.xxx:10000: ****(填入 root, 密码可不输入直接回车) ``` 这里显示的是主机自己的地址 [^3]。 ### 远程连接测试示例 以下是一个远程连接测试的示例: ```plaintext lcc@localhost dubhe-node$ beeline Beeline version 2.2.0 by Apache Hive beeline> !connect jdbc:hive2://localhost:10000/default SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/Users/lcc/soft/hive/hive/lib/log4j-slf4j-impl-2.6.2.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/Users/lcc/soft/hadoop/hadoop/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://localhost:10000/default Enter username for jdbc:hive2://localhost:10000/default: Enter password for jdbc:hive2://localhost:10000/default: Connected to: Apache Hive (version 2.2.0) Driver: Hive JDBC (version 2.2.0) Transaction isolation: TRANSACTION_REPEATABLE_READ 0: jdbc:hive2://localhost:10000/default> ``` 在这个过程中,可能会出现SLF4J的绑定提示,可参考提示中的链接进行解释 [^4]。 ### 相关设置 在使用Beeline连接Hive前,还需要进行一些设置,例如在Core-site.xml中设置hadoop代理用户: ```xml <property> <name>hadoop.proxyuser.hadoop.hosts</name> <value>*</value> </property> <property> <name>hadoop.proxyuser.hadoop.groups</name> <value>*</value> </property> ``` 并且需要启动hiveserver2 [^5]。 ### 连接后设置Hive参数 通过Beeline连接后,可以设置Hive参数,通过相应的操作和代码示例能够更高效地使用Hive [^2]。
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值