【问题标题】:Hadoop HDFS - Wrong FS: hdfs://0.0.0.0:9000... expected: file:///Hadoop HDFS - 错误的 FS:hdfs://0.0.0.0:9000... 预期:file:///
【发布时间】:2014-12-09 01:47:57
【问题描述】:

我遇到了以下错误; java.lang.IllegalArgumentException:错误的 FS:hdfs://0.0.0.0:9000/user/hadoop/dataset/data.log,预期:file:///

代码片段



    Configuration conf = new Configuration();
    conf.addResource(new Path("/home/hadoo/hadoop-2.5.2/etc/hadoop/core-site.xml"));
    conf.addResource(new Path("/home/hadoo/hadoop-2.5.2/etc/hadoop/hdfs-site.xml"));
    FileSystem fs = FileSystem.get(conf);



    Path path = new Path("hdfs://0.0.0.0:9000/user/hadoop/dataset/data.log");
    try {
      if (fs.exist(path)) {
        return true;
      } else {
        return false;
    } catch (IOException e) {
      e.printStackTrace();
    }

但是,如果我从路径中删除前缀“hdfs://0.0.0.0:9000”,就可以了。 您能否指导我如何在不更改 hdfs 路径的情况下解决此问题? 仅供参考,Hadoop 服务器和客户端在不同的机器上运行。 即)Hadoop(HDFS):172.xx.xx.247 我的测试客户端:172.xx.xx.236

核心站点.xml

<configuration>
 <property>
  <name>fs.default.name</name>
  <value>hdfs://172.xx.xx.247:9000</value>
 </property>
</configuration>

hdfs-site.xml

<configuration>
 <property>
  <name>dfs.replication</name>
  <value>1</value>
 </property>
 <property>
  <name>dfs.name.dir</name>
  <value>file:///home/hadoop/hadoopdata/hdfs/namenode</value>
 </property>
 <property>
  <name>dfs.data.dir</name>
  <value>file:///home/hadoop/hadoopdata/hdfs/datanode</value>
 </property>
</configuration>

core-default.xml

<property>
 <name>fs.file.impl</name>
 <value>org.apache.hadoop.fs.LocalFileSystem</value>
</property>
<property>
 <name>fs.hdfs.impl</name>
 <value>org.apache.hadoop.hdfs.DistributedFileSystem</value>
</property>

【问题讨论】:

    标签: hdfs


    【解决方案1】:

    您的代码中有拼写错误。

    您的代码: conf.addResource(new Path("/home/hadoo/hadoop-2.5.2/etc/hadoop/core-site.xml"));

    尝试: conf.addResource(new Path("/home/hadoop/hadoop-2.5.2/etc/hadoop/core-site.xml"));

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-07-09
      • 2015-11-06
      • 1970-01-01
      • 2021-11-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多