[[PageOutline]] = Nutch 安裝測試 = == 前言 == * 之前有安裝過nutch (version 0.9)並成功運作於四台主機上。由於想到之後上課可能有需要,再重新操作一次 * 網址 : [wiki:nutch] * 這次的測試與之前的測試不同點在於: 1. 版本是新的(nutch 1.0) 2. 之前是空的環境下直接安裝nutch,也沒有hadoop的基礎來安裝,因此目錄結構都用nutch官網介紹的;然而這次的安裝測試在於把nutch運行在已經有的hadoop之上。不過測試的結果是失敗了,錯誤訊息在於找不到dfs之類的訊息。 * 於是又再退回最原始的方法,用空的環境架nutch,並且所有的安裝都用最簡單的設定,步驟如下: == step 1 登入免密碼 == * 這是最基本的,怎麼做就不贅述。 == step 2 下載與安裝 == * 下載 java 1.6 {{{ $ sudo apt-get install sun-java6-bin }}} * 下載 nutch 1.0 (2009/03/28) {{{ $ wget http://ftp.twaren.net/Unix/Web/apache/lucene/nutch/nutch-1.0.tar.gz }}} == step 3 編輯設定檔 == * 所有的設定檔都在 $NUTCH_HOME/conf 下 === 3.1 hadoop-env.sh === 將原本的檔案hadoop-env.sh任意處插入 {{{ #!sh export JAVA_HOME=/usr/lib/jvm/java-6-sun export HADOOP_HOME=/opt/nutch export HADOOP_LOG_DIR=/tmp/nutch/logs export HADOOP_SLAVES=/opt/nutch/conf/slaves }}} === 3.2 hadoop-site.xml === {{{ #!sh fs.default.name gm1.nchc.org.tw:9000 The name of the default file system. Either the literal string "local" or a host:port for NDFS. mapred.job.tracker gm1.nchc.org.tw:9001 The host and port that the MapReduce job tracker runs at. If "local", then jobs are run in-process as a single map and reduce task. }}} === 3.3 nutch-site.xml === {{{ #!sh http.agent.name waue HTTP 'User-Agent' request header. http.agent.description MyTest Further description http.agent.url gm1.nchc.org.tw A URL to advertise in the User-Agent header. http.agent.email waue@nchc.org.tw An email address }}} === 3.4 slaves === 其實不用改,因為原本就是localhost {{{ #!sh localhost }}} === 3.5 crawl-urlfilter.txt === 將此檔的兩行改為下面內容 {{{ #!sh # skip URLs containing certain characters as probable queries, etc. -[*!@] # accept hosts in MY.DOMAIN.NAME +^http://([a-z0-9]*\.)*.*/ }}} == step 4 執行 == === 4.1 編輯url清單 === {{{ $ mkdir urls $ vim urls.txt }}} {{{ #!sh http://lucene.apache.org }}} === 4.2 開啟HDFS === {{{ $ bin/hadoop namenode -format $ bin/start-all.sh }}} === 4.3 上傳清單到HDFS === {{{ $ bin/hadoop -put urls urls }}} === 4.4 執行nutch crawl === {{{ $ bin/nutch crawl urls -dir crawl01 -depth 3 }}} == step 5 web瀏覽 == === 5.1 安裝tomcat === * 下載 {{{ $ cd /opt/ $ wget http://ftp.twaren.net/Unix/Web/apache/tomcat/tomcat-6/v6.0.18/bin/apache-tomcat-6.0.18.tar.gz }}} * 解壓縮 {{{ $ tar -xzvf apache-tomcat-6.0.18.tar.gz $ mv apache-tomcat-6.0.18 tomcat }}} === 5.2 將crawl結果匯入tomcat === {{{ $ cd /opt/nutch $ mkdir web $ cd web $ jar -xvf nutch-1.0.war $ rm nutch-1.0.war $ mv /opt/tomcat/webapps/ROOT /opt/tomcat/webapps/ROOT-ori $ cd /opt/nutch $ mv /opt/nutch/web /opt/tomcat/webapps/ROOT $ vim /opt/tomcat/webapps/ROOT/WEB-INF/classes/nutch-site.xml }}} {{{ #!sh searcher.dir /opt/search }}} 並且修改 /opt/tomcat/conf/server.xml 以修正中文問題 {{{ #!sh }}} === 5.3 瀏覽crawl結果 === {{{ $ /opt/tomcat/bin/startup.sh }}} [http://gm1.nchc.org.tw:8080]