hadoop程序问题:java.lang.IllegalArgumentException: Wrong FS: hdfs:/ expected file:///

Java代码以下:java

  1. FileSystem fs = FileSystem.get(conf); 
  2. in = fs.open(new Path("hdfs://192.168.130.54:19000/user/hmail/output/part-00000")); 

抛出异常以下:apache

  1. Exception in thread "main" java.lang.IllegalArgumentException: Wrong FS: hdfs://192.168.130.54:19000/user/hmail/output/part-00000, expected: file:/// 
  2.     at org.apache.hadoop.fs.FileSystem.checkPath(FileSystem.java:310) 
  3.     at org.apache.hadoop.fs.RawLocalFileSystem.pathToFile(RawLocalFileSystem.java:47) 
  4.     at org.apache.hadoop.fs.RawLocalFileSystem.getFileStatus(RawLocalFileSystem.java:357) 
  5.     at org.apache.hadoop.fs.FilterFileSystem.getFileStatus(FilterFileSystem.java:245) 
  6.     at org.apache.hadoop.fs.ChecksumFileSystem$ChecksumFSInputChecker.<init>(ChecksumFileSystem.java:125) 
  7.     at org.apache.hadoop.fs.ChecksumFileSystem.open(ChecksumFileSystem.java:283) 
  8.     at org.apache.hadoop.fs.FileSystem.open(FileSystem.java:356) 
  9.     at com.netease.hadoop.HDFSCatWithAPI.main(HDFSCatWithAPI.java:23) 

解决方案:eclipse

hadoop须要把集群上的core-site.xml和hdfs-site.xml放到当前工程下。eclipse工做目录的bin文件夹下面oop


由于是访问远程的HDFS 须要经过URI来得到FileSystem.spa

相关文章
相关标签/搜索