大数据-Hadoop 本地运行模式

本文详细介绍如何使用Hadoop MapReduce进行Grep和WordCount案例操作。从创建输入文件夹到执行MapReduce程序,再到查看最终输出结果,一步步引导读者实践Hadoop的基本应用。

Grep案例

1. 创建在hadoop-2.7.2文件下面创建一个input文件夹

[atguigu@hadoop101 hadoop-2.7.2]$ mkdir input

2. Hadoopxml配置文件复制到input

[atguigu@hadoop101 hadoop-2.7.2]$ cp etc/hadoop/*.xml input

 

3. 执行share目录下的MapReduce程序(执行)

[atguigu@hadoop101 hadoop-2.7.2]$ bin/hadoop jar

share/hadoop/mapreduce/hadoop-mapreduce-examples-2.7.2.jar grep input output 'dfs[a-z.]+'(要正常的运行,必须要保证output删除,没有才能运行)

 

4. 查看输出结果

[atguigu@hadoop101 hadoop-2.7.2]$ cat output/*

 

WordCount案例

1. 创建在hadoop-2.7.2文件下面创建一个wcinput文件夹

[atguigu@hadoop101 hadoop-2.7.2]$ mkdir wcinput

2. wcinput文件下创建一个wc.input文件

[atguigu@hadoop101 hadoop-2.7.2]$ cd wcinput

[atguigu@hadoop101 wcinput]$ touch wc.input

3. 编辑wc.input文件

[atguigu@hadoop101 wcinput]$ vi wc.input

 

 

保存退出::wq

4. 回到Hadoop目录/opt/module/hadoop-2.7.2

5. 执行程序

[atguigu@hadoop101 hadoop-2.7.2]$ hadoop jar

 share/hadoop/mapreduce/hadoop-mapreduce-examples-2.7.2.jar wordcount wcinput wcoutput

 

6. 查看结果

[atguigu@hadoop101 hadoop-2.7.2]$ cat wcoutput/part-r-00000

 

转载于:https://www.cnblogs.com/nidegui/p/11214055.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值