hadoop预装示例jar

um6iljoc  于 2021-06-03  发布在  Hadoop
关注(0)|答案(4)|浏览(440)

我刚刚在本地机器上成功地安装了hadoop。我正在看我刚买的一本畅销书中的一个例子。我试图得到一个所有hadoop安装示例的列表。我键入以下命令来执行此操作:

bin/hadoop jar hadoop-*-examples.jar

一旦我输入这个,我应该得到一个hadoop示例列表,对吗?但是,我看到的是以下错误消息:

Not a valid JAR: /home/user/hadoop/hadoop-*-examples.jar

如何解决这个问题?只是一个简单的权限问题吗?

5jvtdoz2

5jvtdoz21#

必须指定要使用的jar文件的类名:

hadoop jar pathtojarfile classname arg1 arg2 ..

例子:

hadoop jar example.jar wordcount inputPath outputPath
1qczuiv0

1qczuiv02#

@阿努普。jar文件的完整/相对路径是必需的。
在您的例子中,它可能是/home/user/hadoop/share/hadoop--examples.jar
hadoop目录中的完整命令可能是
/home/user/hadoop/bin/hadoop/home/user/hadoop/share/hadoop-
-examples.jar
(我在这里使用了绝对完整路径,但是可以使用相对路径)。

pgpifvop

pgpifvop3#

这很可能是配置问题或使用无效的文件路径。
很可能hadoop-*-examples.jar的名称不正确,因为在我的hadoop(1.0.0)版本中,文件名是hadoop-examples-1.0.0.jar。
因此,我运行以下命令列出所有示例,它的工作原理与charm类似:

bin/hadoop jar hadoop-examples-*.jar 

An example program must be given as the first argument.
Valid program names are:
  aggregatewordcount: An Aggregate based map/reduce program that counts the words in the input files.
  aggregatewordhist: An Aggregate based map/reduce program that computes the histogram of the words in the input files.
  dbcount: An example job that count the pageview counts from a database.
  grep: A map/reduce program that counts the matches of a regex in the input.
  join: A job that effects a join over sorted, equally partitioned datasets
  multifilewc: A job that counts words from several files.
  pentomino: A map/reduce tile laying program to find solutions to pentomino problems.
  pi: A map/reduce program that estimates Pi using monte-carlo method.
  randomtextwriter: A map/reduce program that writes 10GB of random textual data per node.
  randomwriter: A map/reduce program that writes 10GB of random data per node.
  secondarysort: An example defining a secondary sort to the reduce.
  sleep: A job that sleeps at each map and reduce task.
  sort: A map/reduce program that sorts the data written by the random writer.
  sudoku: A sudoku solver.
  teragen: Generate data for the terasort
  terasort: Run the terasort
  teravalidate: Checking results of terasort
  wordcount: A map/reduce program that counts the words in the input files.

另外,如果我使用与您相同的文件名模式,则会出现错误:

bin/hadoop jar hadoop-*examples.jar 

Exception in thread "main" java.io.IOException: Error opening job jar: hadoop-*examples.jar

hth公司

alen0pnh

alen0pnh4#

你会发现jar在里面 $HADOOP_HOME/share/hadoop/mapreduce/hadoop-*-examples*.jar

相关问题