hadoop1-入门案例Grep|wordCount

版权声明:fromZjy QQ1045152332 https://blog.csdn.net/qq_36762677/article/details/85765675

download and install

官网下载 https://hadoop.apache.org/releases.html
版本 2.8.5,解压
cd /opt
tar -zxvf hadoop-2.8.5.tar.gz
目录结构
在这里插入图片描述


Grep案例

2.测试

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

[root@localhost hadoop-2.8.5]# mkdir input
[root@localhost hadoop-2.8.5]# cp etc/hadoop/*.xml input/

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

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

生成output文件,里面有两个文件
在这里插入图片描述

2.1统计结果

SUCCESS文件0KB
part-r-00000文件为统计结果
在这里插入图片描述


WordCount案例

创建文件夹及文件

[root@localhost hadoop-2.8.5]# mkdir wcinput
[root@localhost hadoop-2.8.5]# cd wcinput/
[root@localhost wcinput]# touch wc.input
[root@localhost wcinput]# vim wc.input

输入以下内容

hadoop yarn
hadoop mapreduce
iloveyou
iloveyou

执行hadoop程序

[root@localhost hadoop-2.8.5]# hadoop jar share/hadoop/mapreduce/hadoop-mapreduce-examples-2.8.5.jar wordcount wcinput/ wcouput

执行结果
在这里插入图片描述
查看part-r-00000
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/qq_36762677/article/details/85765675