hadoop1-入门案例Grep|wordCount

download and install

官网下载 https://hadoop.apache.org/releases.html
版本 2.8.5,解压
cd /opt
tar -zxvf hadoop-2.8.5.tar.gz
目录结构
hadoop1-入门案例Grep|wordCount


Grep案例

2.测试

创建文件夹,将配置文件复制到input

[[email protected] hadoop-2.8.5]# mkdir input
[[email protected] hadoop-2.8.5]# cp etc/hadoop/*.xml input/

进入hadoop,启动第一次测试
output文件不能创建,会报错

[[email protected] hadoop-2.8.5]# hadoop jar share/hadoop/mapreduce/hadoop-mapreduce-examples-2.8.5.jar grep input/ output 'dfs[a-z.]+'

生成output文件,里面有两个文件
hadoop1-入门案例Grep|wordCount

2.1统计结果

SUCCESS文件0KB
part-r-00000文件为统计结果
hadoop1-入门案例Grep|wordCount


WordCount案例

创建文件夹及文件

[[email protected] hadoop-2.8.5]# mkdir wcinput
[[email protected] hadoop-2.8.5]# cd wcinput/
[[email protected] wcinput]# touch wc.input
[[email protected] wcinput]# vim wc.input

输入以下内容

hadoop yarn
hadoop mapreduce
iloveyou
iloveyou

执行hadoop程序

[[email protected] hadoop-2.8.5]# hadoop jar share/hadoop/mapreduce/hadoop-mapreduce-examples-2.8.5.jar wordcount wcinput/ wcouput

执行结果
hadoop1-入门案例Grep|wordCount
查看part-r-00000
hadoop1-入门案例Grep|wordCount