Version 12 (modified by jazz, 15 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' hbase(main):> put 't1', 'r2', 'f2', 'v3' hbase(main):> put 't1', 'r2', 'f2:c2', 'v4'
Table: 't1' | |||||
row-key | column-family | 'f1' | 'f1' | ||
column-quantifier | * | 'c1' | * | 'c2' | |
r1 | v1 | ||||
v2 | |||||
r2 | v3 | ||||
v4 |
列出cell-value
A . 列出一列(row)
hbase(main):> get 't1', 'r1'
執行結果參考
COLUMN CELL f1: timestamp=1285737082689, value=v1 f1:c1 timestamp=1285737085874, value=v2
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'