hadoop helloworld(wordcount)

一、安装hadoop

发现在mac上安装hadoop有更快捷的方法,首先安装homebrew,homebrew是一个包管理工具,安装hadoop命令如下:

brew install hadoop

默认会安装在/usr/local/Cellar目录下。该目录默认为隐藏的,可以打开finder,依次:菜单栏”前往”->”前往文件夹”,输入/usr/local/Cellar。快捷键command+shift+G。

二、运行wordcount入门程序

wordcount是hadoop统计文本中单词的入门程序。
在/usr/local/Cellar/hadoop /2.7.2目录下新建input文件夹,在input文件夹下新建2个文本文档text1.txt和text2.txt,往里面随便输入一些单词:
text1.txt:

张三
李四 
王五
李四

text2.txt:

hello world!
hello Beijing.
Beijing

打开终端,运行以下命令:

hadoop jar  /usr/local/Cellar/hadoop/2.7.2/libexec/share/hadoop/mapreduce/hadoop-mapreduce-examples-2.7.2.jar wordcount input output

会输出一串命令,在/usr/local/Cellar/hadoop/output目录下新生成part-r-00000文件,打开:

Beijing 1
Beijing.    1
hello   2
world!  1
张三  1
李四  2
王五  1

这里写图片描述

参考博客:

  1. Hadoop集群(第6期)_WordCount运行详解
  2. 【Hadoop】MAC下hadoop2.6安装以及执行wordcount
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

esc_ai

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值