1. 程式人生 > >hadoop自帶例子wordcount的具體執行步驟

hadoop自帶例子wordcount的具體執行步驟

1.在linux系統中,所在目錄“/home/kcm”下建立一個資料夾input

[[email protected]~]$ mkdir input

2.在資料夾input中建立兩個文字檔案file1.txt和file2.txt,file1.txt中內容是“hello word”,file2.txt中內容是“hello hadoop”、“hello mapreduce”(分兩行)。

[[email protected]~]$ cd input
[[email protected]~]$ vi file1.txt(編輯檔案並儲存)
[[email protected]~]$

vi file2.txt(編輯檔案並儲存)

[[email protected]~]$ ls -l /home/kcm/input
file1.txt file2.txt

顯示檔案內容可用:

[[email protected]~]$ cat/home/kcm/input/file1.txt
hello word
[[email protected]~]$ cat /home/kcm/input/file2.txt
hello mapreduce
hello hadoop

3.在HDFS上建立輸入資料夾wc_input,並將本地資料夾input中的兩個文字檔案上傳到叢集的wc_input下

[[email protected]~]$ hadoop fs -mkdir wc_input

[[email protected]~]$ hadoop fs -put/home/kcm/input/file* wc_input

檢視wc_input中的檔案:

[[email protected]~]$ /hadoop fs -ls wc_input
Found 2 items
-rw-r--r-- 1 root supergroup 11 2014-03-13 01:19 /user/hadoop/wc_input/file1.txt
-rw-r--r-- 1 root supergroup 29 2014-03-13 01:19 /user/hadoop/wc_input/file2.txt

4.首先,在window下將wordcount進行打包,我們這裡把它打包成wordcount.jar;然後,將wordcount.jar拷貝到linux系統中,存放的目錄自己決定即可。我們這裡存放到/home/kcm目錄下面。

5.執行wordcount.jar包(轉到該jar包存放的目錄下):

[[email protected]~]$ hadoop jar wordcount.jar /user/hadoop/wc_input /user/hadoop/output

(說明:wordcount.jar 後面不需要跟類名,hadoop自帶demo中有個對映檔案,所以需要指定,自己寫的程式碼沒有這個對映關係,所以不需要帶)

中間遇到的問題:

1.在eclipse中,main函式裡,String[] otherArgs = (new GenericOptionsParser(conf, args)).getRemainingArgs();這句提示有錯誤,是因為commons-cli-1.2.jar沒有匯入。

2.執行jar包後,不報錯,也不生成結果,後來發現是jar包打得有問題。不要選擇runnable方式打jar包,具體原因,現在還不是很清楚。下面是才有runnable生成jar執行時報的錯。


部分參考:http://www.cnblogs.com/xuepei/p/3599202.html

相關推薦

hadoop 示例wordcount 詳細執行步驟

因為機器學習,接觸到了資料探勘;因為資料探勘,接觸到了大資料;因為大資料,接觸到了Hadoop。之前有過hadoop的簡單瞭解,但都是基於別人提供的hadoop來學習和使用,雖然也很好用 ,終究不如自己的使用起來方便 。經過這兩天參考大量網上的經驗,終於成功的搭

hadoop例子wordcount具體執行步驟

1.在linux系統中,所在目錄“/home/kcm”下建立一個資料夾input [[email protected]~]$ mkdir input 2.在資料夾input中建立兩個文字檔案file1.txt和file2.txt,file1.txt中內容是“hel

運行hadoopwordcount例子程序

inpu art ces put 自帶 tput wordcount ems example 1.準備文件 [root@master ~]# cat input.txt hello java hello python hello c hello java hello js

Hadoop3.1.1執行例子wordcount發生的錯誤

 錯誤 1 Error: Could not find or load main class org.apache.hadoop.mapreduce.v2.app.MRAppMaster Please check whether your etc/hadoop/mapred-site.xml con

hadoopwordcount測試

1、建立檔案example.txt,並將其拷貝到hdfs的/user/root中 ./hadoop fs -put /root/example.txt /user/root 2、執行hadoop-mapreduce-examples-2.8.0.jar

HadoopSort例子分析

lan exit more double expr ogr oms lru sort /** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor lic

利用Hadoopexample實現wordCount Failed to execute operation: No such file or directory(systemctl enable iptables.service)

 上次雖然把環境搭好了,但是實際執行起來一堆錯誤,下面簡述一下踩的坑。   1、hadoop fs -put上傳檔案失敗 報錯資訊:(test資料夾是已經成功建好的) [[email protected] ~]# hadoop fs -put test1.txt /

Ubuntu16.04 上執行 Hadoop2.7.3 example wordCount摸索記錄

首先最最重要的寫在最前面,也是我覺得個人踩得最深的坑,剛接觸hadoop的人,缺少的認識: hdfs的理解:它是一個檔案系統,跟linux的檔案系統是類似的結構,擁有類似的語法,大概就是你在linux上ls檢視檔案列表,那麼hdfs的無非就是hadoop fs -ls。ha

HadoopWordCount.java程式

位置:{Hadoop_HOME}\hadoop-0.20.1\src\examples\org\apache\hadoop\examples\WordCount.java 其中{Hadoop_HOME}是安裝後的Hadoop所在的目錄 Hadoop自帶WordCount程式

使用Hadoop例子pi計算圓周率

Hadoop中自帶的hadoop-mapreduce-examples-2.7.6.jar含有一些事例,本文將用pi計算圓周率。若想了解其計算原理,參考:http://thinkinginhadoop.iteye.com/blog/710847。 具體步驟如下: 1. 啟

Caffe例子執行

首先說明一點,在caffe中執行所有程式,都必須在CAFFE的根目錄下進行,否則會出錯。 兩個例子分別是mnist和cifar10,mnist被稱為程式設計界的hello world。 1

OPENCV SVM介紹和例子

位置 amp vma width 數據線 degree 當前 來看 get 依據機器學習算法如何學習數據可分為3類:有監督學習:從有標簽的數據學習,得到模型參數,對測試數據正確分類;無監督學習:沒有標簽,計算機自己尋找輸入數據可能的模型;強化學習(reinforcement

Geant4采用make和cmake編譯運行geant4例子的方法

剛才 例子 1-1 build g++ 核數 emp cmake 編譯 該教程介紹如何將geant4中自帶的例子通過camke編譯成可執行文件,並運行程序。 1 在linux主目錄下創建一個geant4_workdir目錄,並將geant4自帶的例子B1復制到該目錄

opencv 單目相機標定 例子程式的使用

<link rel="stylesheet" href="https://csdnimg.cn/release/phoenix/template/css/

人臉與人眼識別 opencv例子

所做的工作就是新建了一個VS2010工程,win32控制檯應用程式,空工程。 只新建了一個cpp檔案 拷貝以下程式碼(百度來的,感謝網友。。。) // face_detect.cpp : 定義控制檯應用程式的入口點。 // //#include "stdafx.h"

Unity3D中事件函式的執行順序

在Unity3D指令碼中,有幾個Unity3D自帶的事件函式按照預定的順序執行作為指令碼執行。其執行順序如下: 編輯器(Editor) Reset:Reset函式被呼叫來初始化指令碼屬性當指令碼第一次被附到物件上,並且在Reset命令被使用時也會呼叫。 編者注:Reset是

storm例子詳解 (一)——WordCountTopologyNode

/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * dist

MapReduce-Join中級優化-hadoopdatajoin的解決方法

接著上一篇《MapReuce-Join操作-初級優化》這一篇部落格繼續說明MapReduce對於Join的操作,這裡使用hadoop包中自帶的datajoin包來處理,如果是hadoop1.x則包在${HADOOP_HOME}/contrib/datajoin資料夾下。如果

星環大數據安全組件Guardian與hadoop的安全組件區別

對象 linux 密碼 tro snap 方法 輪廓 control 重要 在進行講解之前,先帶大家學習下hadoop關於hdfs自己的安全如何實現的--------------------------- 名詞: ACL-訪問控制列表(Access Control Li

OpenCV例子(三)兩幅影象相加

#include <cv.h> #include <highgui.h> #include <iostream> using namespace cv; int main( int argc, char** argv ) { doubl