標籤: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文章還真不容易搞。感謝前輩們的分享