2011-11-20 16 views
1

我試圖運行hadoop jar /usr/lib/hadoop/hadoop-examples.jar aggregatewordcount /data/gutenberg/huckfinn.txt output/guten4,但得到一個錯誤「huckfinn.txt不是SequenceFile」。Hadoop字數計數示例失敗,'not a SequentialFile'。如何設置文件格式?

我在other sites上閱讀,並在source of this example file中看到有一個自變量textinputformat,我猜測修復了這個問題。我無法弄清楚要指定什麼。

如果我跑hadoop jar /usr/lib/hadoop/hadoop-examples.jar aggregatewordcount /data/gutenberg/huckfinn.txt output/guten5 2 textinputformat,我得到一個不同的錯誤,「了java.lang.RuntimeException:在配置對象錯誤」

回答

1

據您的問題聯繫起來mailing list post,在java.lang.RuntimeException: Error in configuring object異常由例子的依賴沒有引起在tasktracker的類路徑上。您可以從完整回溯看到這一點:當我在我的機器上運行你的第二個命令,我得到:

java.lang.RuntimeException: Error in configuring object 
    [...] 
Caused by: java.lang.reflect.InvocationTargetException 
    [...] 
Caused by: java.lang.RuntimeException: Error in configuring object 
    [...] 
Caused by: java.lang.reflect.InvocationTargetException 
    [...] 
Caused by: java.lang.RuntimeException: java.lang.ClassNotFoundException: org.apache.hadoop.examples.AggregateWordCount$WordCountPlugInClass 
    [...] 
Caused by: java.lang.ClassNotFoundException: org.apache.hadoop.examples.AggregateWordCount$WordCountPlugInClass 
    [...] 

This post on the Cloudera blog討論提供的依賴到的TaskTracker的不同方法。

要運行aggregatewordcount例子中,我使用了-libjars選項:

hadoop jar hadoop-examples.jar aggregatewordcount -libjars hadoop-examples.jar /data/gutenberg/huckfinn.txt output/guten7 2 textinputformat

+0

沒有必要添加'-libjars',使用'jar'選項指定的jar文件將被Hadoop框架自動複製到所有節點。如果需要複製任何額外的第三方罐子,那麼必須使用'-libjars'選項。 –

+0

原因喬希是正確的關於我得到的錯誤。添加-libjars可以解決使用Cloudera 3的問題。謝謝Josh! –

1

ValueAggregatorJob如果textinputformat(文本字符串)沒有指定爲在下面的檢查是

int numOfReducers = 1; 
if (args.length > 2) { 
    numOfReducers = Integer.parseInt(args[2]); 
} 

.............. 

if (args.length > 3 && 
    args[3].compareToIgnoreCase("textinputformat") == 0) { 
    theInputFormat = TextInputFormat.class; 
} else { 
    theInputFormat = SequenceFileInputFormat.class; 
} 

一個參數,那麼輸入格式默認爲SequenceFileInputFormat,所以huckfinn.txt not a SequenceFile error。另外,如果沒有指定,則減速器默認爲1。

使用下面的命令來運行作業

hadoop jar hadoop-mapred-examples-0.21.0.jar aggregatewordcount /user/praveensripati/input/sample.txt /user/praveensripati/output 2 textinputformat 

注意,通常是Hadoop的mapred-examples- 0.21.0的.jar在它的版本號。該文件位於Hadoop安裝的根目錄中。確保文件/usr/lib/hadoop/hadoop-examples.jar存在。

要解決java.lang.RuntimeException: Error in configuring object,請檢查日誌文件以獲取堆棧跟蹤並將其發回。

+0

謝謝Praveen。注意觀察這段代碼。這有助於澄清我原來的命令畢竟是好的。關於從我的jar中缺少的版本號,我的目錄有兩個示例jar,一個是w/out版本。最後,喬希提出的解決方案修復了我得到的錯誤。感謝您的詳細回覆,但它有助於我的理解 –

+0

不完全確定,它是如何解決的。 -libjars選項適用於第三方軟件。由'hadoop jar'選項指定的jar由Hadoop框架自動分發。我能夠在沒有-libjars選項的情況下成功運行作業。 –

+0

您是否在使用Cloudera安裝?這可能是Cloudera軟件包的特定問題,以及它們如何安裝(我在Ubuntu 10.04上運行) –