質問

I have a fresh installation of hadoop yarn and I have executed wordcount example via given jar file in hadoop/share/hadoop/mapreduce/hadoop-mapreduce-examples... but when I try to compile wordcount source and run it, it gives me java.io.IOException: No FileSystem for scheme: hdfs.

The exception above is related to this line of code:

FileInputFormat.addInputPath(job, new Path(args[0]));

EDIT: Command and output are these:

hduser@master-virtual-machine:~$ hadoop jar Desktop/NativeWordcount.jar /tin /tout
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [rsrc:org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:rsrc:slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
13/12/03 07:14:44 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
Exception in thread "main" java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.apache.hadoop.util.RunJar.main(RunJar.java:212)
Caused by: java.io.IOException: No FileSystem for scheme: hdfs
    at org.apache.hadoop.fs.FileSystem.getFileSystemClass(FileSystem.java:2421)
    at org.apache.hadoop.fs.FileSystem.createFileSystem(FileSystem.java:2428)
    at org.apache.hadoop.fs.FileSystem.access$200(FileSystem.java:88)
    at org.apache.hadoop.fs.FileSystem$Cache.getInternal(FileSystem.java:2467)
    at org.apache.hadoop.fs.FileSystem$Cache.get(FileSystem.java:2449)
    at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:367)
    at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:166)
    at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:351)
    at org.apache.hadoop.fs.Path.getFileSystem(Path.java:287)
    at org.apache.hadoop.mapreduce.lib.input.FileInputFormat.addInputPath(FileInputFormat.java:466)
    at WordCount.main(WordCount.java:55)
    ... 10 more
役に立ちましたか?

解決

I ran into this problem today as well. You need to make sure the hadoop-hdfs jar is in your classpath.

My first brush at this was to simply add a dependency to my project on the hadoop-hdfs package in Maven, but this was insufficient. In the end, I followed the Cloudera's advice and added a dependency on hadoop-client. The relevant clause for your pom.xml file is:

 <dependency>
    <groupId>org.apache.hadoop</groupId>
    <artifactId>hadoop-client</artifactId>
    <version>VERSION</version>
 </dependency>

As I was doing this in Clojure with Leiningen, I added this to my project.clj file instead:

(defproject 
  ; ...
  :dependencies [[org.apache.hadoop/hadoop-client "VERSION"]
                 ; ...
                 ])

(Your version will depend on what is installed on your system, of course. The only release version in the 2.x series at the moment is 2.2.0.)

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top