nutch安裝配置

來源:互聯網
上載者:User

標籤:blog   http   java   io   for   ar   問題   new   

http://nlp.solutions.asia/?p=180

http://www.promenade.me/archives/146

環境 ubuntu 12.04

sql建表

 

CREATE DATABASE nutch DEFAULT CHARACTER SET utf8mb4 DEFAULT COLLATE utf8mb4_unicode_ci;

and enter followed by

use nutch;

and enter and then copy and paste the following altogether:

CREATE TABLE `webpage` (
`id` varchar(767) NOT NULL,
`headers` blob,
`text` mediumtext DEFAULT NULL,
`status` int(11) DEFAULT NULL,
`markers` blob,
`parseStatus` blob,
`modifiedTime` bigint(20) DEFAULT NULL,
`score` float DEFAULT NULL,
`typ` varchar(32) CHARACTER SET latin1 DEFAULT NULL,
`baseUrl` varchar(767) DEFAULT NULL,
`content` longblob,
`title` varchar(2048) DEFAULT NULL,
`reprUrl` varchar(767) DEFAULT NULL,
`fetchInterval` int(11) DEFAULT NULL,
`prevFetchTime` bigint(20) DEFAULT NULL,
`inlinks` mediumblob,
`prevSignature` blob,
`outlinks` mediumblob,
`fetchTime` bigint(20) DEFAULT NULL,
`retriesSinceFetch` int(11) DEFAULT NULL,
`protocolStatus` blob,
`signature` blob,
`metadata` blob,
PRIMARY KEY (`id`)
) ENGINE=InnoDB
ROW_FORMAT=COMPRESSED
DEFAULT CHARSET=utf8mb4;

 

 

 

主要問題是

1 sql建表會出現欄位長度太長,

解決辦法:

編輯my.cnf,在mysqld下面加入下面的配置

[mysqld] add

innodb_file_format=barracuda
innodb_file_per_table=true
innodb_large_prefix=true
character-set-server=utf8mb4
collation-server=utf8mb4_unicode_ci
max_allowed_packet=500M

 

 

2 產生batchId時的java錯誤

      編輯    {$nutch_dir}src/java/org/apache/nutch/crawl/GeneratorReducer.java,然後看其100行左右

     batchId的產生方式,改一下換成Rondom隨機生一個

 

----------------------------------------------------------------

batchId = new Utf8(conf.get(GeneratorJob.BATCH_ID));

//改為

int randomSeed = Math.abs(new Random().nextInt());
String batchIdStr = (System.currentTimeMillis() / 1000) + "-" + randomSeed;
batchId = new Utf8( batchIdStr );

 

//別忘了在最上面加上
import java.util.Random;

---------------------------------

 

 

3  gora-core的問題,在  ${nutch_dir}ivy/ivy.xml中找到name="gora-core" rev="0.3"  把0.3  替換成 0.2.1

然後進入${nutch_dir}下,命令列下輸入: ant runtime

等編譯完成後,進入${nutch_dir}runtime/local, 命令列下輸入:bin/nutch crawl urls -depth 3 -topN 5 

如果有錯誤,看log/hadoop.log報什麼錯誤,作相應的修改

4 wegpage表中的batchId 這個欄位不存在的問題,這個在wegpage表中的新增一個 batchId  varchar(767) 就行了。

 

 

終於搞定了,可以採集了,省下的功能再研究

                折騰2個小時,沒有前輩們的blog文章還真不容易搞。感謝前輩們的分享

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.