`

Run Nutch In Eclipse on Linux and Windows nutch version 1.0

阅读更多
参考官方文档,通过努力终于我nutch在eclispe下跑通了:),真的很好,很详细,不知道自己有没耐心些这样的文章:)
This is a work in progress. If you find errors or would like to improve this page, just create an account [UserPreferences] and start editing this page 

Tested with
Nutch release 1.0

Eclipse 3.3 (Europa) and 3.4 (Ganymede)

Java 1.6

Ubuntu (should work on most platforms though)

Windows XP and Vista

Before you start
Setting up Nutch to run into Eclipse can be tricky, and most of the time it is much faster if you edit Nutch in Eclipse but run the scripts from the command line (my 2 cents). However, it's very useful to be able to debug Nutch in Eclipse. Sometimes examining the logs (logs/hadoop.log) is quicker to debug a problem.

Steps
For Windows Users
If you are running Windows (tested on Windows XP) you must first install cygwin. Download it from  http://www.cygwin.com/setup.exe

Install cygwin and set the PATH environment variable for it. You can set it from the Control Panel, System, Advanced Tab, Environment Variables and edit/add PATH.

Example PATH:

C:\Sun\SDK\bin;C:\cygwin\bin
If you run "bash" from the Windows command line (Start > Run... > cmd.exe) it should successfully run cygwin.

If you are running Eclipse on Vista, you will need to either give cygwin administrative privileges or  turn off Vista's User Access Control (UAC). Otherwise Hadoop will likely complain that it cannot change a directory permission when you later run the crawler:

org.apache.hadoop.util.Shell$ExitCodeException: chmod: changing permissions of ... Permission denied
See  this for more information about the UAC issue.

Install Nutch
Grab a  fresh release of Nutch 1.0 or download and untar the  official 1.0 release.

Do not build Nutch yet. Make sure you have no .project and .classpath files in the Nutch directory

Create a new Java Project in Eclipse
File > New > Project > Java project > click Next

Name the project (Nutch_Trunk for instance)

Select "Create project from existing source" and use the location where you downloaded Nutch

Click on Next, and wait while Eclipse is scanning the folders

Add the folder "conf" to the classpath (click the "Libraries" tab, click "Add Class Folder..." button, and select "conf" from the list)

Go to "Order and Export" tab, find the entry for added "conf" folder and move it to the top (by checking it and clicking the "Top" button). This is required so Eclipse will take config (nutch-default.xml, nutch-final.xml, etc.) resources from our "conf" folder and not from somewhere else.

Eclipse should have guessed all the Java files that must be added to your classpath. If that's not the case, add "src/java", "src/test" and all plugin "src/java" and "src/test" folders to your source folders. Also add all jars in "lib" and in the plugin lib folders to your libraries

Click the "Source" tab and set the default output folder to "Nutch_Trunk/bin/tmp_build". (You may need to create the tmp_build folder.)

Click the "Finish" button

DO NOT add "build" to classpath

Configure Nutch
See the  Tutorial

Change the property "plugin.folders" to "./src/plugin" on $NUTCH_HOME/conf/nutch-defaul.xml

Make sure Nutch is configured correctly before testing it into Eclipse 

Missing org.farng and com.etranslate
Eclipse will complain about some import statements in parse-mp3 and parse-rtf plugins (30 errors in my case). Because of incompatibility with the Apache license, the .jar files that define the necessary classes were not included with the source code.

Download them here:

http://nutch.cvs.sourceforge.net/nutch/nutch/src/plugin/parse-mp3/lib/

http://nutch.cvs.sourceforge.net/nutch/nutch/src/plugin/parse-rtf/lib/

Copy the jar files into src/plugin/parse-mp3/lib and src/plugin/parse-rtf/lib/ respectively. Then add the jar files to the build path (First refresh the workspace by pressing F5. Then right-click the project folder > Build Path > Configure Build Path... Then select the Libraries tab, click "Add Jars..." and then add each .jar file individually).

Two Errors with RTFParseFactory
If you are trying to build the official 1.0 release, Eclipse will complain about 2 errors regarding the RTFParseFactory (this is after adding the RTF jar file from the previous step). This problem was fixed (see  NUTCH-644 and  NUTCH-705) but was not included in the 1.0 official release because of licensing issues. So you will need to manually alter the code to remove these 2 build errors.

In RTFParseFactory.java:

Add the following import statement: import org.apache.nutch.parse.ParseResult;

Change

public Parse getParse(Content content) {
to

public ParseResult getParse(Content content) {
In the getParse function, replace

return new ParseStatus(ParseStatus.FAILED,
                               ParseStatus.FAILED_EXCEPTION,
                               e.toString()).getEmptyParse(conf);
with

return new ParseStatus(ParseStatus.FAILED,
                ParseStatus.FAILED_EXCEPTION,
              e.toString()).getEmptyParseResult(content.getUrl(), getConf());
In the getParse function, replace

return new ParseImpl(text,
                         new ParseData(ParseStatus.STATUS_SUCCESS,
                                       title,
                                       OutlinkExtractor.getOutlinks(text, this.conf),
                                       content.getMetadata(),
                                       metadata));
with

return ParseResult.createParseResult(content.getUrl(),
                             new ParseImpl(text,
                                     new ParseData(ParseStatus.STATUS_SUCCESS,
                                             title,
                                             OutlinkExtractor.getOutlinks(text, this.conf),
                                             content.getMetadata(),
                                             metadata)));

In TestRTFParser.java, replace

parse = new ParseUtil(conf).parseByExtensionId("parse-rtf", content);
with

parse = new ParseUtil(conf).parseByExtensionId("parse-rtf", content).get(urlString);
Once you have made these changes and saved the files, Eclipse should build with no errors.

Build Nutch
If you setup the project correctly, Eclipse will build Nutch for you into "tmp_build". See below for problems you could run into.

Create Eclipse launcher
Menu Run > "Run..."

create "New" for "Java Application"

set in Main class

org.apache.nutch.crawl.Crawl
on tab Arguments, Program Arguments

urls -dir crawl -depth 3 -topN 50
in VM arguments

-Dhadoop.log.dir=logs -Dhadoop.log.file=hadoop.log
click on "Run"

if all works, you should see Nutch getting busy at crawling 

Debug Nutch in Eclipse (not yet tested for 0.9)
Set breakpoints and debug a crawl

It can be tricky to find out where to set the breakpoint, because of the Hadoop jobs. Here are a few good places to set breakpoints:

Fetcher [line: 371] - run
Fetcher [line: 438] - fetch
Fetcher$FetcherThread [line: 149] - run()
Generator [line: 281] - generate
Generator$Selector [line: 119] - map
OutlinkExtractor [line: 111] - getOutlinks
If things do not work...
Yes, Nutch and Eclipse can be a difficult companionship sometimes 

Java Heap Size problem
If the crawler throws an IOException exception early in the crawl (Exception in thread "main" java.io.IOException: Job failed!), check the logs/hadoop.log file for further information. If you find in hadoop.log lines similar to this:

2009-04-13 13:41:06,105 WARN  mapred.LocalJobRunner - job_local_0001
java.lang.OutOfMemoryError: Java heap space
then you should increase amount of RAM for running applications from Eclipse.

Just set it in:

Eclipse -> Window -> Preferences -> Java -> Installed JREs -> edit -> Default VM arguments

I've set mine to

-Xms5m -Xmx150m
because I have like 200MB RAM left after running all apps

-Xms (minimum ammount of RAM memory for running applications) -Xmx (maximum)

Eclipse: Cannot create project content in workspace
The nutch source code must be out of the workspace folder. My first attempt was download the code with eclipse (svn) under my workspace. When I try to create the project using existing code, eclipse don't let me do it from source code into the workspace. I use the source code out of my workspace and it work fine.

plugin dir not found
Make sure you set your plugin.folders property correct, instead of using a relative path you can use a absolute one as well in nutch-defaults.xml or may be better in nutch-site.xml

<property>
  <name>plugin.folders</name>
  <value>/home/....../nutch-0.9/src/plugin</value>
No plugins loaded during unit tests in Eclipse
During unit testing, Eclipse ignored conf/nutch-site.xml in favor of src/test/nutch-site.xml, so you might need to add the plugin directory configuration to that file as well.

Unit tests work in eclipse but fail when running ant in the command line
Suppose your unit tests work perfectly in eclipse, but each and everyone fail when running ant test in the command line - including the ones you haven't modified. Check if you defined the plugin.folders property in hadoop-site.xml. In that case, try removing it from that file and adding it directly to nutch-site.xml

Run ant test again. That should have solved the problem.

If that didn't solve the problem, are you testing a plugin? If so, did you add the plugin to the list of packages in plugin\build.xml, on the test target?

classNotFound
open the class itself, rightclick

refresh the build dir

debugging hadoop classes
Sometime it makes sense to also have the hadoop classes available during debugging. So, you can check out the Hadoop sources on your machine and add the sources to the hadoop-xxx.jar. Alternatively, you can:

Remove the hadoopXXX.jar from your classpath libraries

Checkout the hadoop brunch that is used within nutch

configure a hadoop project similar to the nutch project within your eclipse

add the hadoop project as a dependent project of nutch project

you can now also set break points within hadoop classes lik inputformat implementations etc.

Failed to get the current user's information
On Windows, if the crawler throws an exception complaining it "Failed to get the current user's information" or 'Login failed: Cannot run program "bash"', it is likely you forgot to set the PATH to point to cygwin. Open a new command line window (All Programs > Accessories > Command Prompt) and type "bash". This should start cygwin. If it doesn't, type "path" to see your path. You should see within the path the cygwin bin directory (e.g., C:\cygwin\bin). See the steps to adding this to your PATH at the top of the article under "For Windows Users". After setting the PATH, you will likely need to restart Eclipse so it will use the new PATH.

Original credits: RenaudRichardet

分享到:
评论

相关推荐

    nutch安装开发环境的配置

    你需要在 Eclipse 工程目录下找到 `build.xml`,然后通过 `Run As` -&gt; `Ant Build` 来编译源代码。这将生成必需的 `nutch.jar` 文件。 2. **java.lang.RuntimeException: org.apache.nutch.plugin....

    网络爬虫教程

    ### 知识点详解:Nutch教程——网络爬虫实现 #### 一、Nutch简介与准备工作 **Nutch** 是一个高度可扩展且开放源代码的网络爬虫项目,它可以抓取整个互联网上的网页,并对其进行索引。Nutch基于Hadoop构建,非常...

    Eclipse中编译运行Hadoop-0.20.1源码

    在Linux系统中,你需要安装Eclipse IDE,并且确保它配置了Java Development Kit (JDK)版本1.6或更高。你可以通过`java -version`命令检查你的系统中已安装的JDK版本。如果版本过低,需要更新或安装相应版本。 其次...

    软件工程第三章实验报告.docx

    软件工程第三章实验报告.docx

    第三章-第八节通信礼仪.ppt

    第三章-第八节通信礼仪.ppt

    智能家居股份合作协议.docx

    智能家居股份合作协议.docx

    西门子S7-1200 PLC双轴定位控制在电池焊接中的应用与优化

    内容概要:本文详细介绍了基于西门子S7-1200 PLC的双轴定位控制系统在电池焊接项目中的应用。主要内容涵盖双轴定位算法的设计与实现,包括使用SCL语言编写的运动控制函数块,以及梯形图用于处理IO互锁和焊接时序控制。文中还讨论了威纶通触摸屏的界面设计,如动态元素映射、宏指令的应用,以及电气图纸的安全回路设计。此外,文章分享了多个调试技巧和注意事项,如加速度参数设置、伺服驱动器订货号核对、BOM清单管理等。 适合人群:从事工业自动化领域的工程师和技术人员,尤其是熟悉PLC编程和触摸屏界面设计的专业人士。 使用场景及目标:适用于需要深入了解PLC编程、运动控制算法、触摸屏界面设计及电气图纸绘制的工程项目。目标是提高双轴定位控制系统的精度和稳定性,确保电池焊接的质量和安全性。 其他说明:文中提供了完整的工程文件包下载链接,并强调了在实际应用中需要注意的具体事项,如硬件配置检查、参数调整等。

    Simulink与Carsim联合仿真:基于PID与MPC的自适应巡航控制系统设计与实现

    内容概要:本文详细介绍了如何利用Simulink和Carsim进行联合仿真,实现基于PID(比例-积分-微分)和MPC(模型预测控制)的自适应巡航控制系统。首先阐述了Carsim参数设置的关键步骤,特别是cpar文件的配置,包括车辆基本参数、悬架系统参数和转向系统参数的设定。接着展示了Matlab S函数的编写方法,分别针对PID控制和MPC控制提供了详细的代码示例。随后讨论了Simulink中车辆动力学模型的搭建,强调了模块间的正确连接和参数设置的重要性。最后探讨了远程指导的方式,帮助解决仿真过程中可能出现的问题。 适合人群:从事汽车自动驾驶领域的研究人员和技术人员,尤其是对Simulink和Carsim有一定了解并希望深入学习联合仿真的从业者。 使用场景及目标:适用于需要验证和优化自适应巡航控制、定速巡航及紧急避撞等功能的研究和开发项目。目标是提高车辆行驶的安全性和舒适性,确保控制算法的有效性和可靠性。 其他说明:文中不仅提供了理论知识,还有大量实用的代码示例和避坑指南,有助于读者快速上手并应用于实际工作中。此外,还提到了远程调试技巧,进一步提升了仿真的成功率。

    基于MATLAB/Simulink的变压器励磁涌流仿真模型构建与应用

    内容概要:本文深入探讨了利用MATLAB/Simulink搭建变压器励磁涌流仿真模型的方法和技术。首先介绍了空载合闸励磁涌流仿真模型的搭建步骤,包括选择和配置电源模块、变压器模块以及设置相关参数。文中详细讲解了如何通过代码生成交流电压信号和设置变压器的变比,同时强调了铁芯饱和特性和合闸角控制的重要性。此外,还讨论了电源简化模型的应用及其优势,如使用受控电压源替代复杂电源模块。为了更好地理解和分析仿真结果,文章提供了绘制励磁涌流曲线的具体方法,并展示了如何提取和分析涌流特征量,如谐波含量和谐波畸变率。最后,文章指出通过调整电源和变压器参数,可以实现针对不同应用场景的定制化仿真,从而为实际工程应用提供理论支持和技术指导。 适合人群:从事电力系统研究、变压器设计及相关领域的科研人员、工程师和技术爱好者。 使用场景及目标:适用于希望深入了解变压器励磁涌流特性的研究人员,旨在帮助他们掌握MATLAB/Simulink仿真工具的使用技巧,提高对励磁涌流现象的理解和预测能力,进而优化继电保护系统的设计。 其他说明:文中不仅提供了详细的建模步骤和代码示例,还分享了一些实用的经验和技巧,如考虑磁滞效应对涌流的影响、避免理想断路器带来的误差等。这些内容有助于读者在实践中获得更加准确可靠的仿真结果。

    三菱FX3U PLC与Factory IO通讯仿真PID液位调节程序:低成本高效学习PID控制

    内容概要:本文详细介绍了利用三菱FX3U PLC与Factory IO通讯仿真进行PID液位调节的方法,旨在降低学习PID控制的成本和难度。文中首先指出了传统硬件学习PID控制面临的高昂成本和复杂接线问题,随后介绍了仿真程序的优势,包括PID配置参数、调节参数、自整定和手动整定的学习方法。接着阐述了所需的设备和软件环境,以及具体的代码示例和寄存器配置。最后,通过实例展示了如何通过仿真环境进行PID参数调整和测试,验证了该方案的有效性和实用性。 适合人群:初学者和有一定PLC基础的技术人员,特别是那些希望通过低成本方式学习PID控制的人群。 使用场景及目标:适用于希望在不购买昂贵硬件的情况下,快速掌握PID控制原理和技术的应用场景。目标是通过仿真环境,熟悉PID参数配置和调整,最终能够应用于实际工业控制系统中。 其他说明:本文不仅提供了理论指导,还给出了详细的实践步骤和代码示例,使读者能够在实践中更好地理解和掌握PID控制技术。同时,强调了仿真环境与实际项目的相似性,便于知识迁移。

    智慧城市树木二维码智能管理系统概述.docx

    智慧城市树木二维码智能管理系统概述.docx

    .NET框架下基于Oracle数据库的大型MES生产制造管理系统源码解析与应用

    内容概要:本文详细介绍了基于.NET框架和Oracle数据库构建的大型MES(制造执行系统)生产制造管理系统的源码结构及其技术特点。该系统采用了BS架构,适用于Web端和WPF客户端,涵盖了从数据库设计、业务逻辑处理到前端展示等多个方面。文中不仅提供了具体的代码示例,还深入剖析了系统的技术难点,如Oracle数据库的高效连接方式、多线程处理、实时数据推送以及高级特性(如分区表、压缩技术和批量操作)的应用。此外,作者还分享了一些关于系统部署和维护的经验。 适合人群:主要面向拥有五年以上.NET开发经验的专业人士,特别是那些对Oracle数据库有一定了解并且参与过大中型项目开发的技术人员。 使用场景及目标:①帮助开发者深入了解MES系统的工作原理和技术实现;②为现有的MES系统提供优化思路;③作为学习资料,用于掌握.NET框架与Oracle数据库的最佳实践。 其他说明:尽管缺少完整的安装说明和数据库备份文件,但凭借丰富的代码片段和技术细节,这套源码仍然是一个宝贵的学习资源。同时,文中提到的一些技术点也可以应用于其他类型的工业控制系统或企业管理信息系统。

    lesson6_点阵.zip

    lesson6_点阵.zip

    jicmp(OpenNMS所需重要组件)

    ‌OpenNMS 依赖组件 jicmp 的完整解析与安装指南‌ ‌一、jicmp 的核心作用‌ ‌ICMP 协议支持‌ jicmp(Java Interface for ICMP)是 OpenNMS 实现网络设备可达性检测(如 Ping)的关键组件,通过原生代码高效处理 ICMP 报文,替代纯 Java 实现的性能瓶颈17。 ‌依赖版本要求‌:OpenNMS 33.1.5 需 jicmp >= 3.0.0,以支持 IPv6 及多线程优化7。 ‌与 jicmp6 的协同‌ jicmp6 是 jicmp 的扩展组件,专用于 IPv6 网络环境检测,二者共同构成 OpenNMS 网络监控的底层通信基础78。 ‌二、jicmp 安装问题的根源‌ ‌仓库版本不匹配‌ OpenNMS 官方旧版仓库(如 opennms-repo-stable-rhel6)仅提供 jicmp-2.0.5 及更早版本,无法满足新版 OpenNMS 的依赖需求78。 ‌典型错误‌:Available: jicmp-2.0.5-1.el6.i386,但 Requires: jicmp >= 3.0.07。 ‌手动编译未注册到包管理器‌ 手动编译的 jicmp 未生成 RPM 包,导致 yum 无法识别已安装的依赖,仍尝试从仓库拉取旧版本57。 ‌三、解决方案:正确安装 jicmp 3.0‌ ‌通过源码编译生成 RPM 包‌ bash Copy Code # 安装编译工具链 yum install -y rpm-build checkinstall gcc-c++ autoconf automake libtool # 编译并生成 jicmp-3.0.0 RPM wget https://sourceforge.net/projects/opennms/files/JICMP/stable-3.x/j

    机械CAD零件图.ppt

    机械CAD零件图.ppt

    制冷站智能群控管理系统的技术实现与优化

    内容概要:本文详细介绍了制冷站智能群控管理系统的构成及其核心技术实现。首先阐述了系统的四大组成部分:环境感知模块、数据处理模块、决策控制模块以及设备控制模块。接着通过具体的Python代码示例展示了如何利用MQTT协议进行设备间的通信,实现了温度控制等功能。此外,文中还探讨了数据处理中的噪声过滤方法、设备控制中的状态锁定机制、以及采用强化学习进行能效优化的具体案例。最后展望了未来的发展方向,如引入能量管理和AI集成等。 适合人群:从事制冷站自动化控制领域的工程师和技术人员,尤其是对智能群控管理系统感兴趣的从业者。 使用场景及目标:适用于希望提升制冷站自动化水平的企业和个人。目标在于提高系统的稳定性和效率,减少人为干预,实现节能减排。 其他说明:文章不仅提供了理论性的介绍,还有大量的实战经验和代码片段分享,有助于读者更好地理解和应用相关技术。

    CNN卷积神经网络FPGA加速器实现:从软件到硬件的深度学习部署

    内容概要:本文详细介绍了将卷积神经网络(CNN)从软件到硬件的全过程部署,特别是在FPGA上的实现方法。首先,作者使用TensorFlow 2构建了一个简单的CNN模型,并通过Python代码实现了模型的训练和权值导出。接着,作者用Verilog手写了CNN加速器的硬件代码,展示了如何通过参数化配置优化加速效果。硬件部分采用了滑动窗口和流水线结构,确保高效执行卷积操作。此外,文中还讨论了硬件调试过程中遇到的问题及其解决方案,如ReLU激活函数的零值处理和权值存储顺序的对齐问题。最后,作者强调了参数化设计的重要性,使得硬件可以在速度和面积之间灵活调整。 适合人群:对深度学习和FPGA感兴趣的开发者,尤其是有一定编程基础和技术背景的研究人员。 使用场景及目标:适用于希望深入了解CNN算法硬件实现的人群,目标是掌握从软件到硬件的完整部署流程,以及如何通过FPGA加速深度学习任务。 其他说明:文中提供了详细的代码片段和调试经验,有助于读者更好地理解和实践。同时,项目代码可在GitHub上获取,方便进一步研究和改进。

    无人驾驶车辆高速MPC控制:基于MATLAB与CarSim的双移线场景复现

    内容概要:本文详细介绍了无人驾驶车辆高速MPC(模型预测控制)控制系统的复现过程,主要涉及MATLAB和CarSim软件工具的应用。作者通过调整caraim文件、构建Simulink控制逻辑以及优化MPC算法,将原有的直线跟车场景成功转换为双移线场景。文中不仅展示了具体的技术实现步骤,如路径点设置、权重矩阵调整、采样时间对齐等,还分享了调试过程中遇到的问题及其解决方案,如参数不匹配、模型不收敛等。最终实现了车辆在虚拟环境中按预定双移线轨迹行驶的目标。 适合人群:从事无人驾驶车辆研究和技术开发的专业人士,尤其是对MPC控制算法感兴趣的工程师。 使用场景及目标:适用于需要深入了解无人驾驶车辆控制系统的设计与实现的研究人员和技术开发者。目标是帮助读者掌握如何利用MATLAB和CarSim进行无人驾驶车辆的模拟实验,特别是在高速场景下的双移线控制。 其他说明:文章强调了MPC在高速场景下的挑战性和调参技巧,提供了宝贵的实践经验。同时提醒读者注意环境配置、控制器核心代码解析以及联合仿真可能出现的问题。

    监控场景下基于CLIP的细粒度目标检测方法.pdf

    监控场景下基于CLIP的细粒度目标检测方法.pdf

    MATLAB频谱与功率谱分析:从理论到实践的全面解析

    内容概要:本文详细介绍了如何使用MATLAB进行频谱和功率谱分析,涵盖了从基础概念到高级应用的各个方面。首先,通过生成人工信号并绘制时域图,帮助读者熟悉基本操作。接着,深入探讨了频谱分析的关键步骤,如快速傅里叶变换(FFT)、窗口函数的选择、频谱横坐标的正确转换等。对于功率谱分析,则介绍了Welch法及其具体实现。针对真实数据处理,讨论了如何读取外部数据、处理非均匀采样、去除趋势项等问题,并提供了多种实用技巧,如滑动平均、自动标注主要频率成分等。此外,还强调了一些常见的错误和注意事项,确保读者能够避免常见陷阱。 适用人群:适用于具有一定MATLAB基础的科研人员、工程师和技术爱好者,特别是那些从事信号处理、通信工程、机械振动分析等领域的人士。 使用场景及目标:① 学习如何使用MATLAB进行频谱和功率谱分析;② 掌握处理实际工程中复杂信号的方法;③ 提高对信号特征的理解能力,以便更好地应用于故障诊断、质量检测等实际工作中。 其他说明:文中提供的代码片段可以直接用于实践,读者可以根据自己的需求进行适当修改。通过跟随文中的步骤,读者不仅能够学会如何绘制频谱图和功率谱图,还能深入了解背后的数学原理和技术细节。 标签1,MATLAB,频谱分析,功率谱,Welch法,FFT

Global site tag (gtag.js) - Google Analytics