hbaseshell操作命令.docx

上传人:b****6 文档编号:5107926 上传时间:2022-12-13 格式:DOCX 页数:10 大小:17.24KB
下载 相关 举报
hbaseshell操作命令.docx_第1页
第1页 / 共10页
hbaseshell操作命令.docx_第2页
第2页 / 共10页
hbaseshell操作命令.docx_第3页
第3页 / 共10页
hbaseshell操作命令.docx_第4页
第4页 / 共10页
hbaseshell操作命令.docx_第5页
第5页 / 共10页
点击查看更多>>
下载资源
资源描述

hbaseshell操作命令.docx

《hbaseshell操作命令.docx》由会员分享,可在线阅读,更多相关《hbaseshell操作命令.docx(10页珍藏版)》请在冰豆网上搜索。

hbaseshell操作命令.docx

hbaseshell操作命令

下面我们看看HBaseShell的一些基本操作命令,我列出了几个常用的HBaseShell命令,如下:

名称

命令表达式

创建表

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

添加记录     

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

','值'

查看记录

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

查看表中的记录总数

count '表名称'

删除记录

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

删除一张表

先要屏蔽该表,才能对该表进行删除,第一步disable'表名称'第二步 drop'表名称'

查看所有记录

scan"表名称"  

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

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

']

更新记录 

就是重写一遍进行覆盖

 370625************

齐春芬

95105105

一、一般操作

1.查询服务器状态

hbase(main):

024:

0>status

3servers,0dead,1.0000averageload

 

2.查询hive版本

 

hbase(main):

025:

0>version

0.90.4,r1150278,SunJul2415:

53:

29PDT2011

 

二、DDL操作

 

1.创建一个表

hbase(main):

011:

0>create'member','member_id','address','info'   

0row(s)in1.2210seconds

 

2.获得表的描述

hbase(main):

012:

0>list

TABLE                                                                                                                                                       

member                                                                                                                                                      

1row(s)in0.0160seconds

hbase(main):

006:

0>describe'member'

DESCRIPTION                                                                                          ENABLED                                               

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

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

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

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

 BLOCKCACHE=>'true'}]}                                                                                                                                    

1row(s)in0.0230seconds

 

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

我们之前建了3个列族,但是发现member_id这个列族是多余的,因为他就是主键,所以我们要将其删除。

hbase(main):

003:

0>alter'member',{NAME=>'member_id',METHOD=>'delete'}

 

ERROR:

Tablememberisenabled.Disableitfirstbeforealtering.

 

报错,删除列族的时候必须先将表给disable掉。

hbase(main):

004:

0>disable'member'                                  

0row(s)in2.0390seconds

hbase(main):

005:

0>alter'member',{NAME=>'member_id',METHOD=>'delete'}

0row(s)in0.0560seconds

hbase(main):

006:

0>describe'member'

DESCRIPTION                                                                                          ENABLED                                               

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

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

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

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

 BLOCKCACHE=>'true'}]}                                                                                                                                    

1row(s)in0.0230seconds

该列族已经删除,我们继续将表enable

hbase(main):

008:

0>enable'member'  

0row(s)in2.0420seconds

 

4.列出所有的表

hbase(main):

028:

0>list

TABLE                                                                                                                                                       

member                                                                                                                                                      

temp_table                                                                                                                                                  

2row(s)in0.0150seconds

 

 

5.drop一个表

hbase(main):

029:

0>disable'temp_table'

0row(s)in2.0590seconds

 

hbase(main):

030:

0>drop'temp_table'

0row(s)in1.1070seconds

 

 

6.查询表是否存在

hbase(main):

021:

0>exists'member'

Tablememberdoesexist                                                                                                                                     

0row(s)in0.1610seconds

 

7.判断表是否enable

hbase(main):

034:

0>is_enabled'member'

true                                                                                                                                                        

0row(s)in0.0110seconds

 

8.判断表是否disable

hbase(main):

032:

0>is_disabled'member'

false                                                                                                                                                       

0row(s)in0.0110seconds

 

 

 

三、DML操作

 

 

1.插入几条记录

put'member','scutshuxue','info:

age','24'

put'member','scutshuxue','info:

birthday','1987-06-17'

put'member','scutshuxue','info:

company','alibaba'

put'member','scutshuxue','address:

contry','china'

put'member','scutshuxue','address:

province','zhejiang'

put'member','scutshuxue','address:

city','hangzhou'

 

 

put'member','xiaofeng','info:

birthday','1987-4-17'

put'member','xiaofeng','info:

favorite','movie' 

put'member','xiaofeng','info:

company','alibaba'

put'member','xiaofeng','address:

contry','china'

put'member','xiaofeng','address:

province','guangdong'

put'member','xiaofeng','address:

city','jieyang'

put'member','xiaofeng','address:

town','xianqiao'

 

 

 

2.获取一条数据

获取一个id的所有数据

hbase(main):

001:

0>get'member','scutshuxue'

COLUMN                                  CELL                                                                                                               

 address:

city                           timestamp=1321586240244,value=hangzhou                                                                            

 address:

contry                         timestamp=1321586239126,value=china                                                                               

 address:

province                       timestamp=1321586239197,value=zhejiang                                                                            

 info:

age                               timestamp=1321586238965,value=24                                                                                  

 info:

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

 info:

company                           timestamp=1321586239071,value=alibaba                                                                             

6row(s)in0.4720seconds

 

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

hbase(main):

002:

0>get'member','scutshuxue','info'

COLUMN                                  CELL                                                                                                               

 info:

age                               timestamp=1321586238965,value=24                                                                                  

 info:

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

 info:

company                           timestamp=1321586239071,value=alibaba                                                                             

3row(s)in0.0210seconds

 

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

hbase(main):

002:

0>get'member','scutshuxue','info:

age' 

COLUMN                                  CELL                                                                                                               

 info:

age                               timestamp=1321586238965,value=24                                                                                  

1row(s)in0.0320seconds

 

 

6.更新一条记录

将scutshuxue的年龄改成99

hbase(main):

004:

0>put'member','scutshuxue','info:

age','99'

0row(s)in0.0210seconds

 

hbase(main):

005:

0>get'member','scutshuxue','info:

age' 

COLUMN                                  CELL                                                                                                               

 info:

age                               timestamp=1321586571843,value=99                                                                                  

1row(s)in0.0180seconds

 

 

3.通过timestamp来获取两个版本的数据

hbase(main):

010:

0>get'member','scutshuxue',{COLUMN=>'info:

age',TIMESTAMP=>1321586238965}

COLUMN                                  CELL                                                                                                               

 info:

age                               timestamp=1321586238965,value=24                                                                                  

1row(s)in0.0140seconds

 

hbase(main):

011:

0>get'member','scutshuxue',{COLUMN=>'info:

age',TIMESTAMP=>1321586571843}

COLUMN                                  CELL                                                                                                               

 info:

age                               timestamp=1321586571843,value=99                                                                                  

1row(s)in0.0180seconds

 

 

4.全表扫描:

hbase(main):

013:

0>scan'member'

ROW                                     COLUMN+CELL                                                                                                        

 scutshuxue                             column=address:

city,timestamp=1321586240244,value=hangzhou                                                       

 scutshuxue                             column=address:

contry,timestamp=1321586239126,val

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 解决方案 > 其它

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1