我想知道是否有可能在Hadoop中运行非mapreduce作业,比如一个显示“hello word”的java程序。如果是这样,请您举个例子吗?
非常感谢你。

最佳答案

您可以创建一个jar并使用hadoop jar运行它:

[root@localhost hellworld]# cat HelloWorld.java

public class HelloWorld {

  public static void main(String[] args) throws Exception {
      System.out.println("Hello World!");
}}


[root@localhost hellworld]# javac HelloWorld.java
[root@localhost hellworld]# jar cvf helloworld.jar HelloWorld.class

[root@localhost hellworld]# ~/Downloads/hadoop-2.1.0-beta/bin/hadoop jar helloworld.jar HelloWorld
Hello World!

10-07 13:25
查看更多