4.修改配置文件
把conf目录下带template结尾的文件都去掉template,如nutch-site.xml.template改成nutch-site.xml以防有些插件运行时找不到配置文件。
修改conf下的nutch-site.xml添加一下设置(里面的value随你输):
- <?xml version="1.0"?>
- <?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
- <configuration>
- <property>
- <name>http.agent.name</name>
- <value>your agent name</value>
- </property>
- <property>
- <name>http.agent.description</name>
- <value>escription</value>
- </property>
- <property>
- <name>http.agent.url</name>
- <value>your http agent url</value>
- </property>
- <property>
- <name>http.agent.email</name>
- <value>your http agent email</value>
- </property>
- </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的方法。
