手机版
你好,游客 登录 注册 搜索
背景:
阅读新闻

Eclipse中调试Nutch2.0

[日期:2012-06-04] 来源:Linux社区  作者:laigood12345 [字体:大 中 小]

4.修改配置文件

把conf目录下带template结尾的文件都去掉template,如nutch-site.xml.template改成nutch-site.xml以防有些插件运行时找不到配置文件。

修改conf下的nutch-site.xml添加一下设置(里面的value随你输):

  1. <?xml version="1.0"?>  
  2. <?xml-stylesheet type="text/xsl" href="configuration.xsl"?>  
  3.   
  4. <configuration>  
  5.     <property>  
  6.         <name>http.agent.name</name>  
  7.         <value>your agent name</value>  
  8.     </property>  
  9.   
  10.     <property>  
  11.         <name>http.agent.description</name>  
  12.         <value>escription</value>  
  13.     </property>  
  14.   
  15.     <property>  
  16.         <name>http.agent.url</name>  
  17.         <value>your http agent url</value>  
  18.     </property>  
  19.   
  20.     <property>  
  21.         <name>http.agent.email</name>  
  22.         <value>your http agent email</value>  
  23.     </property>  
  24. </configuration>  

修改conf下的/nutch/conf/gora.properties

注释掉关系数据库的配置信息:

#gora.sqlstore.jdbc.driver=org.hsqldb.jdbc.JDBCDriver

#gora.sqlstore.jdbc.url=jdbc:hsqldb://localhost/test

#gora.sqlstore.jdbc.user=sa

#gora.sqlstore.jdbc.password=

把gora.cassandrastore.servers=localhost:9160这行的注释去掉,表名使用cassandra作为存储层

5.启动cassandra

启动cassandra,cassandra的启动参考:http://www.linuxidc.com/Linux/2012-06/61940.htm,我用的是1.01版本的cassandra。

6.执行爬虫

在根目录下建立个urls文件夹,在文件夹下新建个txt文档,随便输入几个网站,如:http://www.88181.com/,一行一个网站

最后用Java application运行/nutch/src/java/org/apache/nutch/crawl/Crawler.java 参数:urls -depth 2 爬虫就执行起来,爬取的网页会保存到cassandra中。

索引nutch2.0和nutch1.3+一样,都是使用solr作为搜索程序,所以用法和nutch1.3+的一样,这里就不介绍了,用惯了elasticsearch,现在真心觉得solr太麻烦,配都懒得配个出来调试了,直接改源码,添加nutch文档索引到elasticsearch的方法。

linux
相关资讯       Eclipse  Nutch 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款