Java教程

Hbase shell管理操作

本文主要是介绍Hbase shell管理操作,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

目录

  • 1 status
  • 2 whoami
  • 3 list
  • 4 count
  • 5 describe
  • 6 exists
  • 7 is_enabled、is_disabled
  • 8 alter
  • 9 disable/enable
  • 10 drop
  • 11 truncate


1 status

例如:显示服务器状态

2.4.1 :062 > status
1 active master, 0 backup masters, 3 servers, 0 dead, 1.0000 average load
Took 0.0034 seconds

2 whoami

显示HBase当前用户,例如:

2.4.1 :066 > whoami
root (auth:SIMPLE)
groups: root
Took 0.0080 seconds

3 list

显示当前所有的表

2.4.1 :067 > list
TABLE
ORDER_INFO
1 row(s)
Took 0.0266 seconds
=> ["ORDER_INFO"]

4 count

统计指定表的记录数,例如:

2.4.1 :070 > count 'ORDER_INFO'
66 row(s)
Took 0.0404 seconds
=> 66

5 describe

展示表结构信息

2.4.1 :074 > describe 'ORDER_INFO'
Table ORDER_INFO is ENABLED
ORDER_INFO
COLUMN FAMILIES DESCRIPTION
{NAME => 'C1', VERSIONS => '1', EVICT_BLOCKS_ON_CLOSE => 'false', NEW_VERSION_BEHAVIOR =>
'false', KEEP_DELETED_CELLS => 'FALSE', CACHE_DATA_ON_WRITE =
> 'false', DATA_BLOCK_ENCODING => 'NONE', TTL => 'FOREVER', MIN_VERSIONS => '0',
REPLICATION_SCOPE => '0', BLOOMFILTER => 'ROW', CACHE_INDEX_ON_WRITE =
> 'false', IN_MEMORY => 'false', CACHE_BLOOMS_ON_WRITE => 'false', PREFETCH_BLOCKS_ON_OPEN
=> 'false', COMPRESSION => 'NONE', BLOCKCACHE => 'true', BLO
CKSIZE => '65536'}
1 row(s)
Took 0.0265 seconds

6 exists

检查表是否存在,适用于表量特别多的情况

2.4.1 :075 > exists 'ORDER_INFO'
Table ORDER_INFO does exist
Took 0.0050 seconds
=> true

7 is_enabled、is_disabled

检查表是否启用或禁用

2.4.1 :077 > is_enabled 'ORDER_INFO'
true
Took 0.0058 seconds
=> true
2.4.1 :078 > is_disabled 'ORDER_INFO'
false
Took 0.0085 seconds
=> 1

8 alter

该命令可以改变表和列蔟的模式,例如:

# 创建一个 USER_INFO 表,两个列蔟 C1、C2
create 'USER_INFO', 'C1', 'C2'
# 新增列蔟 C3
alter 'USER_INFO', 'C3'
# 删除列蔟 C3
alter 'USER_INFO', 'delete' => 'C3'

注意:
⚫ ‘delete’ => ‘C3’,还是一个Map结构,只不过只有一个key,可以省略两边的{}

9 disable/enable

禁用一张表/启用一张表

10 drop

删除一张表,记得在删除表之前必须先禁用

11 truncate

清空表的数据,禁用表-删除表-创建表

这篇关于Hbase shell管理操作的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!