0 简介

1)Hadoop官方网站:​​http://hadoop.apache.org/​

2)Hadoop运行模式包括:本地模式伪分布式模式以及完全分布式模式

  • 本地模式:单机运行,只是用来演示一下官方案例。生产环境不用。
  • 伪分布式模式:也是单机运行,但是具备Hadoop集群的所有功能,一台服务器模拟一个分布式的环境。个别缺钱的公司用来测试,生产环境不用。
  • 完全分布式模式:多台服务器组成分布式环境。生产环境使用。

1 本地运行模式(官方WordCount)

1)创建在hadoop-3.1.3文件下面创建一个wcinput文件夹

[atguigu@hadoop102 hadoop-3.1.3]$ mkdir wcinput

2)在wcinput文件下创建一个word.txt文件

[atguigu@hadoop102 hadoop-3.1.3]$ cd wcinput

3)编辑word.txt文件

[atguigu@hadoop102 wcinput]$ vim word.txt

  • 在文件中输入如下内容


hadoop yarn
hadoop mapreduce
atguigu
atguigu


  • 保存退出::wq

4)回到Hadoop目录/opt/module/hadoop-3.1.3

5)执行程序



[atguigu@hadoop102 hadoop-3.1.3]$ hadoop jar share/hadoop/mapreduce/hadoop-mapreduce-examples-3.1.3.jar wordcount wcinput wcoutput


6)查看结果

[atguigu@hadoop102 hadoop-3.1.3]$ cat wcoutput/part-r-00000

 

看到如下结果:



atguigu 2
hadoop 2
mapreduce 1
yarn 1


 


作者:秋华