Nutch学习笔记一 ---环境搭建
学习环境: ubuntu
概要:
Nutch 是一个开源Java 实现的搜索引擎。它提供了我们运行自己的搜索引擎所需的全部工具。包括全文搜索和Web爬虫。
通过nutch,诞生了hadoop、tika、gora。
先安装SVN和Ant环境。(通过编译源码方式来使用nutch)
apt-get install ant
apt-get install subversion
hu@hu-VirtualBox:~/data/nutch$ svn co https://svn.apache.org/repos/asf/nutch/tags/release-1.6/
hu@hu-VirtualBox:~/data/nutch$ cd release-1.6/
hu@hu-VirtualBox:~/data/nutch/release-1.6$ ant
hu@hu-VirtualBox:~/data/nutch/release-1.6$ cd runtime/
备注runtime目录下有两个目录,分别代表了nutch两种不同运行方式。deploy依赖hadoop。
hu@hu-VirtualBox:~/data/nutch/release-1.6/runtime$ ls
deploy local
那nutch和hadoop是通过什么连接起来的?
hu@hu-VirtualBox:~/data/nutch/release-1.6/runtime$ ls deploy/
apache-nutch-1.6.job bin
是通过nutch脚本。通过hadoop命令吧apache-nutch-1.6.job提交给hadoop的JobTracker。
hu@hu-VirtualBox:~/data/nutch/release-1.6/runtime$ cd local/
hu@hu-VirtualBox:~/data/nutch/release-1.6/runtime/local$ mkdir urls
hu@hu-VirtualBox:~/data/nutch/release-1.6/runtime/local$ touch urls/url.txt
hu@hu-VirtualBox:~/data/nutch/release-1.6/runtime/local$ vi urls/url.txt
备注:urls/url.txt中输入爬取地址 http://blog.tianya.cn
hu@hu-VirtualBox:~/data/nutch/release-1.6/runtime/local$ ./bin/nutch crawl
Usage: Crawl <urlDir> -solr <solrURL> [-dir d] [-threads n] [-depth i] [-topN N]
hu@hu-VirtualBox:~/data/nutch/release-1.6/runtime/local$ nohup ./bin/nutch crawl urls -dir data -threads 100 -depth 3 &
备注:查看运行概要 hu@hu-VirtualBox:~/data/nutch/release-1.6/runtime/local$ cat nohup.out
查看运行详情 通过logs/hadoop.log文件
hu@hu-VirtualBox:~/data/nutch/release-1.6/runtime/local$ ls logs/
hadoop.log
通过查看nohup.out发现出现异常
hu@hu-VirtualBox:~/data/nutch/release-1.6/runtime/local$ cat nohup.out
solrUrl is not set, indexing will be skipped...
crawl started in: data
rootUrlDir = urls
threads = 100
depth = 3
solrUrl=null
Injector: starting at 2013-12-08 21:10:30
Injector: crawlDb: data/crawldb
Injector: urlDir: urls
Injector: Converting injected urls to crawl db entries.
solrUrl is not set, indexing will be skipped...
crawl started in: data
rootUrlDir = urls
threads = 100
depth = 3
solrUrl=null
Injector: starting at 2013-12-08 21:10:38
Injector: crawlDb: data/crawldb
Injector: urlDir: urls
Injector: Converting injected urls to crawl db entries.
Injector: total number of urls rejected by filters: 0
Injector: total number of urls injected after normalization and filtering: 1
Injector: Merging injected urls into crawl db.
Injector: finished at 2013-12-08 21:10:53, elapsed: 00:00:14
Generator: starting at 2013-12-08 21:10:53
Generator: Selecting best-scoring urls due for fetch.
Generator: filtering: true
Generator: normalizing: true
Generator: jobtracker is 'local', generating exactly one partition.
Generator: Partitioning selected urls for politeness.
Generator: segment: data/segments/20131208211101
Generator: finished at 2013-12-08 21:11:08, elapsed: 00:00:15
Fetcher: No agents listed in 'http.agent.name' property.
Exception in thread "main" java.lang.IllegalArgumentException: Fetcher: No agents listed in 'http.agent.name' property.
at org.apache.nutch.fetcher.Fetcher.checkConfiguration(Fetcher.java:1389)
at org.apache.nutch.fetcher.Fetcher.fetch(Fetcher.java:1274)
at org.apache.nutch.crawl.Crawl.run(Crawl.java:136)
at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:65)
at org.apache.nutch.crawl.Crawl.main(Crawl.java:55)
【解决方案】
hu@hu-VirtualBox:~/data/nutch/release-1.6/runtime/local$ vi conf/nutch-site.xml
打开 conf/nutch-site.xml. 在nutch-site.xml中添加"http.agent.name"信息。 (conf/nutch-default.xml有默认配置信息)
<configuration>
<property>
<name>http.agent.name</name>
<value>Mozilla/5.0 (Windows NT 6.1; WOW64; rv:20.0; WUID=11ec69f3ac129124d5a2480d127648e0; WTB=2938) Gecko/20100101 Firefox/20.0</value>
<description>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.
</description>
</property>
</configuration>
(如果修改源文件中配置文件,即/release-1.6/conf/nutch-site.xml,在更改nutch配置文件之后,需要重新进行ant编译)
hu@hu-VirtualBox:~/data/nutch/release-1.6/runtime/local$ ls data/
crawldb linkdb segments
下回再学关于查看抓取数据详细信息。
总结:nutch的入门重点在于分析nutch脚本文件
参考:
http://yangshangchuan.iteye.com/category/275433
http://www.oschina.net/translate/nutch-tutorial Nutch 教程
Nutch学习笔记一 ---环境搭建的更多相关文章
- Android Studio 学习笔记(一)环境搭建、文件目录等相关说明
Android Studio 学习笔记(一)环境搭建.文件目录等相关说明 引入 对APP开发而言,Android和iOS是两大主流开发平台,其中区别在于 Android用java语言,用Android ...
- 我的Java学习笔记 -开发环境搭建
开始学习Java~ 一.Java简介 Java编程语言是一种简单.面向对象.分布式.解释型.健壮安全.与系统无关.可移植.高性能.多线程和动态的语言. Java分为三个体系: JavaSE(J2SE) ...
- Django学习笔记 开发环境搭建
为什么使用django?1.支持快速开发:用python开发:数据库ORM系统,并不需要我们手动地构造SQL语句,而是用python的对象访问数据库,能够提升开发效率.2.大量内置应用:后台管理系统a ...
- cocos2d-x lua 学习笔记(1) -- 环境搭建
Cocos2d-x 3.0以上版本的环境搭建和之前的Cocos2d-x 2.0 版差异较大的,同时从Cocos2d-x 3.0项目打包成apk安卓应用文件,搭建安卓环境的步骤有点繁琐,但搭建一次之后, ...
- SpringData JPA的学习笔记之环境搭建
一.环境搭建 1.加入jar包 spring jar+jpa jar +springData jar >>SpringData jar包 2.配置applicationCont ...
- Mybatis学习笔记之---环境搭建与入门
Mybatis环境搭建与入门 (一)环境搭建 (1)第一步:创建maven工程并导入jar包 <dependencies> <dependency> <groupId&g ...
- 前端框架vue学习笔记:环境搭建
兼容性 不兼容IE8以下 Vue Devtools 能够更好的对界面进行审查和调试 环境搭建 1.nodejs(新版本的集成了npm)[npm是node包管理 node package manager ...
- Web安全测试学习笔记 - vulhub环境搭建
Vulhub和DVWA一样,也是开源漏洞靶场,地址:https://github.com/vulhub/vulhub 环境搭建过程如下: 1. 下载和安装Ubuntu 16.04镜像,镜像地址:htt ...
- 【Django学习笔记】-环境搭建
对于初学django新手,根据以下步骤可以快速进行Django环境搭建 虚拟环境创建 使用virtualenv创建并启用虚拟机环境 ,关于virtualenv可参考https://www.yuque. ...
随机推荐
- java中,为什么char类型数组可以直接用数组名打印,打印结果居然不是地址值!
char类型的数组就相当于一个字符串. 因为输出流System.out是PrintStream对象,PrintStream有多个重载的println方法,其中一个就是public void print ...
- Selenium WebDriver-通过断言页面是否存在某些关键字来确定页面按照预期加载
#encoding=utf-8 import unittest import time import chardet from selenium import webdriver class Visi ...
- day04_06 短路原则
True和False不能写成ture和false,不然会报错 not not True or False and not True 按照not>and>or来进行括号 (not (not ...
- Python学习-day7 类 部分socket
这周还是继续关于类的学习,在面向对象的学习过程中又学习了网络编程,并且提交了编写FTP的作业. 复习一下类的相关概念和定义 类 属性 实例变量:内存中 ...
- LaTeX新人教程,30分钟从完全陌生到基本入门[转载]
LaTeX新人教程,30分钟从完全陌生到基本入门[转载] 2017-02-05 分类:TeX讲义 阅读(32514) 评论(0) 这是一篇老文了,前几天看微博的时候看到的,文中的很多表达比较过激,思 ...
- [python学习篇][书籍学习][python standrad library][内建函数]之[list,open,len,pow,range,
Python 解释器内置了一些函数,它们总是可用的.这里将它们按字母表顺序列出. Built-in Functions abs() divmod() input() open() st ...
- oracle查询包含大小写的数据
查询包含小写的所有数据: select oper_no from info_oper where regexp_like(oper_no,'[[:lower:]]'); select oper_no ...
- 【bzoj3566】[SHOI2014]概率充电器 树形概率dp
题目描述 著名的电子产品品牌 SHOI 刚刚发布了引领世界潮流的下一代电子产品——概率充电器:“采用全新纳米级加工技术,实现元件与导线能否通电完全由真随机数决定!SHOI 概率充电器,您生活不可或缺的 ...
- 广东工业大学2016校赛决赛重现——E积木积水(方法据说很多)
Problem E: 积木积水 Description 现有一堆边长为1的已经放置好的积木,小明(对的,你没看错,的确是陪伴我们成长的那个小明)想知道当下雨天来时会有多少积水.小明又是如此地喜欢二次元 ...
- IndiaHacks 2016 - Online Edition (Div. 1 + Div. 2)——A - Bear and Three Balls(unique函数的使用)
A. Bear and Three Balls time limit per test 2 seconds memory limit per test 256 megabytes input stan ...