HBase Shell 命令——Quick Start

来源:互联网 发布:孕囊只有两个数据准吗 编辑:程序博客网 时间:2024/06/05 04:06

The Apache HBase Shell is JRuby's IRB with some HBase particular commands added. Anything you can do in IRB, you should be able to do in the HBase Shell.

Apache HBase Shell 命令在Ruby的IRB命令的基础上加入了一些特殊的HBase命令。任何在IRB中使用的命令,你都可以在HBase Shell中使用。

1、在启动HBase之后,通过shell命令连接HBase

bin/hbase shell

hbase(main):001:0>
2、显示HBase 帮助文本

hbase(main):002:0>help

3、创建表,创建表的时候必须写出表名(test)和列族名(cf)

hbase(main):003:0>create 'test','cf'

4、列出HBase中的表

hbase(main):004:0>list 'test'

5、向test表中插入数据,在插入数据时,可以定义行名(row1)列族名下的列名(a),并赋值(value1)

hbase(main):005:0>put 'test','row1','cf:a','value1'

6、扫描全表

hbase(main):006:0>scan 'test'

7、获得单个行的数据

hbase(main):007:0>get 'test','row1'

8、获得某个行键,某个列族中具体列名的信息。

hbase(main):008:0>get 'test','row1','cf:a'

9、在删除表或修改表之前,首先要是表失效。

hbase(main):009:0>disable 'test'
使表有效:

hbase(main):010:0>enable 'test'

10、修改表

1)删除列族(cf)

hbase(main):011:0>alter 'test',NAME=>'cf',METHOD=>'delete'

2)改变或添加一个列族

hbase(main):012:0>alter 'test',NAME=>'cf',VERSIONS=>5

11、删除行列(不需要表离线)

1)删除指定的行健字段

hbase(main):013:0>delete 'test','row1','cf:a'
2)删除整行

hbase(main):014:0>deleteall 'test','row1'

12、删除整表

hbase(main):015:0>drop 'test'

13、查看集群状态status

14、查看版本号version

15、检查表是否存在

hbase(main):016:0>exists 'test'
16、判断表是否离线

hbase(main):017:0>is_enabled 'test'
hbase(main):018:0>is_disabled 'test'

17、统计表的行数

hbase(main):019:0>count 'test'
18、清空表

hbase(main):020:0>trancate 'test'

19、退出shell命令

hbase(main):021:0>quit

参考资料:1、点击打开链接

                    2、 http://itlab.idcquan.com/linux/set/939223_2.html

0 0