HADOOP入门(4):使用(3)安装(3)Hadoop运行模式(1)本地运行模式(官方WordCount)

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

2wcinput文件下创建一个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@hadoop10hadoop-3.1.3]$ cat wcoutput/part-r-00000

 

看到如下结果:

atguigu 2
hadoop  2
mapreduce       1
yarn    1

本文来自博客园,作者:秋华,转载请注明原文链接:https://www.cnblogs.com/qiu-hua/p/15228649.html

原文地址:https://www.cnblogs.com/qiu-hua/p/15228649.html