Dear Wiki user, You have subscribed to a wiki page or wiki category on "Nutch Wiki" for change notification.
The "Whole-Web Crawling incremental script" page has been changed by Gabriele Kahlout. The comment on this change is: updated script to hanlde recovery/interrupted crawling. http://wiki.apache.org/nutch/Whole-Web%20Crawling%20incremental%20script?action=diff&rev1=18&rev2=19 -------------------------------------------------- == 3. Unabridged with explanations, using solr and Hadoop fs cmds (advanced) == {{{ - #!/bin/sh + #!/bin/bash # # Created by Gabriele Kahlout on 27.03.11. @@ -248, +248 @@ echo } - it_size=10 + it_size=1 depth=1 fresh=false solrIndex="http://localhost:8080/solr" @@ -291, +291 @@ allUrls=`cat $seedsDir/urls-local-only | wc -l | sed -e "s/^ *//"` echo $allUrls" urls to crawl" - j=0 while [[ $indexedPlus1 -le $allUrls ]] #repeat generate-fetch-updatedb-invertlinks-index-merge loop until all urls are fetched @@ -302, +301 @@ bin/hadoop dfs -moveFromLocal $it_seedsDir/urls-local-only $it_seedsDir/urls it_crawldb="crawl/crawldb/$j" - if [[ -d $it_crawldb ]] # resuming crawl + it_segs="crawl/segments/$j" + + fCrawl=`bin/hadoop dfs -test -d $it_crawldb` + if [[ $fCrawl == "" ]] #doesn't exist --> fresh crawl then - bin/hadoop dfs -rmr crawl/segments #should be empty if we indexed them - atomicity at $j level. - else bin/hadoop dfs -mkdir $it_crawldb echo echoThenRun "bin/nutch inject $it_crawldb $it_seedsDir" @@ -315, +315 @@ while [[ $i -lt $depth ]] # depth-first do echo - echo "generate-fetch-updatedb-invertlinks-index-merge iteration "$i":" + echo "generate-fetch-invertlinks-updatedb-index iteration "$i":" - + bin/hadoop dfs -rmr $it_segs + bin/hadoop dfs -rm $it_crawldb/.locked $it_crawldb/..locked.crc - cmd="bin/nutch generate $it_crawldb crawl/segments -topN $it_size" + cmd="bin/nutch generate $it_crawldb $it_segs -topN $it_size" + echo echo $cmd output=`$cmd` echo $output echo + if [[ $output == *'0 records selected for fetching'* ]] #all the urls of this iteration have been fetched then break; fi - + - echoThenRun "bin/nutch fetch crawl/segments/2*" + echoThenRun "bin/nutch fetch $it_segs/2*" - echoThenRun "bin/nutch updatedb $it_crawldb crawl/segments/2*" + echoThenRun "bin/nutch updatedb $it_crawldb $it_segs/2*" - echoThenRun "bin/nutch invertlinks crawl/linkdb -dir crawl/segments" + echoThenRun "bin/nutch invertlinks crawl/linkdb -dir $it_segs" - echoThenRun "bin/nutch solrindex $solrIndex $it_crawldb crawl/linkdb crawl/segments/*" + echoThenRun "bin/nutch solrindex $solrIndex $it_crawldb crawl/linkdb $it_segs/*" # you can now search the index with http://localhost:8080/solr/admin/ (if setup) or http://code.google.com/p/luke/ . The index is stored in crawl/indexes, while if Solr is used then in $NUTCH_HOME/solr/data/index. - bin/hadoop dfs -rmr crawl/segments/2* + bin/hadoop dfs -rmr $it_segs/2* + echo ((i++)) - ((indexedPlus1+=$it_size)) # maybe should readdb crawl/crawldb -stats number of actually fetched, but (! going to fetch a page) --> infinite loop - echo done - + ((indexedPlus1+=$it_size)) # maybe should readdb crawl/crawldb -stats number of actually fetched, but (! going to fetch a page) --> infinite loop echoThenRun "bin/nutch readdb $it_crawldb -stats" ((j++)) done

