Nutch2.3.1 hbase配置加使用。__Nutch2.3.1

來源:互聯網
上載者:User

ivy必須配合ant

安裝ant #yum -y install ant


#mkdir /home/nutch-hbase
#cd /home/nutch-hbase
#tar zxvf apache-nutch-2.3.1-src.tar.gz
#mv apache-nutch-2.3.1-src.tar.gz nutch


(可選)修改預設下載目錄為C:\Users\使用者名稱\.ivy2\catch目錄
修改$NUTCH_HOME/ivy/ivysettings.xml檔案中更換包位置
<ivysettings>
 <caches defaultCacheDir="E:\\work\\maven\\libs"/>


(可選)$NUTCH_HOME/ivy/ivysettings.xml修改為aliyun伺服器位址,加快下載速度
<property name="repo.maven.org"
    value="http://maven.aliyun.com/nexus/content/groups/public/"
  


  override="false"/>


$NUTCH_HOME/ivy/ivy.xml
 <dependency org="org.apache.gora" name="gora-hbase" rev="0.6.1" conf="*->default" />
 <dependency org="org.apache.hbase" name="hbase-common" rev="0.98.8-hadoop2" conf="*->default" 


/>


(必須)安裝Hbase(Hbase0.98.8)
#cd /home
#wget http://archive.apache.org/dist/hbase/hbase-0.98.8/hbase-0.98.8-hadoop2-bin.tar.gz
#tar zxvf hbase-0.98.8-hadoop2-bin.tar.gz
#mv hbase-0.98.8-hadoop2-bin.tar.gz hbase


(必須)配置Hbase環境變數,針對所有使用者
#vi /etc/profile
在最下邊,添加下列內容:
HBASE = /home/hbase-0.98.8-hadoop2/
PATH = $HBASE/bin:$PATH
儲存退出後,立即生效
#source /etc/profile


(可選)輸入命令測試是否安裝成功
#hbase -version


(必須)啟動HBase
#cd $HBASE
#./bin/start-hbase.sh


(可選)停止HBase
#./bin/stop-hbase.sh


(必須)選擇資料庫檔案,添加以下配置
#vi $NUTCH_HOME/conf/gora.properties
gora.datastore.default=org.apache.gora.hbase.store.HBaseStore


(必須)增加內容如下:
$NUTCH_HOME/conf/nutch-site.xml
<configuration>
<property>
    <name>http.agent.name</name>
    <value>mypachong</value>
</property>
<property>
    <name>storage.data.store.class</name>
    <value>org.apache.gora.hbase.store.HBaseStore</value>
    <description>Default class for storing data</description>
</property>
</configuration>


(必須)建立種子檔案列表
#cd $NUTCH_HOME/
#mkdir -p urls
#cd urls
#touch seed.txt
#vi seed.txt
http://mil.news.sina.com.cn


(必須)最後開始編譯
#cd $NUTCH_HOME
#ant clean 
#ant


(必須)編譯完成後,執行抓取
#cd $NUTCH_HOME/
#./$NUTCH_HOME/runtime/local/bin/crawl urls/ mytest 10
另一種執行方式
#./$NUTCH_HOME/runtime/local/bin/nutch crawl urls mytest -depth 3 -topN 5




(必須)抓取完成後進入hbase shell查看資料
#hbase shell
查看列表
>list


查看資料(mytest_webpage)為表名,查詢所有資料
>scan 'mytest_webpage'


擷取一行記錄
>get 'mytest_webpage', 'row1'


退出HBase Shell
>quit


刪除資料庫
>disable 'test'
>drop 'test'

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.