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'	# 删除数据重建表
相关推荐
TDengine (老段)33 分钟前
杨凌美畅用 TDengine 时序数据库,支撑 500 条产线 2 年历史数据追溯
大数据·数据库·物联网·时序数据库·tdengine·涛思数据
青云交39 分钟前
Java 大视界 -- Java 大数据机器学习模型在游戏用户行为分析与游戏平衡优化中的应用
java·大数据·机器学习·数据存储·模型构建·游戏用户行为分析·游戏平衡优化
葛小白13 小时前
C#数据类型:string简单使用
服务器·数据库·c#
污斑兔4 小时前
MongoDB的$sample是啥?
数据库·mongodb
RE-19014 小时前
《深入浅出统计学》学习笔记(一)
大数据·数学·概率论·统计学·数理统计·知识笔记·深入浅出
马丁的代码日记5 小时前
MySQL InnoDB 行锁与死锁排查实战演示
数据库·mysql
拍客圈6 小时前
数据主站+副站做的设置
数据库
计算机学长felix6 小时前
基于SpringBoot的“面向校园的助力跑腿系统”的设计与实现(源码+数据库+文档+PPT)
数据库·spring boot·后端
赵部长风向标7 小时前
在本地生活赛道,如何打造属于自己的业务护城河?
大数据
青云交7 小时前
Java 大视界 -- Java 大数据在智能教育学习社区互动模式创新与用户活跃度提升中的应用(426)
java·大数据·学习·flink 实时计算·智能教育社区·互动模式创新·用户活跃度