hbase shell命令实操

hbase shell操作命令

进入habse shell

[shaw@hadoop101 module]$ hbase-1.3.6/bin/hbase shell

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/module/hbase-1.3.6/lib/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/module/hadoop-2.7.1/share/hadoop/common/lib/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
HBase Shell; enter 'help<RETURN>' for list of supported commands.
Type "exit<RETURN>" to leave the HBase Shell
Version 1.3.6, r806dc3625c96fe2cfc03048f3c54a0b38bc9e984, Tue Oct 15 01:55:41 PDT 2019

hbase(main):001:0>
1.1 通用命令

status: 提供HBase的状态,例如,服务器的数量。

hbase(main):003:0* status
1 active master, 0 backup masters, 3 servers, 0 dead, 1.6667 average load

version: 提供正在使用HBase版本。

hbase(main):002:0* version
1.3.6, r806dc3625c96fe2cfc03048f3c54a0b38bc9e984, Tue Oct 15 01:55:41 PDT 2019

table_help: 表引用命令提供帮助。

whoami: 提供有关用户的信息。

hbase(main):002:0> whoami
shaw (auth:SIMPLE)
    groups: shaw

2.1数据定义语言

• create: 创建一个表。

hbase(main):005:0> create 'test','info'
0 row(s) in 3.1060 seconds

=> Hbase::Table - test

• list: 列出HBase的所有表。

hbase(main):006:0> list
TABLE                                                                           
stu                                                                             
student                                                                         
test                                                                            
test2                                                                           
4 row(s) in 0.0540 seconds

=> ["stu", "student", "test", "test2"]

• disable: 禁用表。

hbase(main):008:0> disable 'test'
0 row(s) in 2.3900 seconds

• is_disabled: 验证表是否被禁用。

hbase(main):009:0> is_disabled 'test'
true                                                                            
0 row(s) in 0.0620 seconds

• enable: 启用一个表。

hbase(main):010:0> enable 'test'
0 row(s) in 1.4070 seconds

• is_enabled: 验证表是否已启用。

hbase(main):012:0> is_enabled 'test'
true                                                                            
0 row(s) in 0.0270 seconds

• describe: 提供了一个表的描述。

hbase(main):013:0> describe 'test'
Table test is ENABLED                                                           
test                                                                            
COLUMN FAMILIES DESCRIPTION                                                     
{NAME => 'info', BLOOMFILTER => 'ROW', VERSIONS => '1', IN_MEMORY => 'false', KE
EP_DELETED_CELLS => 'FALSE', DATA_BLOCK_ENCODING => 'NONE', TTL => 'FOREVER', CO
MPRESSION => 'NONE', MIN_VERSIONS => '0', BLOCKCACHE => 'true', BLOCKSIZE => '65
536', REPLICATION_SCOPE => '0'}                                                 
1 row(s) in 0.0770 seconds

• alter: 改变一个表。

#修改列族
hbase(main):016:0> alter 'test',{NAME=>'info',VERSIONS=>3}
Updating all regions with the new schema...
1/1 regions updated.
Done.
0 row(s) in 2.3780 seconds
#增加列族
hbase(main):017:0> alter 'test','info1'
Updating all regions with the new schema...
0/1 regions updated.
1/1 regions updated.
Done.
0 row(s) in 3.2560 seconds

#删除列族
hbase(main):019:0> alter 'test',{NAME=>'info1',METHOD=>'delete'}
Updating all regions with the new schema...
1/1 regions updated.
Done.
0 row(s) in 2.4940 seconds

• exists: 验证表是否存在。

hbase(main):020:0> exists 'test'
Table test does exist                                                           
0 row(s) in 0.0470 seconds

• drop: 从HBase中删除表。

#删除表前要disable,再执行drop 
hbase(main):024:0> disable 'test'
0 row(s) in 2.4010 seconds
hbase(main):025:0> drop 'test'
0 row(s) in 1.4840 seconds

2.3数据操纵语言

• put: 把指定列在指定的行中单元格的值在一个特定的表。

hbase(main):032:0> put 'test','001','info:name','Kate'
0 row(s) in 0.3590 seconds

• get: 取行或单元格的内容。

hbase(main):032:0> put 'test','001','info:name','Kate'
0 row(s) in 0.3590 seconds

• scan: 扫描并返回表数据。

hbase(main):001:0> put 'test','002','info:name','Kevin'
0 row(s) in 0.9780 seconds

hbase(main):002:0> scan 'test'
ROW                   COLUMN+CELL                                               
 001                  column=info:name, timestamp=1593595079789, value=Kate     
 002                  column=info:name, timestamp=1593595275647, value=Kevin    
2 row(s) in 0.2710 seconds

• delete: 删除表中的单元格值。

hbase(main):004:0> delete 'test','002','info:name'
0 row(s) in 0.2140 seconds

• deleteall: 删除给定行的所有单元格。

hbase(main):008:0> deleteall 'test','001'
0 row(s) in 0.0150 seconds

• count: 计数并返回表中的行的数目。

hbase(main):012:0> count 'test'
2 row(s) in 0.1470 seconds

=> 2

• truncate: 禁用,删除和重新创建一个指定的表。

hbase(main):013:0> truncate 'test'
Truncating 'test' table (it may take a while):
 - Disabling table...
 - Truncating table...
0 row(s) in 4.5520 seconds

参考 https://www.yiibai.com/hbase/hbase_shell.html
参考 http://c.biancheng.net/view/6531.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值