远程连接Hiveserver2服务

目录

1.修改 core-site.xml 和 hive-site.xml 的配置文件

2.启动HiveServer2服务

3.启动Beeline工具连接Hiveserver2服务

4.利用IDEA工具连接Hiveserver2服务

完成Hive本地模式安装后,可以启动hiveserver2服务进行远程连接和操作Hive。

1.修改 core-site.xml 和 hive-site.xml 的配置文件

修改core-site.xml

​[root@master ~]# cd /opt/module/hadoop-3.1.3/etc/hadoop
[root@master hadoop]#vi core-site.xml

 在文件</configuration>标签上方加入以下内容

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

将更改的配置文件分发给slave1、slave2主机

[root@master hadoop]# scp core-site.xml slave1:/opt/module/hadoop-3.1.3/etc/hadoop/
[root@master hadoop]# scp core-site.xml slave2:/opt/module/hadoop-3.1.3/etc/hadoop/

修改hive-site.xml

[root@master hadoop]# cd /opt/module/hive/conf/
[root@master conf]# vi hive-site.xml

 在文件</configuration>标签上方加入以下内容

<!-- 指定 hiveserver2 连接的 host -->
<property>
        <name>hive.server2.thrift.bind.host</name>
        <value>master</value>
</property>

<!-- 指定 hiveserver2 连接的端口号 -->
<property>
        <name>hive.server2.thrift.port</name>
        <value>10000</value>
</property>

2.启动HiveServer2服务

   后台启动HiveServer2服务

[root@master conf]#hive --service hiveserver2 &

   后台启动metastore服务 

[root@master conf]# hive --service metastore &

关闭服务 kill -9 进程号

3.启动Beeline工具连接Hiveserver2服务

可以打开一个master主机新窗口,输入以下命令

[root@master conf]# beeline
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/module/hive/lib/log4j-slf4j-impl-2.10.0.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/module/hadoop-3.1.3/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.2 by Apache Hive
beeline> !connect jdbc:hive2://master:10000 -n root -p 123456
Connected to: Apache Hive (version 3.1.2)
Driver: Hive JDBC (version 3.1.2)
Transaction isolation: TRANSACTION_REPEATABLE_READ
0: jdbc:hive2://master:10000>

输入!quit命令可以断开Hiveserver2服务

4.利用IDEA工具连接Hiveserver2服务

启动IDEA软件,打开任何一个项目即可。

点击右侧Database菜单项,配置Apache HiveDriver。

 测试连接是否成功

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值