wiki:NCHCCloudCourse100929_2_USE

Version 10 (modified by jazz, 14 years ago) (diff)

--

Hbase 使用方法
HBase 0.20 + Hadoop 0.20

列出所有 table

hbase(main):>	list

新增 table

A . 直接增加一個表 t2

hbase(main):>	create 't2'

B . 增加一個擁有 'f1','f2','fn' 為 column family 的表: t1

hbase(main):>	create 't1','f1','f2','fn'   

查詢 Table 欄位

hbase(main):> describe 't1'

執行結果參考

hbase(main):> describe 't1'
DESCRIPTION                                                             ENABLED                               
 {NAME => 't1', FAMILIES => [{NAME => 'f1', COMPRESSION => 'NONE', VERS true                                  
 IONS => '3', TTL => '2147483647', BLOCKSIZE => '65536', IN_MEMORY => '                                       
 false', BLOCKCACHE => 'true'}, {NAME => 'f2', COMPRESSION => 'NONE', V                                       
 ERSIONS => '3', TTL => '2147483647', BLOCKSIZE => '65536', IN_MEMORY =                                       
 > 'false', BLOCKCACHE => 'true'}, {NAME => 'fn', COMPRESSION => 'NONE'                                       
 , VERSIONS => '3', TTL => '2147483647', BLOCKSIZE => '65536', IN_MEMOR                                       
 Y => 'false', BLOCKCACHE => 'true'}]}                                                                        
1 row(s) in 0.0170 seconds

加入cell-value

需先擁有表 t1 與column-family : f1 並且加入一個 column-quantifier c1

hbase(main):>	put 't1', 'r1', 'f1', 'v1'    
hbase(main):>	put 't1', 'r1', 'f1:c1', 'v2'    
Table: 't1'
row-keycolumn-family : 'f1'
column-quantifier: *'c1'
r1v1
r1v2

列出cell-value

A . 列出一列(row)

hbase(main):>	get 't1', 'r1'

執行結果參考

COLUMN                    CELL                                                                           
 f1:c1                 timestamp=1285041409509, value=value

B . 列出一個 cell 的值

hbase(main):005:0>   get 't1', 'r1', {COLUMN => 'f1:c1'}

執行結果參考

COLUMN                       CELL                                                                             
 f1:c1                       timestamp=1285732474078, value=value                                             
1 row(s) in 0.0030 seconds    

刪除 cell-value

hbase(main):>	deleteall 't1','r1'

加入column family

hbase(main):>	disable 't1'
hbase(main):>   alter 't1', {NAME => 'f1'}
hbase(main):>   enable 't1'

刪除column family

hbase(main):>	disable 't1'
hbase(main):>	alter 't1', {NAME => 'f1', METHOD => 'delete'}
hbase(main):>   enable 't1'

節點狀態

hbase(main):>	status

刪除整張table

hbase(main):>	truncate 't1'
hbase(main):>	disable 't1'
hbase(main):>	drop 't1'