HBase Shell常用命令

进入shellhbase shell

1
2
3
4
5
6
7
[hduser@hadoop2 applications]$ hbase shell
2014-05-20 14:48:54,159 INFO [main] Configuration.deprecation: hadoop.native.lib is deprecated. Instead, use io.native.lib.available
HBase Shell; enter 'help<RETURN>' for list of supported commands.
Type "exit<RETURN>" to leave the HBase Shell
Version 0.96.2-hadoop2, r1581096, Mon Mar 24 16:03:18 PDT 2014
hbase(main):001:0>

退出shellexit

1
2
hbase(main):009:0> exit
[hduser@hadoop2 ~]$

列出所有表list

1
2
3
4
5
6
7
8
hbase(main):001:0> list
TABLE
table2
tables
test1
3 row(s) in 4.9810 seconds
=> ["table2", "tables", "test1"]

查看表定义describe

1
2
3
4
5
hbase(main):008:0> describe 'table2'
DESCRIPTION ENABLED
'table2', {NAME => 'col1', DATA_BLOCK_ENCODING => 'NONE', BLOOMFILTER => 'ROW', REPLICATION_SCOPE => '0', VERSION true
S => '1', COMPRESSION => 'NONE', MIN_VERSIONS => '0', TTL => '2147483647', KEEP_DELETED_CELLS => 'false', BLOCKSI
ZE => '65536', IN_MEMORY => 'false', BLOCKCACHE => 'true'}

列出部分行scan

1
2
3
4
5
6
7
8
scan '<tablename>', {LIMIT=> 2}
例子
hbase(main):007:0> scan 'test',{LIMIT=>2}
ROW COLUMN+CELL
row1 column=col1:, timestamp=1400570581885, value=1
row2 column=col1:, timestamp=1400571033424, value=2
2 row(s) in 0.0230 seconds