hadoop的第一个程序wordcount实现

具体安装步骤请见博客:linux hadoop 2.7 伪分布式安装简单几步实现

1. 在本地新建一个文件,笔者在~/hadoop-2.7.1/local_data文件夹新建了一个文本文件hello.txt,local_data文件夹也是新建的。文件内容是:

he wo shi he jing
shao wo shi shao jie
ni ni shi lu lu

2. 在hdfs文件系统中,新建一个文件夹,用于上传本地的hello.txt,在hadoop2.7.1目录下输入命令:

在hdfs根目录下建立一个test目录:bin/hdfs dfs -mkdir /test    

查看hdfs根目录下的目录结构:bin/hdfs dfs -ls /

3. 将本地的hello.txt文档上传到test目录里

上传本地文件:bin/hdfs dfs -put /home/couragek/hadoop-2.7.1/local_data/hello.txt /test/

查看此时目录:bin/hdfs dfs -ls /test/

4. 运行word count程序

使用命令:bin/hadoop jar share/hadoop/mapreduce/hadoop-mapreduce-examples-2.7.1.jar wordcount /test/hello.txt /test/out

在/test目录下生成名为out的文件:bin/hdfs dfs -ls /test 

结果是在test目录下生成了一个名为out的文件目录

输入命令查看out目录下的文件:bin/hdfs dfs -ls /test/out


查看运行结果:


5. 参考文献

http://www.tuicool.com/articles/bmeUneM

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值