nutch1.2運行時可能發生的錯誤以及解決辦法

來源:互聯網
上載者:User

錯誤1.由linux下允許開啟的最大檔案數量引起

錯誤訊息:
java.io.IOException: background merge hit exception: _0:C500->_0 _1:C500->_0 _2:C500->_..... [optimize]
 at org.apache.lucene.index.IndexWriter.optimize(IndexWriter.java:2310)
 at org.apache.lucene.index.IndexWriter.optimize(IndexWriter.java:2249)
 at org.apache.lucene.index.IndexWriter.optimize(IndexWriter.java:2219)
 at org.apache.nutch.indexer.lucene.LuceneWriter.close(LuceneWriter.java:237)
 at org.apache.nutch.indexer.IndexerOutputFormat$1.close(IndexerOutputFormat.java:48)
 at org.apache.hadoop.mapred.ReduceTask.runOldReducer(ReduceTask.java:474)
 at org.apache.hadoop.mapred.ReduceTask.run(ReduceTask.java:411)
 at org.apache.hadoop.mapred.Child.main(Child.java:170)
Caused by: java.io.FileNotFoundException: /var/lib/crawlzilla/nutch-crawler/mapred/local/index/_682243155/_6a.frq (Too many open files)
 at java.io.RandomAccessFile.open(Native Method)
 at java.io.RandomAccessFile.(RandomAccessFile.java:212)
 at org.apache.lucene.store.SimpleFSDirectory$SimpleFSIndexInput$Descriptor.(SimpleFSDirectory.java:76)
 at org.apache.lucene.store.SimpleFSDirectory$SimpleFSIndexInput.(SimpleFSDirectory.java:97)
 at org.apache.lucene.store.NIOFSDirectory$NIOFSIndexInput.(NIOFSDirectory.java:87)
 at org.apache.lucene.store.NIOFSDirectory.openInput(NIOFSDirectory.java:67)
 at org.apache.lucene.index.SegmentReader$CoreReaders.(SegmentReader.java:129)
 at org.apache.lucene.index.SegmentReader.get(SegmentReader.java:576)
 at org.apache.lucene.index.IndexWriter$ReaderPool.get(IndexWriter.java:609)
 at org.apache.lucene.index.IndexWriter.mergeMiddle(IndexWriter.java:4239)
 at org.apache.lucene.index.IndexWriter.merge(IndexWriter.java:3917)
 at org.apache.lucene.index.ConcurrentMergeScheduler.doMerge(ConcurrentMergeScheduler.java:231)
 at org.apache.lucene.index.ConcurrentMergeScheduler$MergeThread.run(ConcurrentMergeScheduler.java:288)

 

原因及解決方案:
    Java程式運行在Unix/Linux環境下,並且該Java程式需要對檔案做大量的操作,則會產生這樣的異常。
    Unix/Linux環境下有檔案控制代碼的限制,可以使用ulimit -n查看當前環境允許開啟的檔案控制代碼數量,預設為1024。但是在我們的Java程式並發接近於或者多餘1024而同時又在頻繁的讀寫檔案,所以會出

現以上異常,解決方式是按實際需要增大對檔案控制代碼的限制數。
    命令:
    ulimit –n 32768

錯誤2.硬碟空間不足

錯誤訊息:
Error: java.io.IOException: No space left on device
 at java.io.FileOutputStream.writeBytes(Native Method)
 at java.io.FileOutputStream.write(FileOutputStream.java:260)
 at org.apache.hadoop.fs.RawLocalFileSystem$LocalFSFileOutputStream.write(RawLocalFileSystem.java:190)
 at java.io.BufferedOutputStream.write(BufferedOutputStream.java:105)
 at org.apache.hadoop.fs.FSDataOutputStream$PositionCache.write(FSDataOutputStream.java:49)
 at java.io.DataOutputStream.write(DataOutputStream.java:90)
 at org.apache.hadoop.mapred.IFileOutputStream.write(IFileOutputStream.java:84)
 at org.apache.hadoop.fs.FSDataOutputStream$PositionCache.write(FSDataOutputStream.java:49)
 at java.io.DataOutputStream.write(DataOutputStream.java:90)
 at org.apache.hadoop.mapred.IFile$Writer.append(IFile.java:218)
 at org.apache.hadoop.mapred.Merger.writeFile(Merger.java:157)
 at org.apache.hadoop.mapred.ReduceTask$ReduceCopier$LocalFSMerger.run(ReduceTask.java:2454)

 

原因及解決方案:
當硬碟不足時nutch會等待可用空間,如果是分布式的話可以增加一個運行節點。

 

錯誤3.namenode ID衝突導致HDFS不能啟動

錯誤訊息:
2010-07-21 10:12:11,987 ERROR org.apache.hadoop.hdfs.server.datanode.DataNode: java.io.IOException: Incompatible namespaceIDs in

/home/admin/joe.wangh/hadoop/data/dfs.data.dir: namenode namespaceID = 898136669; datanode namespaceID = 2127444065

        at org.apache.hadoop.hdfs.server.datanode.DataStorage.doTransition(DataStorage.java:233)
        at org.apache.hadoop.hdfs.server.datanode.DataStorage.recoverTransitionRead(DataStorage.java:148)
        at org.apache.hadoop.hdfs.server.datanode.DataNode.startDataNode(DataNode.java:288)
        at org.apache.hadoop.hdfs.server.datanode.DataNode.<init>(DataNode.java:206)
        at org.apache.hadoop.hdfs.server.datanode.DataNode.makeInstance(DataNode.java:1239)
        at org.apache.hadoop.hdfs.server.datanode.DataNode.instantiateDataNode(DataNode.java:1194)
        at org.apache.hadoop.hdfs.server.datanode.DataNode.createDataNode(DataNode.java:1202)
        at org.apache.hadoop.hdfs.server.datanode.DataNode.main(DataNode.java:1324)
......

 

原因及解決方案:
每次namenode format會重新建立一個namenodeId,而tmp/dfs/data下包含了上次format下的id,namenode format清空了namenode下的資料,但是沒有晴空datanode下的資料,導致啟動時失敗,所要做的就

是每次fotmat前,清空tmp一下的所有目錄。
解決方案1:
停掉hadoop叢集,然後將本地的datanode的資料檔案夾刪除 。檔案夾位置在conf/hdfs-site.xml中配置,預設的話放在/usr/local/hadoop-datastore/hadoop-hadoop(這個是該機器的登入

名)/dfs/data    ,但我的預設放在 /tmp/hadoop-dev(我的hadoop啟動的使用者名稱)  /dfs/data
解決方案2(推薦):
停止datanode節點,找到<dfs.data.dir>/current/VERSION,把裡面的namenode id改為錯誤資訊裡提示的,我這例子裡是898136669

 

錯誤4.設定檔出錯

錯誤訊息:
[Fatal Error] hadoop-site.xml:15:7: The content of elements must consist of well

-formed character data or markup.

Exception in thread "main" java.lang.RuntimeException: org.xml.sax.SAXParseException:

The content of elements must consist of well-formed character data or mark up.

原因及解決方案
nutch-site.xml等設定檔其中一個標籤</property>前面多了一個角括弧。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.