环境搭建:
1.安装subversion:
apt-get install subversion(如果系统里自带的是yum,需要执行yum -y install subversion);
2.安装ant:
apt-get install ant(如果系统里自带的是yum,同理需要执行yum -y install ant);
下载nutch1.7:
1.利用svn从服务器上checkout下来nutch1.6:
svn co https://svn.apache.org/repos/asf/nutch/tags/release-1.6/
这个过程有可能会报错unkown host "https://svn.apache.org",可能是机器的网络配置问题,我当时遇到这个问题的时候是在公司的网络环境下遇到的,
公司的网络配置了代理服务器,我在机器上执行ping https://svn.apache.org也是报错unkown host "https://svn.apache.org"。所以当遇到这个问题时,
可以换个没有代理的网络环境,网上说需要配置下DNS服务器也可以解决(本人未实践,具体如何未知)
2.导出的目录是release-1.6/,进入目录,cd release-1.6;
3.执行ant命令,编译nutch。这个过程也会出现问题,好像也是跟网络环境有关,当时在公司的网络环境中一直无法编译,回到家后,执行成功了。
4.编译完成后,生成runtime文件夹,进入runtime/local目录下:cd runtime/local;
5.配置nutch-site.xml:vi conf/nutch-site.xml 增加http.agent.name配置:
<configuration>
<property>
<name>http.agent.name</name>
<value>nutch agent name</value>
</property>
</configuration>
6. 执行命令:
mkdir urls
vi urls/url.txt 并输入http://blog.tianya.cn
nohup bin/nutch crawl urls -dir data -depth 3 -threads 100 &