溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

《Hadoop The Definitive Guide》ch12 HBase

發(fā)布時(shí)間:2020-07-19 15:39:39 來(lái)源:網(wǎng)絡(luò) 閱讀:467 作者:a7272706 欄目:關(guān)系型數(shù)據(jù)庫(kù)


1. 關(guān)于HBase的介紹,http://www.searchtb.com/2011/01/understanding-hbase.html很不錯(cuò)。

HBase – Hadoop Database,是一個(gè)高可靠性、高性能、面向列、可伸縮的分布式存儲(chǔ)系統(tǒng),利用HBase技術(shù)可在廉價(jià)PC Server上搭建起大規(guī)模結(jié)構(gòu)化存儲(chǔ)集群。

HBase是Google Bigtable的開(kāi)源實(shí)現(xiàn),類(lèi)似Google Bigtable利用GFS作為其文件存儲(chǔ)系統(tǒng),HBase利用Hadoop HDFS作為其文件存儲(chǔ)系統(tǒng);Google運(yùn)行MapReduce來(lái)處理Bigtable中的海量數(shù)據(jù),HBase同樣利用Hadoop MapReduce來(lái)處理HBase中的海量數(shù)據(jù);Google Bigtable利用 Chubby作為協(xié)同服務(wù),HBase利用Zookeeper作為對(duì)應(yīng)。

(HBase感覺(jué)更像是一個(gè)上學(xué)時(shí)學(xué)的分布式數(shù)據(jù)庫(kù))

2. HBase安裝的版本要和Hadoop的版本對(duì)應(yīng)起來(lái),剛開(kāi)始下了最新的hbase-0.94.0,但是Hadoop的版本是hadoop-0.20.203.0,在啟動(dòng)HBase的時(shí)候,總是有問(wèn)題。重新下載了hbase-0.90.6之后,一次就啟動(dòng)成功了。


Html代碼 《Hadoop The Definitive Guide》ch12 HBase《Hadoop The Definitive Guide》ch12 HBase《Hadoop The Definitive Guide》ch12 HBase
  1. [ate: /local/nomad2 ]

  2. >> /local/nomad2/hbase/hbase-0.94.0/bin/start-hbase.sh

  3. starting master, logging to /local/nomad2/hbase/hbase-0.94.0/bin/../logs/hbase-nomad2-master-ate.out

  4. SLF4J: Class path contains multiple SLF4J bindings.

  5. SLF4J: Found binding in [jar:file:/local/nomad2/hbase/hbase-0.94.0/lib/slf4j-log4j12-1.5.8.jar!/org/slf4j/impl/StaticLoggerBinder.class]

  6. SLF4J: Found binding in [jar:file:/local/nomad2/hadoop/hadoop-0.20.203.0/lib/slf4j-log4j12-1.4.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]

  7. SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.

[ate: /local/nomad2 ]
>> /local/nomad2/hbase/hbase-0.94.0/bin/start-hbase.sh 
starting master, logging to /local/nomad2/hbase/hbase-0.94.0/bin/../logs/hbase-nomad2-master-ate.out
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/local/nomad2/hbase/hbase-0.94.0/lib/slf4j-log4j12-1.5.8.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/local/nomad2/hadoop/hadoop-0.20.203.0/lib/slf4j-log4j12-1.4.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.

解決辦法,去掉hbase下面的lib。



Html代碼 《Hadoop The Definitive Guide》ch12 HBase《Hadoop The Definitive Guide》ch12 HBase《Hadoop The Definitive Guide》ch12 HBase
  1. >> hbase classpath | tr ":" "\n" | grep -i slf4j

>> hbase classpath | tr ":" "\n" | grep -i slf4j


3. 設(shè)置環(huán)境變量


Html代碼 《Hadoop The Definitive Guide》ch12 HBase《Hadoop The Definitive Guide》ch12 HBase《Hadoop The Definitive Guide》ch12 HBase
  1. export HBASE_INSTALL=/local/nomad2/hbase/hbase-0.90.6

  2. export PATH=$PATH:$HBASE_INSTALL/bin

export HBASE_INSTALL=/local/nomad2/hbase/hbase-0.90.6
export PATH=$PATH:$HBASE_INSTALL/bin

4. 啟動(dòng)HBase



Html代碼 《Hadoop The Definitive Guide》ch12 HBase《Hadoop The Definitive Guide》ch12 HBase《Hadoop The Definitive Guide》ch12 HBase
  1. [ate: /local/nomad2/hbase/hbase-0.90.6/bin ]

  2. >> start-hbase.sh

  3. starting master, logging to /local/nomad2/hbase/hbase-0.90.6/bin/../logs/hbase-nomad2-master-ate.out

  4. [ate: /local/nomad2/hbase/hbase-0.90.6/bin ]

  5. >> hbase shell

  6. HBase Shell; enter 'help<RETURN>' for list of supported commands.

  7. Type "exit<RETURN>" to leave the HBase Shell

  8. Version 0.90.6, r1295128, Wed Feb 29 14:29:21 UTC 2012


  9. hbase(main):001:0> create 'test', 'data'

  10. 0 row(s) in 1.4430 seconds


  11. hbase(main):002:0> list

  12. TABLE

  13. test

  14. 1 row(s) in 0.0420 seconds



  15. hbase(main):003:0> put 'test', 'row1', 'data:1', 'value1'

  16. 0 row(s) in 0.1500 seconds


  17. hbase(main):005:0> put 'test', 'row2', 'data:2', 'value2'

  18. 0 row(s) in 0.0230 seconds


  19. hbase(main):006:0> put 'test', 'row3', 'data:3', 'value3'

  20. 0 row(s) in 0.0220 seconds


  21. hbase(main):007:0> scan 'test'

  22. ROW COLUMN+CELL

  23. row1 column=data:1, timestamp=1341662081734, value=value1

  24. row2 column=data:2, timestamp=1341662107606, value=value2

  25. row3 column=data:3, timestamp=1341662122336, value=value3

  26. 3 row(s) in 0.0640 seconds


  27. hbase(main):008:0> disable 'test'

  28. 0 row(s) in 2.0590 seconds


  29. hbase(main):011:0> drop 'test'

  30. 0 row(s) in 1.1650 seconds


  31. hbase(main):012:0> list

  32. TABLE

  33. 0 row(s) in 0.0190 seconds

[ate: /local/nomad2/hbase/hbase-0.90.6/bin ]
>> start-hbase.sh 
starting master, logging to /local/nomad2/hbase/hbase-0.90.6/bin/../logs/hbase-nomad2-master-ate.out
[ate: /local/nomad2/hbase/hbase-0.90.6/bin ]
>> hbase shell
HBase Shell; enter 'help<RETURN>' for list of supported commands.
Type "exit<RETURN>" to leave the HBase Shell
Version 0.90.6, r1295128, Wed Feb 29 14:29:21 UTC 2012

hbase(main):001:0> create 'test', 'data'
0 row(s) in 1.4430 seconds

hbase(main):002:0> list
TABLE                                                                                                             
test                                                                                                              
1 row(s) in 0.0420 seconds


hbase(main):003:0> put 'test', 'row1', 'data:1', 'value1'
0 row(s) in 0.1500 seconds

hbase(main):005:0> put 'test', 'row2', 'data:2', 'value2'
0 row(s) in 0.0230 seconds

hbase(main):006:0> put 'test', 'row3', 'data:3', 'value3'
0 row(s) in 0.0220 seconds

hbase(main):007:0> scan 'test'
ROW                          COLUMN+CELL                                                                       
 row1                        column=data:1, timestamp=1341662081734, value=value1                              
 row2                        column=data:2, timestamp=1341662107606, value=value2                              
 row3                        column=data:3, timestamp=1341662122336, value=value3                              
3 row(s) in 0.0640 seconds

hbase(main):008:0> disable 'test'
0 row(s) in 2.0590 seconds

hbase(main):011:0> drop 'test'
0 row(s) in 1.1650 seconds

hbase(main):012:0> list
TABLE                                                                                                          
0 row(s) in 0.0190 seconds

5. 導(dǎo)入數(shù)據(jù)(書(shū)上的例子)



Html代碼 《Hadoop The Definitive Guide》ch12 HBase《Hadoop The Definitive Guide》ch12 HBase《Hadoop The Definitive Guide》ch12 HBase
  1. hbase(main):013:0> create 'stations', {NAME => 'info', VERSIONS => 1}

  2. 0 row(s) in 1.1100 seconds


  3. hbase(main):014:0> create 'observations', {NAME => 'data', VERSIONS => 1}

  4. 0 row(s) in 1.1060 seconds


  5. hbase(main):015:0> list

  6. TABLE

  7. observations

  8. stations

  9. 2 row(s) in 0.0210 seconds

hbase(main):013:0> create 'stations', {NAME => 'info', VERSIONS => 1}
0 row(s) in 1.1100 seconds

hbase(main):014:0> create 'observations', {NAME => 'data', VERSIONS => 1}
0 row(s) in 1.1060 seconds

hbase(main):015:0> list
TABLE                                                                                                          
observations                                                                                                   
stations                                                                                                       
2 row(s) in 0.0210 seconds



Html代碼 《Hadoop The Definitive Guide》ch12 HBase《Hadoop The Definitive Guide》ch12 HBase《Hadoop The Definitive Guide》ch12 HBase
  1. >> export HBASE_CLASSPATH=$HBASE_CLASSPATH:ch23.jar

  2. >> hbase HBaseTemperatureImporter input/ncdc/all

>> export HBASE_CLASSPATH=$HBASE_CLASSPATH:ch23.jar
>> hbase HBaseTemperatureImporter input/ncdc/all  

導(dǎo)入完成后,從http://ate:60010查看數(shù)據(jù)表。


向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI