Hdfs连接报错java.net.ConnectException: Connection timed out: no further information


在这里插入图片描述

想学习架构师构建流程请跳转:Java架构师系统架构设计

1 连接超时

在这里插入图片描述

2 排查具体问题

2.1.检查网络能不能ping通,防火墙问题

由于有Hue可以访问,网络没有问题或者看是否连通,因为可能防ping

telnet www.baidu.com 80

2.2 检查zookeeper有没有开启

2.3 最后检查Hue中Hdfs节点挂掉

在这里插入图片描述
最后可以看出上述问题都没有所以大环境是没有错,那就是代码的问题

3 解决方法

问题在于使用本地读取hdfs文件时,服务器datanode使用的是内网进行通信,所以我们把hdfs-site.xml和core-site.xml文件导入到Idea中时,需要修改hdfs-site.xml中的以下配置:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!--
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License. See accompanying LICENSE file.
-->

<!-- Put site-specific property overrides in this file. -->

<configuration>
	<property>
		<name>dfs.namenode.name.dir</name>
		<value>/opt/hdfs/namenode</value>
		<description>NameNode directory for namespace and transaction logs storage.</description>
	</property>
	<property>
		<name>dfs.datanode.data.dir</name>
		<value>/opt/hdfs/datanode</value>
		<description>DataNode directory</description>
	</property>
	<property>
		<name>dfs.replication</name>
		<value>2</value>
	</property>
	<property>
		<name>dfs.permissions</name>
		<value>false</value>
		<description>need not permissions</description>
	</property>
	<property>
		<name>dfs.webhdfs.enabled</name>
		<value>true</value>
	</property>
	<property>
		<name>dfs.datanode.max.xcievers</name>
		<value>4096</value>
	</property>
	<property>
		<name>dfs.client.use.datanode.hostname</name>
		<value>true</value>
	</property>
</configuration>

在这里插入图片描述

这个错误信息"connect to server 192.168.206.88:22122 fail java.net.ConnectException: Connection refused: connect"表示连接服务器192.168.206.88的22122端口失败,可能是由于服务器拒绝连接引起的。这种错误通常发生在网络连接问题、端口未打开或服务器未响应的情况下。根据引用中提供的链接,你可以查看更多关于Connection refused错误的详细信息。引用中也提供了一些解决java.net.ConnectException的方法,你可以参考一下。在你的问题中,你提到使用了如下命令读取hdfs上的文件:"var text = sc.textFile("hdfs://slaver1:/input.txt")"。根据引用中的描述,你可能是因为没有指定端口号导致连接错误。所以你需要确保在"hdfs://slaver1:/input.txt"中指定正确的端口号。如果问题仍然存在,你可以检查网络连接,确保端口处于打开状态,并确认服务器是否正常运行。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *3* [java.net.ConnectException: Call From slaver1/192.168.19.128 to slaver1:8020 failed on connection exc...](https://blog.csdn.net/u011652364/article/details/89347724)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* [java.net.ConnectException: Connection refused问题解决办法](https://download.csdn.net/download/weixin_38711778/12790245)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

赵广陆

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值