下载nutch1.9
http://mirrors.hust.edu.cn/apache/nutch/1.9/apache-nutch-1.9-bin.tar.gz
解压到~/DevelopmentKits/
建立符号链接
ln -s ~/DevelopmentKits/apache-nutch-1.9 nutch
在.bash_profile 中设置 NUTCH_HOME=/home/zhw/DevelopmentKits/nutch
执行$NATCH_HOME/bin/natch,查看安装情况。下面的操作都默认在$NUTCH_HOME下
编辑conf/nutch-site.xml,设置成下面的样子
<configuration>
<property>
<name> http.agent.name</name>
<value> my nutch spider</value>
</property>
</configuration>
创建ruls的相关配置
mkdir -p urls
cd urls
touch seed.txt
在seed.txt 中加入一行
http://nutch.apache.org
编辑conf/regex-urlfilter.txt
将原来的
# accept anything else +.替换为
# accept anything else表示只搜索 nutch.apache.org中的文章+^http://([a-z0-9]*\.)*nutch.apache.org/
假设之前已经安装了solr,在tomcat7上部署Solr-4.10.1
执行抓取命令bin/crawl,命令格式为
Usage: bin/crawl <seedDir> <crawlDir> <solrURL> <numberOfRounds>
这里是: bin/crawl urls/ TestCrawl/ http://localhost:8080/solr/ 2
与solr的集成
备份原来的schema.xml
mv ${SOLR_HOME}/example/solr/collection1/conf/schema.xml ${SOLR_HOME}/example/solr/collection1/conf/schema.xml.org
复制nutch中的schema-solr4.xml到solr中
cp ${NUTCH_HOME}/conf/schema-solr4.xml ${SOLR_HOME}/solr/collection1/conf/
编辑这个文件
vi ${SOLR_HOME}/solr/collection1/conf/schema.xml
增加下面一行到<field name="id" ... /> (probably at line 69-70)下
<field name="_version_" type="long" indexed="true" stored="true"/>