本地连接hadoop集群问题汇总

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配置文件。

 

你可能感兴趣的:(hadoop)