大数据应用——Hadoop运行模式(本地运行)

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

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

4.1本地运行模式

4.1.1 官方Grep案例

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

[hadoop@hadoop101 hadoop-2.7.1]$ mkdir input

2. 将Hadoop的xml配置文件复制到input

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

[hadoop@hadoop101 hadoop-2.7.1]$ cd input/

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

[hadoop@hadoop101 hadoop-2.7.1]$

bin/hadoop jar share/hadoop/mapreduce/hadoop-mapreduce-examples-2.7.1.jar grep input output 'dfs[a-z.]+' #找出与dfs所有字符满足的要求

4. 查看输出结果

[hadoop@hadoop101 hadoop-2.7.1]$ cat output/part-r-00000

4.1.2 官方WordCount案例

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

[hadoop@hadoop101 hadoop-2.7.1]$ mkdir wcinput

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

[hadoop@hadoop101 hadoop-2.7.1]$ cd wcinput

[hadoop@hadoop101 wcinput]$ touch wc.txt

3. 编辑wc.input文件

[hadoop@hadoop101 wcinput]$ sudo vi wc.txt

在文件中输入如下内容

hadoop yarn

hadoop mapreduce

hadoop

hadoop

保存退出::wq

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

5. 执行程序

[[email protected]]$

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

6. 查看结果

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

hadoop 2

hadoop 2

mapreduce 1

yarn 1

你可能感兴趣的:(大数据,大数据应用,大数据,Centos7,Hadoop运行模式,hadoop运行模型)