当前位置:   article > 正文

Hadoop之MapReduce官方案例实战_hadoop mapreduce电商项目实战

hadoop mapreduce电商项目实战

Hadoop官方在hadoop/share/hadoop/mapreduce目录下面提供了可以使用的样例jar包。

[root@node01 ~]# ll /opt/bigdata/hadoop-2.6.5/share/hadoop/mapreduce/
total 4876
-rw-rw-r--. 1 god vagrant  526732 Oct  2  2016 hadoop-mapreduce-client-app-2.6.5.jar
-rw-rw-r--. 1 god vagrant  686773 Oct  2  2016 hadoop-mapreduce-client-common-2.6.5.jar
-rw-rw-r--. 1 god vagrant 1535776 Oct  2  2016 hadoop-mapreduce-client-core-2.6.5.jar
-rw-rw-r--. 1 god vagrant  259326 Oct  2  2016 hadoop-mapreduce-client-hs-2.6.5.jar
-rw-rw-r--. 1 god vagrant   27489 Oct  2  2016 hadoop-mapreduce-client-hs-plugins-2.6.5.jar
-rw-rw-r--. 1 god vagrant   61309 Oct  2  2016 hadoop-mapreduce-client-jobclient-2.6.5.jar
-rw-rw-r--. 1 god vagrant 1514166 Oct  2  2016 hadoop-mapreduce-client-jobclient-2.6.5-tests.jar
-rw-rw-r--. 1 god vagrant   67762 Oct  2  2016 hadoop-mapreduce-client-shuffle-2.6.5.jar
-rw-rw-r--. 1 god vagrant  292710 Oct  2  2016 hadoop-mapreduce-examples-2.6.5.jar
drwxrwxr-x. 2 god vagrant    4096 Oct  2  2016 lib
drwxrwxr-x. 2 god vagrant      30 Oct  2  2016 lib-examples
drwxrwxr-x. 2 god vagrant    4096 Oct  2  2016 sources
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14

执行

本次在node01执行

hdfs dfs -mkdir -p /data/wordcount/input
hdfs dfs -D dfs.blocksize=1048576 -put data.txt /data/wordcount/input
hadoop jar hadoop-mapreduce-examples-2.6.5.jar wordcount /data/wordcount/input /data/wordcount/output
  • 1
  • 2
  • 3

结果

执行完命令之后,在窗口里面也能看到执行结果。
浏览器访问http://node03:8088/,点击菜单“Applications”就会看到执行记录。
执行结果
在node01执行

[root@node01 ~]# hdfs dfs -ls /data/wordcount/output
Found 2 items
# 标志成功的文件
-rw-r--r--   2 root supergroup          0 2022-12-30 01:52 /data/wordcount/output/_SUCCESS
# 生成的数据文件;**part-r-00000中间的r表示map+reduce;m表示map**
-rw-r--r--   2 root supergroup     788922 2022-12-30 01:52 /data/wordcount/output/part-r-00000
[root@node01 ~]# hdfs dfs -cat  /data/wordcount/output/part-r-00000
# 就会看到数据文件
# 也可以下载到服务器查看
[root@node01 ~]# hdfs dfs -get  /data/wordcount/output/part-r-00000 ./
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家小花儿/article/detail/429294
推荐阅读
相关标签
  

闽ICP备14008679号