栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 前沿技术 > 大数据 > 大数据系统

Hadoop本地运行模式

Hadoop本地运行模式

Hadoop本地运行模式
  • 一.官方 Grep 案例
  • 二.官方 WordCount 案例

一.官方 Grep 案例

从一堆配置文件中匹配出开头以dfs开头的单词

  1. 创建在hadoop-2.7.2文件下面创建一个input文件夹
    [atguigu@hadoop101hadoop-2.7.2]$ mkdir input
    
  2. 将Hadoop的xml配置文件复制到input
    [atguigu@hadoop101hadoop-2.7.2]$ cp etc/hadoop/*.xml input
    
  3. 执行share目录下的MapReduce程序
    [atguigu@hadoop101hadoop-2.7.2]$ bin/hadoop jar share/hadoop/mapreduce/hadoop-mapreduce-examples-2.7.2.jar grep input output 'dfs[a-z.]+'
    
  4. 查看输出结果
    [atguigu@hadoop101hadoop-2.7.2]$ cat output/part-r-00000
    1  dfsadmin
    
二.官方 WordCount 案例

从一个文件中统计一下每个单词的次数

  1. 创建在hadoop-2.7.2文件下面创建一个wcinput文件夹
    [atguigu@hadoop101hadoop-2.7.2]$ mkdir wcinput
    
  2. 在wcinput文件下创建一个wc.input文件
    [atguigu@hadoop101hadoop-2.7.2]$ cd wcinput
    [atguigu@hadoop101wcinput]$ touch wc.input
    
  3. 编辑wc.input文件
    [atguigu@hadoop101wcinput]$ vi wc.input
    
    在文件中输入如下内容:
    hadoop  yarn
    hadoop  mapreduce
    atguigu
    atguigu
    
    保存退出::wq
    
  4. 回到Hadoop目录/opt/module/hadoop-2.7.2
  5. 执行程序
    [atguigu@hadoop101hadoop-2.7.2]$ hadoop jar share/hadoop/mapreduce/hadoop-mapreduce-examples-2.7.2.jar wordcount wcinput wcoutput
    
  6. 查看结果
    [atguigu@hadoop101hadoop-2.7.2]$ cat wcoutput/part-r-00000
    atguigu  2
    hadoop  2
    mapreduce  1
    yarn  1 
    
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/281603.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号