好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

HBase Shell

HBase Shell

1.进入HBase Shell 命令:

$ ${HBASE_HOME}/bin/hbase shell

2.获得命令列表:

hbase> help

3.alter: 

1) 表't1'中,增加或修改一个column family=> 'f1'并保持其最大版本数为5:

hbase> alter 't1', {NAME => 'f1', VERSIONS => 5}

2)删除表't1'中值为'f1'的column family:

hbase> alter 't1', {NAME => 'f1', METHOD => 'delete'}

3)你也可以修改表属性,比如:MAX_FILESIZE,MEMSTORE_FLUSHSIZE和READONLY:

hbase> alter 't1', {METHOD => 'table_att', MAX_FILESIZE => '134217728'}

4.count:

返回表的全部行数,这种操作会花费很长时间(run counting mapreduce job),默认每1000行显示一次,当然这个是可以自己配置的。

hbase> count 't1'
hbase> count 't1', 100000

 

5.create:

hbase> create 't1', {NAME => 'f1', VERSIONS => 5}
hbase> create 't1', {NAME => 'f1'}, {NAME => 'f2'}, {NAME => 'f3'}
hbase> # The above in shorthand would be the following:
hbase> create 't1', 'f1', 'f2', 'f3'
hbase> create 't1', {NAME => 'f1', VERSIONS => 1, TTL => 2592000, \

             BLOCKCACHE => true}

TTL为此column family的生命周期,单位为秒。

6.describe:

获得表的属性。

hbase> describe 't1'

 

7.delete:

删除一个cell,需要用timestamp定位。

hbase> delete 't1', 'r1', 'f1:c1', ts1

 

8.deleteall

根据指定条件批量删除cell。

hbase> deleteall 't1', 'r1'
hbase> deleteall 't1', 'r1', 'f1:c1'
hbase> deleteall 't1', 'r1', 'f1:c1', ts1

 

9.disable

使一个指定表失效。

hbase> exists 't1'

 

10.drop

删除一张表,在删除之前必须先disable此表,如果这个表有多个region,先运行:

hbase> major_compact ".META."

 

11.enable

与disable相对应。

12.exists

判断表是否存在。

hbase> exists 't1'

 

13.exit

离开hbase shell。

14.get

根据指定条件返回查询结果,必须指定row。

hbase> get 't1', 'r1' hbase> get 't1', 'r1', {COLUMN => 'f1:c1'} hbase> get 't1', 'r1', {COLUMN => ['f1:c1', 'f1:c2', 'f1:c3']} hbase> get 't1', 'r1', {COLUMN => 'f1:c1', TIMESTAMP => ts1} hbase> get 't1', 'r1', {COLUMN => 'f1:c1', TIMESTAMP => ts1, \        VERSIONS => 4}

 

15.list

获得hbase中所有表名。

16.put

新增一个cell。

hbase> put 't1', 'r1', 'f1:c1', 'value', ts1

17.tools

获得server端的一些操作命令,如close_regin,flush等,如以后遇到,会另作具体详解。

18.scan

根据指定条件扫描指定表,条件包括LIMIT,STARTROW,STOPROW,TIMESTAMP,COLUMNS。如果在COLUMNS中未指定具体column family则会扫描全部column family。

hbase> scan '.META.' hbase> scan '.META.', {COLUMNS => 'info:regioninfo'} hbase> scan 't1', {COLUMNS => ['c1', 'c2'], LIMIT => 10, \               STARTROW => 'xyz'}

在扫描的时候也可以自动设置缓存的开启和关闭状态,默认为开启。

hbase> scan 't1', {COLUMNS => ['c1', 'c2'], CACHE_BLOCKS => false}

1 9.status

显示hbase中列簇状态,条件可以为:summary,simple,detailed,默认为summary。

hbase> status hbase> status 'simple' hbase> status 'summary'
hbase> status 'detailed'

20.shutdown,truncate,version

 

分类:  HBase

标签:  hbase ,  shell

作者: Leo_wl

    

出处: http://www.cnblogs.com/Leo_wl/

    

本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。

版权信息

查看更多关于HBase Shell的详细内容...

  阅读:62次