当前位置:   article > 正文

Hive 远程连接配置_hive远程连接

hive远程连接

Hive 远程连接配置

1、配置 hive-site.xml 中的内容

打开 hive-site.xml 搜索 hive.server2.thrift.bind.host 如果存在则修改 value 值为 本机 域名或 ip

<property>
		<name>hive.server2.thrift.bind.host</name>
		<value>syq-jtj-jzjxyth-yycx3</value>
		<description>Bind host on which to run the HiveServer2 Thrift service.</description>
</property>
  • 1
  • 2
  • 3
  • 4
  • 5

配置beeline远程客户端连接时的用户名和密码。这个用户名要在对应的hadoop的配置文件core-site.xml中也配置

  <property>
    <name>hive.server2.thrift.client.user</name>
    <value>hduser</value>
    <description>Username to use against thrift client</description>
  </property>
  <property>
    <name>hive.server2.thrift.client.password</name>
    <value>hduser</value>
    <description>Password to use against thrift client</description>
  </property>

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11

2、配置对应hadoop 中的 core-site.xml

  <property>
    <name>hive.server2.thrift.client.user</name>
    <value>hduser</value>
    <description>Username to use against thrift client</description>
  </property>
  <property>
    <name>hive.server2.thrift.client.password</name>
    <value>hduser</value>
    <description>Password to use against thrift client</description>
  </property>
	<property>
		<name>hadoop.proxyuser.root.hosts</name> <!-- root为当前Linux的用户,我的是root用户 -->
		<value>*</value>
	</property>
	<property>
		<name>hadoop.proxyuser.root.groups</name>
		<value>*</value>
	</property>
	<property>
		<name>hadoop.native.lib</name>
		<value>false</value>
	</property>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22

重启hadoop

3、验证 hive beeline 连接以及其他客户端连接

1、启动 hiveserver2 进入 hive/bin目录下 执行 ./hiveserver2 启动hive 测试阶段使用的启动方式,关闭shell 窗口 进程就自动关闭。
产线情况下启动使用后台启动方式
启动hiveserver2
beeline
!connect jdbc:hive2://localhost:10000 hive hive
后台运行
hiveserver2 nohup hive --service hiveserver2 &

[root@syq-jtj-jzjxyth-yycx3 bin]# ./hiveserver2 
which: no hbase in (/usr/jdk1.8/bin:/usr/jdk1.8/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/opt/hadoop/bin:/root/bin:/opt/hadoop/bin:/opt/hive/bin)
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/hive/lib/log4j-slf4j-impl-2.4.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/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]

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

重新打开一个shell 窗口 进入 hive/bin目录下 执行 ./beeline 如下 然后输入上面配置文件里的用户名密码 ,登录 测试beeline 连接

[root@syq-jtj-jzjxyth-yycx3 bin]# ./beeline
which: no hbase in (/usr/jdk1.8/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/opt/hadoop/bin:/root/bin)
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/hive/lib/log4j-slf4j-impl-2.4.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/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]
Beeline version 2.1.1 by Apache Hive
beeline> !connect jdbc:hive2://10.75.8.44:10000
Connecting to jdbc:hive2://10.75.8.44:10000
Enter username for jdbc:hive2://10.75.8.44:10000: hduser
Enter password for jdbc:hive2://10.75.8.44:10000: ******
Connected to: Apache Hive (version 2.1.1)
Driver: Hive JDBC (version 2.1.1)
22/04/06 22:38:26 [main]: WARN jdbc.HiveConnection: Request to set autoCommit to false; Hive does not support autoCommit=false.
Transaction isolation: TRANSACTION_REPEATABLE_READ
0: jdbc:hive2://10.75.8.44:10000> show databases;
+----------------+--+
| database_name  |
+----------------+--+
| default        |
| ods            |
+----------------+--+
2 rows selected (1.635 seconds)
0: jdbc:hive2://10.75.8.44:10000>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25

到此 hive 远程配置结束

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/你好赵伟/article/detail/570117
推荐阅读
相关标签
  

闽ICP备14008679号