hadoop编译-在dfs文件中

pgpifvop  于 2021-06-03  发布在  Hadoop
关注(0)|答案(1)|浏览(371)

我想用以下命令编译hadoop示例,但出现了一个错误:

  1. $ mkdir wordcount_classes
  2. $ javac -classpath ${HADOOP_HOME}/hadoop-${HADOOP_VERSION}-core.jar -d wordcount_classes WordCount.java
  3. $ jar -cvf /usr/joe/wordcount.jar -C wordcount_classes/ .
  4. Assuming that:
  5. /usr/joe/wordcount/input - input directory in HDFS
  6. /usr/joe/wordcount/output - output directory in HDFS
  7. Sample text-files as input:
  8. $ bin/hadoop dfs -ls /usr/joe/wordcount/input/
  9. /usr/joe/wordcount/input/file01
  10. /usr/joe/wordcount/input/file02
  11. $ bin/hadoop dfs -cat /usr/joe/wordcount/input/file01
  12. Hello World Bye World
  13. $ bin/hadoop dfs -cat /usr/joe/wordcount/input/file02
  14. Hello Hadoop Goodbye Hadoop
ymzxtsji

ymzxtsji1#

/usr/joe 是本地的,正如您在执行 ls 命令在第一行。第二个命令需要hdfs位置的输入和输出,但是 /usr/joe hdfs上不存在。您需要将数据移动到hdfs上,然后执行命令。例如:

  1. # This creates a folder "wordcount/input" in your HDFS home directory
  2. hdfs dfs -mkdir -p wordcount/input
  3. hdfs dfs -put /usr/joe/wordcount/input/* wordcount/input

相关问题