本地文件运行hadoop案例

一、Hadoop的运行模式

Hadoop有三种运行模式:本地模式、伪分布式模式和完全分布式模式。
  本地模式,顾名思义,就是在一台linux服务器进行安装,这种模式也是Hadoop的默认模式,在这种安装模式下Hadoop的core-site.xml、mapred-site.xml、hdfs-site.xml等配置文件都是空的,不需要配置。
  在本地模式下,Hadoop单独运行,不与其他节点进行交互,不使用hadoop的分布式文件系统,也不加载任何的守护进程,该模式主要用于MapReduce应用程序的调试。

二、运行官方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]$vim wc.input
    在文件中输入如下内容
    hadoop yarn
    hadoop mapreduce
    atguigu
    atguigu

  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
    atguigu 2
    hadoop 2
    mapreduce 1
    yarn 1

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/chen7588693/article/details/84637613