hadoop集羣 應用例子

例子博客html

https://blog.csdn.net/huhui_cs/article/details/9907951ubuntu

http://dbaplus.cn/news-21-1277-1.htmlvim

 

一 搭建好了集羣環境以後,首先咱們先跑一下例子。app

能夠時刻關注http://172.17.0.2:50070/explorer.html信息oop

在ubuntu1 中建立三個文件ui

a.txt內容爲this

this is first file
one
two
three
four

b.txtspa

this is second file
aa
bb
cc
dd
ee
ff

c.txt.net

this is third file
11
22
33
44
55
one
two
aa
bb

在hdfs建立input目錄,而且將三個文件上傳。code

root@ubuntu1:/home/software/hadoop# bin/hdfs dfs -mkdir /input
root@ubuntu1:/home/software/hadoop# vim a.txt
root@ubuntu1:/home/software/hadoop# vim b.txt
root@ubuntu1:/home/software/hadoop# vim c.txt
root@ubuntu1:/home/software/hadoop# 
root@ubuntu1:/home/software/hadoop# 
root@ubuntu1:/home/software/hadoop# 
root@ubuntu1:/home/software/hadoop# 
root@ubuntu1:/home/software/hadoop# bin/hdfs dfs -put  /input
LICENSE.txt  README.txt   b.txt        c.txt        etc/         lib/         logs/        share/       
NOTICE.txt   a.txt        bin/         data/        include/     libexec/     sbin/        
root@ubuntu1:/home/software/hadoop# bin/hdfs dfs -put a.txt b.txt c.txt /input
root@ubuntu1:/home/software/hadoop# bin/hdfs dfs -ls /input
Found 3 items
-rw-r--r--   3 root supergroup         38 2018-05-26 10:33 /input/a.txt
-rw-r--r--   3 root supergroup         38 2018-05-26 10:33 /input/b.txt
-rw-r--r--   3 root supergroup         48 2018-05-26 10:33 /input/c.txt

接下來查找三個文件裏的單詞

root@ubuntu1:/home/software/hadoop# bin/hadoop jar share/hadoop/mapreduce/hadoop-mapreduce-examples-2.9.1.jar grep /input /output '[a-z]'

***********************************************************************************************************************

注意:這裏有可能會卡在INFO mapreduce.Job: Running job: job_1532339328403_0003 ,

http://172.17.0.2:8088/cluster/apps/ACCEPTED能夠看到任務處於ACCEPTED狀態,可是就不執行。

此時須要修改/etc/hosts文件

添加下面的內容  前面是ip  後面是主機名

172.17.0.2      ubuntu1
172.17.0.3      ubuntu2
172.17.0.4      ubuntu3

***********************************************************************************************************************

 

查看結果

root@ubuntu1:/home/software/hadoop# bin/hdfs dfs -get /output output
root@ubuntu1:/home/software/hadoop# cat output/*
相關文章
相關標籤/搜索