Error: Could not open client transport with JDBC Uri: jdbc:hive2://slave3:10000: java.net.ConnectExc

HIVE客户端连接服务端:拒绝连接 问题

报错如下:

WARN jdbc.HiveConnection: Failed to connect to slave3:10000
Could not open connection to the HS2 server. Please check the server URI and if the URI is correct, then ask the administrator to check the server status.
Error: Could not open client transport with JDBC Uri: jdbc:hive2://slave3:10000: java.net.ConnectException: 拒绝连接 (Connection refused) (state=08S01,code=0)

原因是因为hive服务没有启动

执行命令:hive --service hiveserver2 &

客户端连接成功

 

转载自:https://blog.youkuaiyun.com/zt15732625878/article/details/87562838

 

 

我在弄hive的安装和配置,我在完成Linux中的任务,请帮我根据文档要求完成操作。以下是我的虚拟机信息: 虚拟机版本: CentOS7 用户名为: wyy0212 虚拟机master IP为192.168.161.130 hive压缩包路径/home/wyy0212/apache-hive-3.1.2-bin.tar.gz hadoop路径: /export/server/hadoop hadoop版本: 3.3.3 jdk路径: /export/server/jdk jdk版本: 1.8.0_202 mysql路径: /root/export/server/hadoop/bin/hadoop mysql版本: mysql Ver 15.1 Distrib 5.5.68-MariaDB 目前我在master虚拟机,当前所在路径:/export/server 所有操作均在root下完成(包括master和slave) 我要求一个零基础的终极详细教程,提供从第一步开始的完整操作流程,每个命令都要给出,包括每一步的命令和操作,以及所有代码和配置文件的完整路径和完整内容。涉及编辑的都使用vi 必须提供可以直接复制粘贴的代码和配置文件。请务必详细,不要跳过任何步骤。谢谢。但是现在我遇到问题了[root@master server]# [root@master server]# # 重命名为 hive(简洁) [root@master server]# mv apache-hive-3.1.2-bin hive [root@master server]# vi /etc/profile [root@master server]# source /etc/profile [root@master server]# echo $HIVE_HOME /export/server/hive [root@master server]# cd /export/server/hive/lib [root@master lib]# [root@master lib]# # 删除 Hive 自带的旧版 guava [root@master lib]# rm -f guava-19.0.jar [root@master lib]# [root@master lib]# # 从 Hadoop 复制新版(先查看真实版本号) [root@master lib]# ls /export/server/hadoop/share/hadoop/common/lib/guava-*.jar ls: 无法访问/export/server/hadoop/share/hadoop/common/lib/guava-*.jar: 没有那个文件或目录 [root@master lib]# cd /export/server/hive [root@master hive]# [root@master hive]# # 创建 conf 目录(如果不存在) [root@master hive]# mkdir -p conf [root@master hive]# [root@master hive]# # 进入配置目录 [root@master hive]# cd conf [root@master conf]# vi hive-site.xml [root@master conf]# cp /export/soft/mysql-connector-java-5.1.49.jar /export/server/hive/lib/ [root@master conf]# ls /export/server/hive/lib/mysql-connector-java-5.1.49.jar /export/server/hive/lib/mysql-connector-java-5.1.49.jar [root@master conf]# mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 5 Server version: 5.7.43 MySQL Community Server (GPL) Copyright (c) 2000, 2023, Oracle and/or its affiliates. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type &#39;help;&#39; or &#39;\h&#39; for help. Type &#39;\c&#39; to clear the current input statement. mysql> -- 创建 hive 数据库 mysql> CREATE DATABASE IF NOT EXISTS hive CHARACTER SET utf8 COLLATE utf8_general_ci; Query OK, 1 row affected (0.10 sec) mysql> mysql> -- 授权 root 用户访问 hive 库(因为我们用 root 连接) mysql> -- 注意:生产环境建议新建专用用户,这里简化操作 mysql> GRANT ALL PRIVILEGES ON hive.* TO &#39;root&#39;@&#39;%&#39;; Query OK, 0 rows affected (0.07 sec) mysql> mysql> -- 刷新权限 mysql> FLUSH PRIVILEGES; Query OK, 0 rows affected (0.01 sec) mysql> mysql> -- 退出 mysql> EXIT; Bye [root@master conf]# cd /export/server/hive [root@master hive]# [root@master hive]# # 执行 schematool 初始化 [root@master hive]# bin/schematool -dbType mysql -initSchema -verbose SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/export/server/hive/lib/log4j-slf4j-impl-2.10.0.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/root/export/server/hadoop/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] Exception in thread "main" java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkArgument(ZLjava/lang/String;Ljava/lang/Object;)V at org.apache.hadoop.conf.Configuration.set(Configuration.java:1357) at org.apache.hadoop.conf.Configuration.set(Configuration.java:1338) at org.apache.hadoop.mapred.JobConf.setJar(JobConf.java:518) at org.apache.hadoop.mapred.JobConf.setJarByClass(JobConf.java:536) at org.apache.hadoop.mapred.JobConf.<init>(JobConf.java:430) at org.apache.hadoop.hive.conf.HiveConf.initialize(HiveConf.java:5141) at org.apache.hadoop.hive.conf.HiveConf.<init>(HiveConf.java:5104) at org.apache.hive.beeline.HiveSchemaTool.<init>(HiveSchemaTool.java:96) at org.apache.hive.beeline.HiveSchemaTool.main(HiveSchemaTool.java:1473) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.hadoop.util.RunJar.run(RunJar.java:318) at org.apache.hadoop.util.RunJar.main(RunJar.java:232) [root@master hive]# # 创建日志目录 [root@master hive]# mkdir -p /export/server/hive/logs [root@master hive]# [root@master hive]# # 启动 Metastore(后台运行) [root@master hive]# nohup /export/server/hive/bin/hive --service metastore \ > > /export/server/hive/logs/metastore.log 2>&1 & [1] 124844 [root@master hive]# [root@master hive]# # 查看是否启动成功 [root@master hive]# tail -f /export/server/hive/logs/metastore.log nohup: 忽略输入 2025-11-26 22:50:08: Starting Hive Metastore Server SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/export/server/hive/lib/log4j-slf4j-impl-2.10.0.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/root/export/server/hadoop/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] MetaException(message:com.google.common.base.Preconditions.checkArgument(ZLjava/lang/String;Ljava/lang/Object;)V) at org.apache.hadoop.hive.metastore.RetryingHMSHandler.<init>(RetryingHMSHandler.java:84) at org.apache.hadoop.hive.metastore.RetryingHMSHandler.getProxy(RetryingHMSHandler.java:93) at org.apache.hadoop.hive.metastore.HiveMetaStore.newRetryingHMSHandler(HiveMetaStore.java:8661) at org.apache.hadoop.hive.metastore.HiveMetaStore.newRetryingHMSHandler(HiveMetaStore.java:8656) at org.apache.hadoop.hive.metastore.HiveMetaStore.startMetaStore(HiveMetaStore.java:8926) at org.apache.hadoop.hive.metastore.HiveMetaStore.main(HiveMetaStore.java:8843) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.hadoop.util.RunJar.run(RunJar.java:318) at org.apache.hadoop.util.RunJar.main(RunJar.java:232) Caused by: java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkArgument(ZLjava/lang/String;Ljava/lang/Object;)V at org.apache.hadoop.conf.Configuration.set(Configuration.java:1357) at org.apache.hadoop.conf.Configuration.set(Configuration.java:1338) at org.apache.hadoop.hive.metastore.ObjectStore.correctAutoStartMechanism(ObjectStore.java:641) at org.apache.hadoop.hive.metastore.ObjectStore.getDataSourceProps(ObjectStore.java:572) at org.apache.hadoop.hive.metastore.ObjectStore.setConf(ObjectStore.java:349) at org.apache.hadoop.util.ReflectionUtils.setConf(ReflectionUtils.java:77) at org.apache.hadoop.util.ReflectionUtils.newInstance(ReflectionUtils.java:137) at org.apache.hadoop.hive.metastore.RawStoreProxy.<init>(RawStoreProxy.java:59) at org.apache.hadoop.hive.metastore.RawStoreProxy.getProxy(RawStoreProxy.java:67) at org.apache.hadoop.hive.metastore.HiveMetaStore$HMSHandler.newRawStoreForConf(HiveMetaStore.java:718) at org.apache.hadoop.hive.metastore.HiveMetaStore$HMSHandler.getMSForConf(HiveMetaStore.java:696) at org.apache.hadoop.hive.metastore.HiveMetaStore$HMSHandler.getMS(HiveMetaStore.java:690) at org.apache.hadoop.hive.metastore.HiveMetaStore$HMSHandler.createDefaultDB(HiveMetaStore.java:767) at org.apache.hadoop.hive.metastore.HiveMetaStore$HMSHandler.init(HiveMetaStore.java:538) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.hadoop.hive.metastore.RetryingHMSHandler.invokeInternal(RetryingHMSHandler.java:147) at org.apache.hadoop.hive.metastore.RetryingHMSHandler.invoke(RetryingHMSHandler.java:108) at org.apache.hadoop.hive.metastore.RetryingHMSHandler.<init>(RetryingHMSHandler.java:80) ... 11 more Exception in thread "main" MetaException(message:com.google.common.base.Preconditions.checkArgument(ZLjava/lang/String;Ljava/lang/Object;)V) at org.apache.hadoop.hive.metastore.RetryingHMSHandler.<init>(RetryingHMSHandler.java:84) at org.apache.hadoop.hive.metastore.RetryingHMSHandler.getProxy(RetryingHMSHandler.java:93) at org.apache.hadoop.hive.metastore.HiveMetaStore.newRetryingHMSHandler(HiveMetaStore.java:8661) at org.apache.hadoop.hive.metastore.HiveMetaStore.newRetryingHMSHandler(HiveMetaStore.java:8656) at org.apache.hadoop.hive.metastore.HiveMetaStore.startMetaStore(HiveMetaStore.java:8926) at org.apache.hadoop.hive.metastore.HiveMetaStore.main(HiveMetaStore.java:8843) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.hadoop.util.RunJar.run(RunJar.java:318) at org.apache.hadoop.util.RunJar.main(RunJar.java:232) Caused by: java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkArgument(ZLjava/lang/String;Ljava/lang/Object;)V at org.apache.hadoop.conf.Configuration.set(Configuration.java:1357) at org.apache.hadoop.conf.Configuration.set(Configuration.java:1338) at org.apache.hadoop.hive.metastore.ObjectStore.correctAutoStartMechanism(ObjectStore.java:641) at org.apache.hadoop.hive.metastore.ObjectStore.getDataSourceProps(ObjectStore.java:572) at org.apache.hadoop.hive.metastore.ObjectStore.setConf(ObjectStore.java:349) at org.apache.hadoop.util.ReflectionUtils.setConf(ReflectionUtils.java:77) at org.apache.hadoop.util.ReflectionUtils.newInstance(ReflectionUtils.java:137) at org.apache.hadoop.hive.metastore.RawStoreProxy.<init>(RawStoreProxy.java:59) at org.apache.hadoop.hive.metastore.RawStoreProxy.getProxy(RawStoreProxy.java:67) at org.apache.hadoop.hive.metastore.HiveMetaStore$HMSHandler.newRawStoreForConf(HiveMetaStore.java:718) at org.apache.hadoop.hive.metastore.HiveMetaStore$HMSHandler.getMSForConf(HiveMetaStore.java:696) at org.apache.hadoop.hive.metastore.HiveMetaStore$HMSHandler.getMS(HiveMetaStore.java:690) at org.apache.hadoop.hive.metastore.HiveMetaStore$HMSHandler.createDefaultDB(HiveMetaStore.java:767) at org.apache.hadoop.hive.metastore.HiveMetaStore$HMSHandler.init(HiveMetaStore.java:538) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.hadoop.hive.metastore.RetryingHMSHandler.invokeInternal(RetryingHMSHandler.java:147) at org.apache.hadoop.hive.metastore.RetryingHMSHandler.invoke(RetryingHMSHandler.java:108) at org.apache.hadoop.hive.metastore.RetryingHMSHandler.<init>(RetryingHMSHandler.java:80) ... 11 more ^C [1]+ 退出 1 nohup /export/server/hive/bin/hive --service metastore > /export/server/hive/logs/metastore.log 2>&1 [root@master hive]# # 启动 HiveServer2 [root@master hive]# nohup /export/server/hive/bin/hive --service hiveserver2 \ > > /export/server/hive/logs/hiveserver2.log 2>&1 & [1] 126010 [root@master hive]# [root@master hive]# # 查看日志 [root@master hive]# tail -f /export/server/hive/logs/hiveserver2.log nohup: 忽略输入 which: no hbase in (/usr/local/bin:/usr/bin:/usr/sbin:/bin:/sbin:/export/server/jdk/bin:/export/server/hadoop/bin:/export/server/hadoop/sbin:/export/server/mysql/bin:/export/server/hive/bin) 2025-11-26 22:50:53: Starting HiveServer2 SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/export/server/hive/lib/log4j-slf4j-impl-2.10.0.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/root/export/server/hadoop/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] Exception in thread "main" java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkArgument(ZLjava/lang/String;Ljava/lang/Object;)V at org.apache.hadoop.conf.Configuration.set(Configuration.java:1357) at org.apache.hadoop.conf.Configuration.set(Configuration.java:1338) at org.apache.hadoop.mapred.JobConf.setJar(JobConf.java:518) at org.apache.hadoop.mapred.JobConf.setJarByClass(JobConf.java:536) at org.apache.hadoop.mapred.JobConf.<init>(JobConf.java:430) at org.apache.hadoop.hive.conf.HiveConf.initialize(HiveConf.java:5141) at org.apache.hadoop.hive.conf.HiveConf.<init>(HiveConf.java:5099) at org.apache.hadoop.hive.common.LogUtils.initHiveLog4jCommon(LogUtils.java:97) at org.apache.hadoop.hive.common.LogUtils.initHiveLog4j(LogUtils.java:81) at org.apache.hive.service.server.HiveServer2.main(HiveServer2.java:1141) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.hadoop.util.RunJar.run(RunJar.java:318) at org.apache.hadoop.util.RunJar.main(RunJar.java:232) ^C [1]+ 退出 1 nohup /export/server/hive/bin/hive --service hiveserver2 > /export/server/hive/logs/hiveserver2.log 2>&1 [root@master hive]# jps 96417 DataNode 96162 NameNode 126676 Jps 103240 ResourceManager 103483 NodeManager 96894 SecondaryNameNode [root@master hive]# /export/server/hive/bin/beeline SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/export/server/hive/lib/log4j-slf4j-impl-2.10.0.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/root/export/server/hadoop/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://192.168.161.130:10000 Connecting to jdbc:hive2://192.168.161.130:10000 Enter username for jdbc:hive2://192.168.161.130:10000: root Enter password for jdbc:hive2://192.168.161.130:10000: 25/11/26 22:51:47 [main]: WARN jdbc.HiveConnection: Failed to connect to 192.168.161.130:10000 Could not open connection to the HS2 server. Please check the server URI and if the URI is correct, then ask the administrator to check the server status. Error: Could not open client transport with JDBC Uri: jdbc:hive2://192.168.161.130:10000: java.net.ConnectException: 拒绝连接 (Connection refused) (state=08S01,code=0) beeline> SHOW DATABASES; No current connection beeline> # 开放 Metastore 端口 beeline> firewall-cmd --permanent --add-port=9083/tcp . . . .> . . . .> # 开放 HiveServer2 端口 . . . .> firewall-cmd --permanent --add-port=10000/tcp . . . .> . . . .> # 重新加载 . . . .> firewall-cmd --reload . . . .> exit; No current connection beeline> !quit [root@master hive]#
最新发布
11-27
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值