官方文档:nutch+hadoop
nutch+solr
版本:
nutch:nutch1.6
solr: solr3.6.2
可以参照hadoop1.0.4+nutch1.6“单机”配置
一,ant编译nutch
下载apache-nutch-1.6-src.tar.gz,解压之。
在nutch1.6/conf下
先修改 nutch-default.xml中http.agent.name和http.robots.agents,value值随意,但是要保持一致
http.agent.name
sleeper_qp
HTTP 'User-Agent' request header. MUST NOT be empty -
please set this to a single word uniquely related to your organization.
NOTE: You should also check other related properties:
http.robots.agents
http.agent.description
http.agent.url
http.agent.email
http.agent.version
and set their values appropriately.
http.robots.agents
sleeper_qp
The agent strings we'll look for in robots.txt files,
comma-separated, in decreasing order of precedence. You should
put the value of http.agent.name as the first agent name, and keep the
default * at the end of the list. E.g.: BlurflDev,Blurfl,*
然后
cp nutch-default.xml nutch-site.xml
在nutch1.6下ant编译
二,测试nutch
启动hadoop,新建,上传urls.txt
~/hadoop-1.0.4$ bin/start-all.sh
~/hadoop-1.0.4$ touch urls.txt
在urls.txt写入你想爬的网站
~/hadoop-1.0.4$ bin/hadoop fs -mkdir urls
~/hadoop-1.0.4$ bin/hadoop fs -put urls.txt urls/
添加hadoop的环境变量
修改~/.bashrc:
export HADOOPHOME=/home/hadoop/hadoop
export PATH=$PATH:$HADOOPHOME/bin
说明:直接输入hadoop的命令可能会有警告,这是因为hadoop自身也配置了自己的路径(在HADOOP_HOME/bin/hadoop-config.sh)
在nutch/runtime/deploy下输入
~/nutch1.6/runtime/deploy$ bin/nutch crawl urls -dir crawl -depth 3 -topN 3
解释
-dir是爬取内容存放的文件 -depth 爬取深度 -topN
完成后可查看hdfs
输入hadoop fs -ls查看新的crawl文件夹
三,安装solr
下载解压solr3.6.2
修改NUTCH_HOME/conf下的schema.xml
拷贝NUTCH_HOME/conf下的schema.xml到solr/example/solr/conf/下
然后solr/example/solr/conf/下的solrconfig.xml中的str name="df"后的text全部改为content PS:因为版本的变更,默认值有text该为了content
在{APACHE_SOLR_HOME}/example下输入:
java -jar start.jar
四,整合测试
保证正确,重启hadoop(删除前面的hdfs中的crawl),重启solr
在浏览器下查看相关信息:
http://localhost:8983/solr/
http://localhost:50070
在~/nutch1.6/runtime/deploy下输入
bin/nutch crawl urls -solr http://localhost:8983/solr -dir crawl -depth 1 -topN 1
在正确运行的情况下,可以在http://localhost:8983/solr/admin/ 输入你先前爬取网站的相关内容,可以得到一个xml格式的结果
运维网声明
1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网 享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com