hadoop学习(7)—— 使用yarn运行mapreduce一个简单的wordcount示例

来源:互联网 发布:2016网络安全数据 编辑:程序博客网 时间:2024/06/08 16:42

1.hdfs文件系统目录要求(建议)

    /user        /{username}             --用户名            /mr                 --MapReduce类型应用                /wordcount      --应用的名称                    /input      --要处理的文件                    /output     --输出结果的文件夹

2.按照目录格式创建输入文件夹(不用创建输出文件夹)

    [root@hadoop-yarn hadoop-2.6.5]# bin/hdfs dfs -mkdir -p /user/root/mr/wordcount/input

3.手动创建测试数据

    cyhp supergroup    hadoop hello    hdfs hadoop    mapreduce hadoop    world yarn

4.将输入数据放入HDFS中

[root@hadoop-yarn hadoop-2.6.5]# bin/hdfs dfs -put test-datas/wc.input  /user/root/mr/wordcount/input/

5.使用yarn运行示例

[root@hadoop-yarn hadoop-2.6.5]# bin/yarn jar share/hadoop/mapreduce/hadoop-mapreduce-examples-2.6.5.jar wordcount /user/root/mr/wordcount/input/ /user/root/mr/wordcount/output/

6.查看输出

[root@hadoop-yarn hadoop-2.6.5]# bin/hdfs dfs -text /user/root/mr/wordcount/output/par*
[root@hadoop-yarn hadoop-2.6.5]# bin/hdfs dfs -text /user/root/mr/wordcount/output/par*cyhp    1hadoop  3hdfs    1hello   1mapreduce   1supergroup  1world   1yarn    1
0 0
原创粉丝点击