HBase1.0.2版基本命令
博客专区 > douyur 的博客 > 博客详情
HBase1.0.2版基本命令
douyur 发表于6个月前
HBase1.0.2版基本命令
  • 发表于 6个月前
  • 阅读 6
  • 收藏 0
  • 点赞 0
  • 评论 0

标题:腾讯云 新注册用户域名抢购1元起>>>   

进入HBase Shell Console

[hadoop@HM ~]$ /home/hadoop/hbase-1.0.2/bin/hbase shell
HBase Shell; enter 'help<RETURN>' for list of supported commands.
Type "exit<RETURN>" to leave the HBase Shell
Version 1.0.2, r76745a2cbffe08b812be16e0e19e637a23a923c5, Tue Aug 25 15:59:49 PDT 2015

hbase(main):001:0> 

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

hbase(main):001:0> whoami
hadoop (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 seconds

hbase(main):037:0> put 'ak47','k1','cf1:a2','Buddy'
0 row(s) in 0.0050 seconds

hbase(main):038:0> put 'ak47','k1','cf1:a3','Beatty'
0 row(s) in 0.0060 seconds

hbase(main):039:0> put 'ak47','k1','cf2:a1','Edie'
0 row(s) in 0.0060 seconds

hbase(main):040:0> put 'ak47','k1','cf2:a2','Guido'
0 row(s) in 0.0060 seconds

hbase(main):041:0> put 'ak47','k1','cf2:a3','Gordon'
0 row(s) in 0.0050 seconds

hbase(main):042:0> put 'ak47','k2','cf1:a1','Anton'
0 row(s) in 0.0060 seconds

hbase(main):043:0> put 'ak47','k2','cf1:a2','Dante'
0 row(s) in 0.0060 seconds

hbase(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}
标签: HBase
共有 人打赏支持
粉丝 5
博文 62
码字总数 26478
×
douyur
如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
* 金额(元)
¥1 ¥5 ¥10 ¥20 其他金额
打赏人
留言
* 支付类型
微信扫码支付
打赏金额:
已支付成功
打赏金额: