hive beeline连接

hive需要的jar包(可以在hive/lib里拿)
hadoop-common
hive-exec
hive-jdbc
hive-metastore
hive-service
hive-service-rpc (可能和上方jar包冲突,加exclusion)
httpclient
httpcore
slf4j-api

beeline 连接Hive
Hive的连接方式:
1.cli方式
在bin目录下执行hive,相当于执行的hive --service cli
2.通过客户端beeline访问hive
3.还有一种是通过web ui访问
这里记录的是通过beeline客户端访问

1.修改hadoop配置文件hdfs-site.xml,表示启用webhdfs

<property>
<name>dfs.webhdfs.enabled</name>
<value>true</value>
</property>

2.修改hadoop配置文件core-site.xml,表示设置可访问的用户及用户组

<property>
<name>hadoop.proxyuser.root.hosts</name>
<value>*</value>
</property>
<property>
<name>hadoop.proxyuser.root.groups</name>
<value>*</value>
</property>

将配置文件同步到其他节点

scp -r hdfs-site.xml node1:$PWD

3.修改hive的配置文档hive-site.xml

<property>
<name>hive.server2.thrift.bind.host</name>
<value>node1</value>
<description>Bind host on which to run the HiveServer2 Thrift service.</description>
</property>

<property>
<name>hive.server2.thrift.port</name>
<value>11000</value>
<description>Port number of HiveServer2 Thrift interface when hive.server2.transport.mode is 'binary'.</description>
</property>

4.重启hadoop
stop-all.sh
start-all.sh

5.启动hiveserver2

[root@node1 conf]# hiveserver2
which: no hbase in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:JAVA_HOME/bin:/home/hadoop-3.2.0/bin:/home/hadoop-3.2.0/sbin:/usr/local/hive-3.1.1/bin:/usr/local/mysql-5.7.26/bin:/root/bin)
2019-05-24 03:36:40: Starting HiveServer2
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/usr/local/hive-3.1.1/lib/log4j-slf4j-impl-2.10.0.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/hadoop-3.2.0/share/hadoop/common/lib/slf4j-log4j12-1.7.25.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]
Hive Session ID = d64c0a40-4e99-4764-85ef-a1073e143249

6.在客户端使用beeline访问hive

[root@node1 conf]# beeline
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/usr/local/hive-3.1.1/lib/log4j-slf4j-impl-2.10.0.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/hadoop-3.2.0/share/hadoop/common/lib/slf4j-log4j12-1.7.25.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]
Beeline version 3.1.1 by Apache Hive

beeline> !connect jdbc:hive2://node1:11000/testdb
Connecting to jdbc:hive2://node1:11000/testdb
Enter username for jdbc:hive2://node1:11000/testdb: root
Enter password for jdbc:hive2://node1:11000/testdb: ********
Connected to: Apache Hive (version 3.1.1)
Driver: Hive JDBC (version 3.1.1)
Transaction isolation: TRANSACTION_REPEATABLE_READ
0: jdbc:hive2://node1:11000/testdb>

查看端口(执行hiveserver2后可能需要等两分钟端口才能查看得到)
netstat -nat | grep 11000

show tables;
使用hive sql

此文为转载

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值