博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
HBase1.0.2版基本命令
阅读量:6360 次
发布时间:2019-06-23

本文共 7638 字,大约阅读时间需要 25 分钟。

  hot3.png

进入HBase Shell Console

[hadoop@HM ~]$ /home/hadoop/hbase-1.0.2/bin/hbase shellHBase Shell; enter 'help
' for list of supported commands.Type "exit
" to leave the HBase ShellVersion 1.0.2, r76745a2cbffe08b812be16e0e19e637a23a923c5, Tue Aug 25 15:59:49 PDT 2015hbase(main):001:0>

使用whoami命令可查看当前用户:

hbase(main):001:0> whoamihadoop (auth:SIMPLE)    groups: hadoop

查看表

hbase(main):038:0> list

创建表

语法:create <table>, {NAME => <family>},{NAME => <family>}

hbase(main):037:0> create 'ak47',{NAME => 'cf1'},{NAME => 'cf2'}0 row(s) in 0.3910 seconds​=> Hbase::Table - ak47

在HBase-1.0.2版本中创建表时,不需要加版本号。

全表扫描

hbase(main):003:0> scan 'ak47'ROW                                                       COLUMN+CELL 0 row(s) in 0.0420 seconds

查看表结构

hbase(main):004:0> desc 'ak47'Table ak47 is ENABLED                                                                                                                                                                                                           ak47                                                                                                                                                                                                                            COLUMN FAMILIES DESCRIPTION                                                                                                                                                                                                     {NAME => 'cf1', DATA_BLOCK_ENCODING => 'NONE', BLOOMFILTER => 'ROW', REPLICATION_SCOPE => '0', VERSIONS => '1', COMPRESSION => 'NONE', MIN_VERSIONS => '0', TTL => 'FOREVER', KEEP_DELETED_CELLS => 'FALSE', BLOCKSIZE => '65536', IN_MEMORY => 'false', BLOCKCACHE => 'true'}                                                                                                                                                                                  {NAME => 'cf2', DATA_BLOCK_ENCODING => 'NONE', BLOOMFILTER => 'ROW', REPLICATION_SCOPE => '0', VERSIONS => '1', COMPRESSION => 'NONE', MIN_VERSIONS => '0', TTL => 'FOREVER', KEEP_DELETED_CELLS => 'FALSE', BLOCKSIZE => '65536', IN_MEMORY => 'false', BLOCKCACHE => 'true'}                                                                                                                                                                                  2 row(s) in 0.0990 seconds

添加数据

hbase(main):036:0> put 'ak47','k1','cf1:a1','Codi'0 row(s) in 0.0140 secondshbase(main):037:0> put 'ak47','k1','cf1:a2','Buddy'0 row(s) in 0.0050 secondshbase(main):038:0> put 'ak47','k1','cf1:a3','Beatty'0 row(s) in 0.0060 secondshbase(main):039:0> put 'ak47','k1','cf2:a1','Edie'0 row(s) in 0.0060 secondshbase(main):040:0> put 'ak47','k1','cf2:a2','Guido'0 row(s) in 0.0060 secondshbase(main):041:0> put 'ak47','k1','cf2:a3','Gordon'0 row(s) in 0.0050 secondshbase(main):042:0> put 'ak47','k2','cf1:a1','Anton'0 row(s) in 0.0060 secondshbase(main):043:0> put 'ak47','k2','cf1:a2','Dante'0 row(s) in 0.0060 secondshbase(main):044:0> put 'ak47','k2','cf1:a3','David'0 row(s) in 0.0110 seconds
hbase(main):045:0> scan 'ak47'ROW                                                       COLUMN+CELL                                                                                                                                                            k1                                                       column=cf1:a1, timestamp=1450078255865, value=Codi                                                                                                                     k1                                                       column=cf1:a2, timestamp=1450078255897, value=Buddy                                                                                                                    k1                                                       column=cf1:a3, timestamp=1450078255919, value=Beatty                                                                                                                   k1                                                       column=cf2:a1, timestamp=1450078255943, value=Edie                                                                                                                     k1                                                       column=cf2:a2, timestamp=1450078255965, value=Guido                                                                                                                    k1                                                       column=cf2:a3, timestamp=1450078255987, value=Gordon                                                                                                                   k2                                                       column=cf1:a1, timestamp=1450078256009, value=Anton                                                                                                                    k2                                                       column=cf1:a2, timestamp=1450078256032, value=Dante                                                                                                                    k2                                                       column=cf1:a3, timestamp=1450078257178, value=David                                                                                                                   2 row(s) in 0.0320 seconds

删除一行数据

hbase(main):033:0> delete 'ak47','k2','cf1:a3'0 row(s) in 0.0260 seconds
hbase(main):051:0> scan 'ak47'ROW                                                       COLUMN+CELL                                                                                                                                                            k1                                                       column=cf1:a1, timestamp=1450078255865, value=Codi                                                                                                                     k1                                                       column=cf1:a2, timestamp=1450078255897, value=Buddy                                                                                                                    k1                                                       column=cf1:a3, timestamp=1450078255919, value=Beatty                                                                                                                   k1                                                       column=cf2:a1, timestamp=1450078255943, value=Edie                                                                                                                     k1                                                       column=cf2:a2, timestamp=1450078255965, value=Guido                                                                                                                    k1                                                       column=cf2:a3, timestamp=1450078255987, value=Gordon                                                                                                                   k2                                                       column=cf1:a1, timestamp=1450078256009, value=Anton                                                                                                                    k2                                                       column=cf1:a2, timestamp=1450078256032, value=Dante                                                                                                                   2 row(s) in 0.0260 seconds

查看所有数据,包括历史和最新的数据

scan 'ak47',{RAW => true, VERSION => 10}

转载于:https://my.oschina.net/siiiso/blog/1475674

你可能感兴趣的文章