安装并运行了Hadoop的Linux VM。 在Eclipse中运行的Java应用程序从HDFS中检索数据。 如果我将文件复制到VM中的HDFS或从VM中复制文件,一切正常。 但是,当我从我的Windows物理机上运行应用程序,我得到一个异常:将文件从HDFS复制到Windows机器时出错
WARN hdfs.DFSClient: Failed to connect to /127.0.0.1:50010 for block, add to
deadNodes and continue. java.net.ConnectException: Connection refused: no further
information. Could not obtain BP-*** from any node: java.io.IOException:
No live nodes contain current block. Will get new block locations from namenode and retry
我只能从HDFS中检索文件的列表。 似乎从数据节点检索数据时,它将连接到我的Windows本地主机。 因为当我从我的本地主机到虚拟主机的腻子隧道一切都很好。
这里是我的Java代码:
Configuration config = new Configuration();
config.set("fs.defaultFS", "hdfs://ip:port/");
config.set("mapred.job.tracker", "hdfs://ip:port");
FileSystem dfs = FileSystem.get(new URI("hdfs://ip:port/"), config, "user");
dfs.copyToLocalFile(false, new Path("/tmp/sample.txt"),newPath("D://sample.txt"), true);
怎样才可以解决吗? 谢谢。
P.S.当我使用Cloudera的QuickStart VM时会发生此错误。