hadoop word count example

1. 运行hadoop-1.2.1自带的wordcount example

在$hadoop_home目录生成file01, file02文本文件
hadoop word count example - spring8743 - 我的博客
 
hadoop word count example - spring8743 - 我的博客
 
将file01, file02放到hdfs的某一个目录下
bin/hadoop fs -put file01  /user/hadoop/wordcount/input
bin/hadoop fs -put file02  /user/hadoop/wordcount/input

在$hadoop_home目录执行word count的job
bin/hadoop jar hadoop-examples-1.2.1.jar wordcount  /user/hadoop/wordcount/input   /user/hadoop/wordcount/output

在hdfs的output目录下会生成如下的文件和文件夹
hadoop word count example - spring8743 - 我的博客

查看part-r-00000输出文件
hadoop word count example - spring8743 - 我的博客

注意事项:
1. hadoop-example-1.2.1.jar放在本地的磁盘上而不是hdfs
2. 输入文件file01, file02放在hdfs上
3. output目录事先不能在hdfs上创建,因为程序会自动在你给的路径上创建output目录,否则会报错the directory is already existed
4. input, output不能放在hdfs的根目录/上,由于权限和security的原因,否则会报错。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值