nutch安装配置

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文章还真不容易搞。感谢前辈们的分享

 

posted @ 2014-08-06 17:37  flex_fly  阅读(265)  评论(0编辑  收藏  举报