Skip to content

Instantly share code, notes, and snippets.

@rahulkumar-aws
Created December 5, 2018 06:58
Show Gist options
  • Save rahulkumar-aws/8434279b63714574a7eb2a536893ad24 to your computer and use it in GitHub Desktop.
Save rahulkumar-aws/8434279b63714574a7eb2a536893ad24 to your computer and use it in GitHub Desktop.
$ wget http://www-eu.apache.org/dist/nutch/2.3.1/apache-nutch-2.3.1-src.tar.gz
$ tar xvfz apache-nutch-2.3.1-src.tar.gz
$ cd apache-nutch-2.3.1/conf

$NUTCH_HOME/conf/nutch-site.xml

<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!--
 Licensed to the Apache Software Foundation (ASF) under one or more
 contributor license agreements.  See the NOTICE file distributed with
 this work for additional information regarding copyright ownership.
 The ASF licenses this file to You under the Apache License, Version 2.0
 (the "License"); you may not use this file except in compliance with
 the License.  You may obtain a copy of the License at
     http://www.apache.org/licenses/LICENSE-2.0
 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
-->

<!-- Put site-specific property overrides in this file. -->

<configuration>
<property>
     <name>http.agent.name</name>
     <value>nutch-2.3.1-crawler</value>
 </property>
 <property>
    <name>storage.data.store.class</name>
    <value>org.apache.gora.mongodb.store.MongoStore</value>
    <description>Default class for storing data</description>
</property>
 <property>
    <name>plugin.includes</name>
    <value>protocol-httpclient|urlfilter-regex|index-(basic|more)|query-(basic|site|url|lang)|indexer-solr|nutch-extensionpoints|protocol-httpclient|urlfilter-regex|parse-(text|html|msexcel|msword|mspowerpoint|pdf)|summary-basic|scoring-opic|urlnormalizer-(pass|regex|basic)protocol-http|urlfilter-regex|parse-(html|tika|metatags)|index-(basic|anchor|more|metadata)</value>
 </property>
<property>
 <name>db.ignore.external.links</name>
 <value>true</value>
</property>
<property>
 <name>db.ignore.external.links.mode</name>
 <value>byDomain</value>
</property>
</configuration>

$NUTCH_HOME/conf/gora.properties

############################
# MongoDBStore properties  #
############################
gora.datastore.default=org.apache.gora.mongodb.store.MongoStore
gora.mongodb.override_hadoop_configuration=false
gora.mongodb.mapping.file=/gora-mongodb-mapping.xml
gora.mongodb.servers=localhost:27017
gora.mongodb.db=nutchdb

$NUTCH_HOME/conf/ivy/ivy.xml

<!-- Uncomment this to use MongoDB as Gora backend. -->
<dependency org="org.apache.gora" name="gora-mongodb" rev="0.6.1" conf="*->default" />

Now we build Nutch. Install ant if it is not installed already.

sudo apt-get install ant

build Nutch from $NUTCH_HOME folder

$ pwd
/home/ubuntu/apache-nutch-2.3.1
$ ant runtime

Crawl and Index

$ cd ~/apache-nutch-2.3.1/
$ mkdir urls
$ vi urls/seeds.text
runtime/local/bin/nutch inject urls/
runtime/local/bin/nutch generate -topN 50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment