HBase shell 常用命令总结

HBase shell 常用命令总结

1. status
c 复制代码
hbase> status	#集群状态
hbase> status 'simple'	#集群各节点状态信息
hbase> status 'detailed'	#各表region状态信息
2. whoami
c 复制代码
hbase> whoami	#查询当前hbase用户
3. version
c 复制代码
hbase> version	#查询hbase版本
4. alter
c 复制代码
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
c 复制代码
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
c 复制代码
hbase> describe 'table1'	# 查看表详情
7. disable
c 复制代码
hbase> disable 'table1'	# 禁用表table1
8. disable_all
c 复制代码
hbase> disable_all 't.*'	# 禁用正则匹配到的表
9. is_disabled
c 复制代码
hbase> is_disabled 'table1'	# 查看表是否禁用
10. drop
c 复制代码
hbase> drop 'table1'	# 删除表table1
11. drop_all
c 复制代码
hbase> drop_all 't.*'	# 删除正则匹配到的表
12. enable
c 复制代码
hbase> enable 'table1'	# 启用表
13. enable_all
c 复制代码
hbase> enable_all 't.*'	# 启用正则匹配到的表
14. is_enabled
c 复制代码
hbase> is_enabled 'table1'	# 查看表是否启用
15. exists
c 复制代码
hbase> exists 'table1'	# 查看表是否存在
16. list
c 复制代码
hbase> list	# 查看所有表
hbase> list 'abc.*'	查看正则匹配到的表
17. show_filters
c 复制代码
hbase> show_filters	# 查看所有过滤器
18. alter_status
c 复制代码
hbase> alter_status 'table1'	# 获取 alter 命令的状态。显示已接收更新的架构传递表名称的表的区域数
19. alter_async
c 复制代码
hbase> alter_async 'table1', NAME => 'cf1', METHOD => 'delete'	# 异步修改列族Schema
20. count
c 复制代码
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
c 复制代码
hbase> delete 'table1', 'rk1', 'c1', ts1	# 删除rk1行c1列中标有ts1时间戳的数据
22. deleteall
c 复制代码
hbase> deleteall 'table1', 'rk1'	#  删除rk1这一行
hbase> deleteall 'table1', 'rk1', 'c1'	# 删除rk1这一行列c1的数据
hbase> deleteall 'table1', 'rk1', 'c1', ts1	# 删除rk1行c1列中标有ts1时间戳的数据
23. get
c 复制代码
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
c 复制代码
hbase> get_counter 'table1', 'rk1', 'c1'	# 查询指定表、行、列计数器的值
25. incr
c 复制代码
hbase> incr 'table1', 'rk1', 'c1'	# 指定表、行、列计数器+1
hbase> incr 'table1', 'rk1', 'c1', 1	# 指定表、行、列计数器+1
hbase> incr 'table1', 'rk1', 'c1', 10	# 指定表、行、列计数器+10
26. put
c 复制代码
hbase> put 'table1', 'rk1', 'c1', 'value', ts1	# 将值value更新到r1行c1列ts1时间戳下
27. scan
c 复制代码
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,时间戳在123和456之间的数据
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
c 复制代码
hbase>truncate 'table1'	# 删除数据重建表
相关推荐
shinelord明3 小时前
【大数据技术实战】Kafka 认证机制全解析
大数据·数据结构·分布式·架构·kafka
DokiDoki之父3 小时前
Mybatis—入门 & (配置)SQL提示和日志输出
数据库·sql·mybatis
文火冰糖的硅基工坊4 小时前
[创业之路-702]:“第三次”与“第四次工业革命”的范式跃迁
大数据·人工智能·科技·嵌入式硬件·架构·嵌入式·gpu
TDengine (老段)4 小时前
TDengine 数据函数 LN 用户手册
大数据·数据库·物联网·时序数据库·tdengine·涛思数据
机灵猫4 小时前
Redis 在订单系统中的实战应用:防重、限流与库存扣减
数据库·redis·缓存
木易2.04 小时前
从零构建RAG知识库管理系统(二)
数据库·oracle
程序新视界4 小时前
什么是MySQL JOIN查询的驱动表和被驱动表?
数据库·后端·mysql
lingggggaaaa5 小时前
小迪安全v2023学习笔记(一百三十四讲)—— Windows权限提升篇&数据库篇&MySQL&MSSQL&Oracle&自动化项目
java·数据库·windows·笔记·学习·安全·网络安全
小光学长5 小时前
基于Vue的保护动物信息管理系统r7zl6b88 (程序+源码+数据库+调试部署+开发环境)带论文文档1万字以上,文末可获取,系统界面在最后面。
前端·数据库·vue.js
一匹电信狗5 小时前
【MySQL】数据库的相关操作
linux·运维·服务器·数据库·mysql·ubuntu·小程序