wiki:Hbase_Lab2

HBase 操作

0. 啟動HBase並確認所有服務都已啟動

  • 終端機
    ~$ jps
    17101 QuorumPeerMain
    19978 HRegionServer
    19807 HMaster
    14510 NameNode
    15136 TaskTracker
    20311 Jps
    14685 DataNode
    14873 SecondaryNameNode
    14958 JobTracker
    
  • 網頁瀏覽器
    http://localhost:60010
    

1. 進入HBase Shell

shunfa@shunfa-vmmVBox:/opt/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> 
  • 試試help指令
    hbase(main):001:0> help
    

1-1 資料庫操作-列出資料庫 list

hbase(main):002:0> list
TABLE                                                                                                             
0 row(s) in 0.7890 seconds

1-2 資料庫操作-新增資料庫 create

hbase(main):003:0> create 'test', 'data'
0 row(s) in 1.4780 seconds
  • 驗證
    hbase(main):004:0> list
    TABLE                                                                                                             
    test                                                                                                              
    1 row(s) in 0.0130 seconds
    

1-3 資料庫操作-新增紀錄 put

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

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

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

1-4 資料庫操作-列出資料庫內容 scan

hbase(main):009:0> scan 'test'
ROW                           COLUMN+CELL                                                                         
 row1                         column=data:1, timestamp=1355213278489, value=value1                                
 row2                         column=data:2, timestamp=1355213303215, value=value2                                
 row3                         column=data:3, timestamp=1355213310664, value=value3                                
3 row(s) in 0.0580 seconds

1-5 資料庫操作-刪除資料庫 disable and drop

  • disable
    hbase(main):010:0> disable 'test'
    0 row(s) in 2.1270 seconds
    
  • drop
    hbase(main):011:0> drop 'test'
    0 row(s) in 1.3310 seconds
    
  • 確認已刪除"test"
    hbase(main):012:0> list
    TABLE                                                                                                             
    0 row(s) in 0.0110 seconds
    

1-6 離開

hbase(main):013:0> exit
shunfa@shunfa-vmmVBox:/opt/hbase-0.90.6$ 
Last modified 12 years ago Last modified on Dec 11, 2012, 4:11:39 PM