CREATE DATABASE nutch DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
CREATE TABLE `webpage` (
`id` varchar(767) CHARACTER SET latin1 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(512) CHARACTER SET latin1 DEFAULT NULL,
`content` mediumblob,
`title` varchar(2048) DEFAULT NULL,
`reprUrl` varchar(512) CHARACTER SET latin1 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 DEFAULT CHARSET=utf8;
2、安装nutch2.1
A、 nutch下载地址:http://apache.etoak.com/nutch/2.1/apache-nutch-2.1-src.zip
# Default SqlStore properties ################################
#gora.sqlstore.jdbc.driver=org.hsqldb.jdbc.JDBCDriver#gora.sqlstore.jdbc.url=jdbc:hsqldb:hsql://localhost/nutchtest#gora.sqlstore.jdbc.user=sa#gora.sqlstore.jdbc.password=
################################ MySQL properties################################gora.sqlstore.jdbc.driver=com.mysql.jdbc.Driver
gora.sqlstore.jdbc.url=jdbc:mysql://localhost:3306/nutch?createDatabaseIfNotExist=true
gora.sqlstore.jdbc.user=xxxxx(mysql用户名)
gora.sqlstore.jdbc.password=xxxxx(mysql密码)
D、修改${APACHE_NUTCH_HOME}/conf/nutch-site.xml 加入如下代码:
http.agent.name
Your Nutch Spider
http.accept.language
ja-jp, en-us,en-gb,en;q=0.7,*;q=0.3
Value of the “Accept-Language” request header field. This allows selecting non-English language as default one to retrieve.
It is a useful setting for search engines build for certain national group.
parser.character.encoding.default
utf-8
The character encoding to fall back to when no other information is available
storage.data.store.class
org.apache.gora.sql.store.SqlStore
The Gora DataStore class for storing and retrieving data. Currently the following stores are available: ….
E、使用ant编译 ${APACHE_NUTCH_HOME} 。
cd ${APACHE_SOLR_HOME}/example
java -jar start.jar
D 、在浏览器输入地址
http://localhost:8983/solr 测试是否启动成功。
E、另起linux终端,输入如下命令,使solr对nutch抓取内容进行索引。
cd ${APACHE_NUTCH_HOME}/runtime/local/
bin/nutch solrindex http://127.0.0.1:8983/solr/ -reindex