Hadoop本地運行模式

P.S.

我爲了不打擾我的畢設內容(hadoop101已被畢設佔用),重新配置了虛擬機hadoop100,和上文的hadoop101沒有區別,只是名字和ip地址不同而已。特此說明。

 

目錄

2.Hadoop本地運行模式

2.1 官方Grep案例

2.1.1 在hadoop-2.9.2文件夾下創建一個input 文件夾

2.1.2 將Hadoop的xml配置文件複製到input

2.1.3 執行share目錄下的MapReduce程序

2.1.4 查看輸出結果

 

2.2 官方WordCount 案例

2.2.1 在hadoop-2.9.2文件夾下創建一個wcinput文件夾

2.2.2 在wcinput文件夾下創建一個wc.input文件

2.2.3 編輯wc.input

2.2.4 回到Hadoop目錄/opt/module/hadoop-2.9.2

2.2.5 執行程序

2.2.6 查看結果


 

2.Hadoop本地運行模式

 

2.1 官方Grep案例

2.1.1 在hadoop-2.9.2文件夾下創建一個input 文件夾

[atlingtree@hadoop100 ~]$ cd /opt/modules/hadoop-2.9.2
[atlingtree@hadoop100 hadoop-2.9.2]$ mkdir input

2.1.2 將Hadoop的xml配置文件複製到input

[atlingtree@hadoop100 hadoop-2.9.2]$ cp etc/hadoop/*.xml input
[atlingtree@hadoop100 hadoop-2.9.2]$ cd input/
[atlingtree@hadoop100 input]$ ll
total 48
-rw-r--r--. 1 atlingtree atlingtree  7861 May  5 10:04 capacity-scheduler.xml
-rw-r--r--. 1 atlingtree atlingtree   774 May  5 10:04 core-site.xml
-rw-r--r--. 1 atlingtree atlingtree 10206 May  5 10:04 hadoop-policy.xml
-rw-r--r--. 1 atlingtree atlingtree   775 May  5 10:04 hdfs-site.xml
-rw-r--r--. 1 atlingtree atlingtree   620 May  5 10:04 httpfs-site.xml
-rw-r--r--. 1 atlingtree atlingtree  3518 May  5 10:04 kms-acls.xml
-rw-r--r--. 1 atlingtree atlingtree  5939 May  5 10:04 kms-site.xml
-rw-r--r--. 1 atlingtree atlingtree   690 May  5 10:04 yarn-site.xml

2.1.3 執行share目錄下的MapReduce程序

[atlingtree@hadoop100 input]$ cd ..
[atlingtree@hadoop100 hadoop-2.9.2]$ bin/hadoop jar share/hadoop/mapreduce/hadoop-mapreduce-examples-2.9.2.jar grep input output 'dfs[a-z.]+'

2.1.4 查看輸出結果

[atlingtree@hadoop100 hadoop-2.9.2]$ cat output/*
1	dfsadmin

 

2.2 官方WordCount 案例

2.2.1 在hadoop-2.9.2文件夾下創建一個wcinput文件夾

[atlingtree@hadoop100 hadoop-2.9.2]$ mkdir wcinput

2.2.2 在wcinput文件夾下創建一個wc.input文件

[atlingtree@hadoop100 hadoop-2.9.2]$ cd wcinput/
[atlingtree@hadoop100 wcinput]$ touch wc.input

2.2.3 編輯wc.input

[atlingtree@hadoop100 wcinput]$ vi wc.input

在文件中輸入如下內容:

hadoop yarn
hadoop mapreduce
ignb
tesnb
ignb

保存退出 :wq

2.2.4 回到Hadoop目錄/opt/module/hadoop-2.9.2

[atlingtree@hadoop100 wcinput]$ cd /opt/modules/hadoop-2.9.2/

2.2.5 執行程序

[atlingtree@hadoop100 hadoop-2.9.2]$ hadoop jar share/hadoop/mapreduce/hadoop-mapreduce-examples-2.9.2.jar wordcount wcinput wcoutput

2.2.6 查看結果

[atlingtree@hadoop100 hadoop-2.9.2]$ cat wcoutput/part-r-00000 
hadoop	2
ignb	2
mapreduce	1
tesnb	1
yarn	1

 

 

 

 

 

 

 

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章