官术网_书友最值得收藏!

Time for action – running WordCount on a local Hadoop cluster

Now we have generated the class files and collected them into a JAR file, we can run the application by performing the following steps:

  1. Submit the new JAR file to Hadoop for execution.
    $ hadoop jar wc1.jar WordCount1 test.txt output
    
  2. If successful, you should see the output being very similar to the one we obtained when we ran the Hadoop-provided sample WordCount in the previous chapter. Check the output file; it should be as follows:
    $ Hadoop fs –cat output/part-r-00000
    This 1
    yes 1
    a 1
    is 2
    test 1
    this 1
    

What just happened?

This is the first time we have used the Hadoop JAR command with our own code. There are four arguments:

  1. The name of the JAR file.
  2. The name of the driver class within the JAR file.
  3. The location, on HDFS, of the input file (a relative reference to the /user/Hadoop home folder, in this case).
  4. The desired location of the output folder (again, a relative path).

Tip

The name of the driver class is only required if a main class has not (as in this case) been specified within the JAR file manifest.

主站蜘蛛池模板: 孝义市| 莲花县| 禄丰县| 武平县| 化德县| 勐海县| 泗水县| 乌海市| 大埔县| 武威市| 吉首市| 安泽县| 兴海县| 凤冈县| 鄂尔多斯市| 恭城| 株洲县| 偃师市| 通辽市| 虹口区| 自贡市| 德令哈市| 兖州市| 思茅市| 墨玉县| 江川县| 高陵县| 阜城县| 织金县| 文水县| 邢台县| 武隆县| 沾益县| 大姚县| 康定县| 韶山市| 博野县| 都兰县| 阿拉善右旗| 偏关县| 吉林市|