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'	# 删除数据重建表
相关推荐
成长之路5141 小时前
【面板数据】中国与世界各国新能源汽车进出口数据-分类别与不分类别(2017-2024年)
大数据·汽车
说私域1 小时前
传统企业数字化转型:以定制开发开源 AI 智能名片 S2B2C 商城小程序源码为核心的销售环节突破
大数据·人工智能·开源
一 乐4 小时前
民宿|基于java的民宿推荐系统(源码+数据库+文档)
java·前端·数据库·vue.js·论文·源码
美林数据Tempodata5 小时前
大模型驱动数据分析革新:美林数据智能问数解决方案破局传统 BI 痛点
数据库·人工智能·数据分析·大模型·智能问数
野槐6 小时前
node.js连接mysql写接口(一)
数据库·mysql
G皮T6 小时前
【Elasticsearch】正排索引、倒排索引(含实战案例)
大数据·elasticsearch·搜索引擎·kibana·倒排索引·搜索·正排索引
Zzzone6836 小时前
PostgreSQL日常维护
数据库·postgresql
chxii6 小时前
1.13使用 Node.js 操作 SQLite
数据库·sqlite·node.js
冰刀画的圈6 小时前
修改Oracle编码
数据库·oracle
这个胖子不太裤6 小时前
Django(自用)
数据库·django·sqlite