赞
踩
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
本次在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
执行完命令之后,在窗口里面也能看到执行结果。
浏览器访问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 ./
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。