本地连接hadoop集群问题汇总

本文分析了本地代码读取云主机Hadoop数据时出现超时的问题,详细解释了错误信息,指出原因是本地代码请求到了错误的内网地址。提供了解决方案,即在hdfs-site.xml中增加特定属性并重启集群,同步配置文件。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.本地运行代码读取云主机hadoop数据超时

本地代码简版,其中hadoopcluster为集群的命名空间

val spark = SparkSession.builder()
      .appName("SparkStatFormatData")
      .master("*")
      .getOrCreate()

val data = spark.sparkContext.textFile("hdfs://hadoopcluster/test")

报错信息:

19/09/25 19:21:50 WARN BlockReaderFactory: I/O error constructing remote block reader.
org.apache.hadoop.net.ConnectTimeoutException: 60000 millis timeout while waiting for channel to be ready for connect. ch : java.nio.channels.SocketChannel[connection-pending remote=/172.26.84.192:50010]
  
19/09/25 19:21:50 WARN DFSClient: Failed to connect to /172.26.84.192:50010 for block, add to deadNodes and continue. org.apache.hadoop.net.ConnectTimeoutException: 60000 millis timeout while waiting for channel to be ready for connect. ch : java.nio.channels.SocketChannel[connection-pending remote=/172.26.84.192:50010]
org.apache.hadoop.net.ConnectTimeoutException: 60000 millis timeout while waiting for channel to be ready for connect. ch : java.nio.channels.SocketChannel[connection-pending remote=/172.26.84.192:50010]

报错信息分析:

从报错信息中可以看出,本地代码运行的过程中,所有请求都请求到内网地址中,该内网地址为部署hadoop集群的内网地址,我们本地环境的内网地址,并不是我们想要请求的云主机的hadoop集群。

解决方案:

在hdfs-site.xml中增加dfs.datanode.use.datanode.hostname属性,表示datanode之间的通信也通过域名方式。

重启hadoop集群,同时在本地运行环境的resource目录,同步集群的hdfs-site.xml配置文件。

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值