Hbase shell 常用命令1

  • 时间:
  • 浏览:0

获取当前count的值

put'member','scutshuxue','info:company','alibaba'

1 row(s) in 0.0130seconds

hbase(main):030:0>get 'member','xiaofeng','info:age' 

获取有一4个id的所有数据

COUNTER VALUE = 2

COLUMN                                   CELL                                                                                                               

 info:company                           timestamp=1321586239071, value=alibaba                                                                             

put'member','scutshuxue','address:province','zhejiang'

hbase(main):034:0>is_enabled 'member'

 info:age                               timestamp=1321586238965, value=24                                                                                  

  VERSIONS => '3', COMPRESSION => 'NONE',TTL => '2147483647', BLOCKSIZE => '65536', IN_MEMORY => 'fa                                                       

 scutshuxue                             column=address:contry, timestamp=1321586239126, value=china                                                        

命令表达式

0 row(s) in 0.0110seconds

2.获取第十根数据

 BLOCKCACHE => 'true'}]}                                                                                                                                    

5.删除id为temp的值的‘info:age’字段

hbase(main):028:0>list

名称

0 row(s) in 4.3430seconds

下面朋友儿看看HBase Shell的因此 基本操作命令,我列出了几块常用的HBase Shell命令,如下:

hbase(main):013:0>scan 'member'

true                                                                                                                                                        

COUNTER VALUE = 2

 info:age                               timestamp=1321591025110, value=\x00\x00\x00\x00\x00\x00\x00\x02                                                    

hbase(main):011:0>create 'member','member_id','address','info'   

put'member','xiaofeng','address:province','guangdong'

hbase(main):005:0>get 'member','scutshuxue','info:age' 

 info:birthday                          timestamp=1321586239015, value=1987-06-17                                                                          

8.判断表是不是disable

3 row(s) in 0.0210seconds

1.插入几块记录

 lse', BLOCKCACHE => 'true'}, {NAME =>'info', BLOOMFILTER => 'NONE', REPLICATION_SCOPE => '0', VERSI                                                       

0 row(s) in 0.0210seconds

3 row(s) in 0.0570seconds

COLUMN                                   CELL                                                                                                               

删除记录

false                                                                                                                                                       

hbase(main):012:0>list

0 row(s) in 0.030seconds

1 row(s) in 0.0140seconds

 {NAME => 'member', FAMILIES => [{NAME=> 'address', BLOOMFILTER => 'NONE', REPLICATION_SCOPE => '0', true                                                 

hbase(main):016:0>delete 'member','temp','info:age'

0.90.4, r130278,Sun Jul 24 15:53:29 PDT 2011

4.列出所有的表

hbase(main):001:0>deleteall 'member','xiaofeng'

put'member','xiaofeng','info:birthday','1987-4-17'

hbase(main):058:0>get 'member','xiaofeng','info:age' 

二、DDL操作

1 row(s) in 0.0130seconds

1.查询服务器状态

Truncating 'member'table (it may take a while):

 - Creating table...

put'member','scutshuxue','info:age','24'

hbase(main):006:0>describe 'member'

3.删除有一4个列族,alter,disable,enable

6.查询表是不是地处

0 row(s) in 2.0390seconds

put'member','scutshuxue','address:contry','china'

查看记录

三、DML操作

0 row(s) in 0.1610seconds

hbase(main):019:0>count 'member'                                        

 - Dropping table...

3.通过timestamp来获取有一4个版本的数据

DESCRIPTION                                                                                          ENABLED                                               

hbase(main):030:0>drop 'temp_table'

COLUMN                                   CELL                                                                                                               

不能自己屏蔽该表,能够对该表进行删除,第一步 disable '表名称' 第二步  drop '表名称'

put'member','scutshuxue','address:city','hangzhou'

 scutshuxue                              column=info:age,timestamp=1321586571843, value=99                                                                 

 address:contry                         timestamp=1321586239126, value=china                                                                               

 {NAME => 'member', FAMILIES => [{NAME=> 'address', BLOOMFILTER => 'NONE', REPLICATION_SCOPE => '0',false                                                 

COUNTER VALUE = 1

 xiaofeng                               column=info:birthday, timestamp=1321586248202, value=1987-4-17                                                     

hbase(main):005:0>alter'member',{NAME=>'member_id',METHOD=>'delete'}

 ONS => '3', COMPRESSION => 'NONE', TTL=> '2147483647', BLOCKSIZE => '65536', IN_MEMORY => 'false',                                                        

hbase(main):004:0>disable 'member'                                  

hbase(main):021:0>exists 'member'

 scutshuxue                             column=address:province, timestamp=1321586239197, value=zhejiang                                                   

2.获得表的描述

 address:city                           timestamp=1321586240244, value=hangzhou                                                                            

1 row(s) in 0.0230seconds

  VERSIONS => '3', COMPRESSION => 'NONE',TTL => '2147483647', BLOCKSIZE => '65536', IN_MEMORY => 'fa                                                       

点击(此处)折叠或打开

put'member','xiaofeng','address:city','jieyang'

 scutshuxue                             column=address:city, timestamp=1321586240244, value=hangzhou                                                       

hbase(main):035:0>truncate 'member'

一、一般操作

hbase(main):006:0>describe 'member'

 xiaofeng                               column=address:town, timestamp=1321586249564, value=xianqiao                                                       

get '表名称', '行名称'

 info:birthday                          timestamp=1321586239015, value=1987-06-17                                                                          

 lse', BLOCKCACHE => 'true'}, {NAME =>'info', BLOOMFILTER => 'NONE', REPLICATION_SCOPE => '0', VERSI                                                       

5.drop有一4个表

删除一张表

该列族将会删除,朋友儿继续将表enable

hbase(main):011:0>get 'member','scutshuxue',{COLUMN=>'info:age',TIMESTAMP=>1321586571843}

 xiaofeng                               column=info:company, timestamp=1321586248277, value=alibaba                                                        

scan "表名称"  

delete  '表名' ,'行名称' , '列名称'

0 row(s) in 2.0420seconds

1 row(s) in 0.0320seconds

2 row(s) in 0.0130seconds

2.查询hbase版本

COLUMN                                   CELL                                                                                                               

0 row(s) in 1.1070seconds

6.更新第十根记录

4.全表扫描:

6 row(s) in 0.4720seconds

能够 看出,hbase是先将掉disable掉,因此 drop掉后重建表来实现truncate的功能的。

put'member','xiaofeng','address:town','xianqiao'

0 row(s) in 0.030seconds

 temp                                   column=info:age, timestamp=1321589309775, value=59                                                                 

hbase(main):057:0*incr 'member','xiaofeng','info:age'                    

hbase(main):018:0>get 'member','temp'

 scutshuxue                             column=info:company, timestamp=1321586239071, value=alibaba                                                        

hbase(main):010:0>get 'member','scutshuxue',{COLUMN=>'info:age',TIMESTAMP=>1321586238965}

 info:age                               timestamp=1321586238965, value=24                                                                                  

下面是因此 常见命令的说明,在hbaseshell中输入help的帮助信息,在本文中,朋友儿先介绍前4个,里边有一4个,将在下一篇博文中介绍。

hbase(main):024:0>status

获取有一4个id,有一4个列族暗含一4个列的所有数据

 info:age                               timestamp=1321586571843, value=99                                                                                  

count  '表名称'

put'member','xiaofeng','address:contry','china'

 info:age                               timestamp=1321586238965, value=24                                                                                  

7.判断表是不是enable

 - Disabling table...

put'member','xiaofeng','info:favorite','movie' 

 address:province                       timestamp=1321586239197, value=zhejiang                                                                            

朋友儿然后建了4个列族,因此 发现member_id你你是什么 列族是多余的,将会他本来主键,本来朋友儿要将其删除。

7.查询表暗含几块行:

报错,删除列族的然后需要先将表给disable掉。

1 row(s) in 0.0140seconds

ERROR: Table memberis enabled. Disable it first before altering.

put'member','scutshuxue','info:birthday','1987-06-17'

 xiaofeng                               column=address:contry, timestamp=1321586248316, value=china                                                        

COLUMN                                   CELL                                                                                                               

hbase(main):004:0>put 'member','scutshuxue','info:age' ,'99'

 ONS => '3', COMPRESSION => 'NONE', TTL=> '2147483647', BLOCKSIZE => '65536', IN_MEMORY => 'false',                                                        

hbase(main):032:0>is_disabled 'member'

打上去记录      

DESCRIPTION                                                                                          ENABLED                                               

0 row(s) in 0.0110seconds

 info:age                               timestamp=1321586571843, value=99                                                                                  

0 row(s) in 1.2210seconds

member                                                                                                                                                      

 xiaofeng                               column=info:favorite, timestamp=1321586248241, value=movie                                                         

1.创建有一4个表

put'member','xiaofeng','info:company','alibaba'

将scutshuxue的年龄改成99

scan "表名称" , ['列名称:']

Table member doesexist                                                                                                                                     

 xiaofeng                               column=address:city, timestamp=132158624830, value=jieyang                                                        

TABLE                                                                                                                                                       

hbase(main):003:0>alter 'member',{NAME=>'member_id',METHOD=>'delete'}

查看某个表某个列中所有数据

 info:age                               timestamp=1321586238965, value=24                                                                                  

更新记录 

COLUMN                                   CELL                                                                                                               

0 row(s) in 2.0590seconds

hbase(main):025:0>version

hbase(main):001:0>get 'member','scutshuxue'

获取有一4个id,有一4个列族的所有数据

COLUMN                                   CELL                                                                                                               

0 row(s) in 0.0530seconds

COLUMN                                   CELL                                                                                                               

0 row(s) in 0.3990seconds

2 row(s) in 0.030seconds

 scutshuxue                             column=info:birthday, timestamp=1321586239015, value=1987-06-17                                                    

put '表名称', '行名称', '列名称:', '值'

create '表名称', '列名称1','列名称2','列名称N'

8.给‘xiaofeng’你你是什么 id增加'info:age'字段,并使用counter实现递增

查看表中的记录总数

本来重写一遍进行覆盖

hbase(main):059:0>incr 'member','xiaofeng','info:age'

创建表

1 row(s) in 0.0130seconds

hbase(main):002:0>get 'member','scutshuxue','info'

9.将整张表清空:

3 servers, 0 dead,1.0000 average load

hbase(main):029:0>disable 'temp_table'

hbase(main):002:0>get 'member','scutshuxue','info:age' 

member                                                                                                                                                      

hbase(main):069:0>get_counter 'member','xiaofeng','info:age' 

 info:company                           timestamp=1321586239071, value=alibaba                                                                             

TABLE                                                                                                                                                       

temp_table                                                                                                                                                  

 BLOCKCACHE => 'true'}]}                                                                                                                                    

 info:age                               timestamp=1321590997648, value=\x00\x00\x00\x00\x00\x00\x00\x01                                                    

查看所有记录

ROW                                     COLUMN+CELL                                                                                                        

hbase(main):008:0> enable 'member'  

1 row(s) in 0.0230seconds

1 row(s) in 0.0130seconds

 xiaofeng                               column=address:province, timestamp=1321586248355, value=guangdong                                                  

COLUMN                                   CELL                                                                                                               

6.删除整行