HBase shell 常用命令总结

这篇文章详细介绍了HBaseshell中的一系列HBase命令,包括集群状态检查、用户身份验证、版本查询、表结构修改、创建与删除表、数据操作等,涵盖了HBase的基础管理和数据处理功能。
摘要由CSDN通过智能技术生成

HBase shell 常用命令总结

1. status
hbase> status	#集群状态
hbase> status 'simple'	#集群各节点状态信息
hbase> status 'detailed'	#各表region状态信息
2. whoami
hbase> whoami	#查询当前hbase用户
3. version
hbase> version	#查询hbase版本
4. alter
hbase> alter 'table1', NAME => 'cf', VERSIONS => 5	# 修改列族版本数为5
hbase> alter 'table1', 'cf1',{NAME => 'cf2', IN_MEMORY => true}	# 列族cf2开启激进缓存
hbase> alter 'table1', 'delete' => 'cf1'	# 删除列族cf1
hbase> alter 'table1', MAX_FILESIZE => '134217728'	# 修改文件最大为 128MB
hbase> alter 'table1', METHOD => 'table_att_unset', NAME => 'MAX_FILESIZE'	# 删除table-scope属性MAX_FILESIZE
hbase> alter 'table1', METADATA => {'mykey' => 'myvalue'}	# 添加元数据mykey,其值为myvalue
5. create
hbase> create 'table1', {NAME => 'cf1', VERSIONS => 5}	# 创建只有一个列族cf1且版本数为5的表table1
hbase> create 'table1', {NAME => 'cf1'}, {NAME => 'cf2'}, {NAME => 'cf3'}	# 创建有三个列族的表table1
hbase> create 'table1', 'cf1', 'cf2', 'cf3'	# 创建有三个列族的表table1
hbase> create 'table1', {NAME => 'cf1', VERSIONS => 1, TTL => 2592000, BLOCKCACHE => true}	# 创建一个列族cf1,且版本数为1,TTL为30天,块缓存开启的表table1
6. describe
hbase> describe 'table1'	# 查看表详情
7. disable
hbase> disable 'table1'	# 禁用表table1
8. disable_all
hbase> disable_all 't.*'	# 禁用正则匹配到的表
9. is_disabled
hbase> is_disabled 'table1'	# 查看表是否禁用
10. drop
hbase> drop 'table1'	# 删除表table1
11. drop_all
hbase> drop_all 't.*'	# 删除正则匹配到的表
12. enable
hbase> enable 'table1'	# 启用表
13. enable_all
hbase> enable_all 't.*'	# 启用正则匹配到的表
14. is_enabled
hbase> is_enabled 'table1'	# 查看表是否启用
15. exists
hbase> exists 'table1'	# 查看表是否存在
16. list
hbase> list	# 查看所有表
hbase> list 'abc.*'	查看正则匹配到的表
17. show_filters
hbase> show_filters	# 查看所有过滤器
18. alter_status
hbase> alter_status 'table1'	# 获取 alter 命令的状态。显示已接收更新的架构传递表名称的表的区域数
19. alter_async
hbase> alter_async 'table1', NAME => 'cf1', METHOD => 'delete'	# 异步修改列族Schema
20. count
hbase> count 'table1'	# 计算表行数
hbase> count 'table1', INTERVAL => 100000	# 设置每统计100000行显示
hbase> count 'table1', CACHE => 1000	# 设置缓存条数1000
hbase> count 'table1', INTERVAL => 10, CACHE => 1000	# 设置缓存条数1000,每统计10行显示
21. delete
hbase> delete 'table1', 'rk1', 'c1', ts1	# 删除rk1行c1列中标有ts1时间戳的数据
22. deleteall
hbase> deleteall 'table1', 'rk1'	#  删除rk1这一行
hbase> deleteall 'table1', 'rk1', 'c1'	# 删除rk1这一行列c1的数据
hbase> deleteall 'table1', 'rk1', 'c1', ts1	# 删除rk1行c1列中标有ts1时间戳的数据
23. get
hbase> get 'table1', 'rk1'	# 查询rk1这一行数据
hbase> get 'table1', 'rk1', {TIMERANGE => [ts1, ts2]}	# 查询rk1这一行在时间区间[ts1, ts2]的数据
hbase> get 'table1', 'rk1', {COLUMN => 'c1'}	# 查询rk1这一行列c1的数据
hbase> get 'table1', 'rk1', {COLUMN => ['c1', 'c2', 'c3']}	# 查询rk1这一行列c1、c2、c3的数据
hbase> get 'table1', 'rk1', {COLUMN => 'c1', TIMESTAMP => ts1}	# 查询rk1这一行列c1的时间为ts1的数据
hbase> get 'table1', 'rk1', {COLUMN => 'c1', TIMERANGE => [ts1, ts2], VERSIONS => 4}	# 查询rk1这一行列c1的时间区间[ts1, ts2]的版本数为4的数据
hbase> get 'table1', 'rk1', {FILTER => "ValueFilter(=, 'binary:abc')"}	# 查询rk1这一行值为abc的数据
hbase> get 'table1', 'rk1', 'c1'	# 查询rk1这一行列c1的数据
hbase> get 'table1', 'rk1', 'c1', 'c2'	# 查询rk1这一行列c1、c2的数据
hbase> get 'table1', 'rk1', ['c1', 'c2']	# 查询rk1这一行列c1、c2的数据
24. get_counter
hbase> get_counter 'table1', 'rk1', 'c1'	# 查询指定表、行、列计数器的值
25. incr
hbase> incr 'table1', 'rk1', 'c1'	# 指定表、行、列计数器+1
hbase> incr 'table1', 'rk1', 'c1', 1	# 指定表、行、列计数器+1
hbase> incr 'table1', 'rk1', 'c1', 10	# 指定表、行、列计数器+10
26. put
hbase> put 'table1', 'rk1', 'c1', 'value', ts1	# 将值value更新到r1行c1列ts1时间戳下
27. scan
hbase> scan '.META.'	# 扫描元数据
hbase> scan '.META.', {COLUMNS => 'info:regioninfo'}	扫描regioninfo元数据
hbase> scan 'table1', {COLUMNS => ['c1', 'c2'], LIMIT => 10, STARTROW => 'xyz'}	# 扫描列c1、c2的数据,始于主键xyz,输出10行
hbase> scan 'table1', {COLUMNS => 'c1', TIMERANGE => [1303668804, 1303668904]}	# 扫描列c1在时间区间[1303668804, 1303668904]的数据
hbase> scan 'table1', {FILTER => "(PrefixFilter ('row2')AND(QualifierFilter (>=, 'binary:xyz'))) AND (TimestampsFilter (123, 456))"}	# 过滤出主键是row2开头,列名大于等于xyz,时间戳在123456之间的数据
hbase> scan 'table1', {FILTER =>org.apache.hadoop.hbase.filter.ColumnPaginationFilter.new(2, 0)}	# 扫描从第0列开始,向后的2列数据
hbase> scan 'table1', {COLUMNS => ['c1', 'c2'], CACHE_BLOCKS => false}	# 扫描列c1、c2的数据
hbase> scan 'table1', {RAW => true, VERSIONS => 10}	# 扫描最近10个版本的原始数据
hbase> scan 'table1', {COLUMNS => ['cf:qualifier1:toInt'}	# 扫描qualifier1格式化为整数
hbase> t = get_table 'table1'	# 表table1引用为t
hbase> t.scan	# 扫描table1全表
28. truncate
hbase>truncate 'table1'	# 删除数据重建表
  • 9
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

公子乂

你的鼓励是我创作的大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值