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'	# 删除数据重建表
相关推荐
经典19921 分钟前
mysql 锁介绍
数据库·mysql
不太可爱的大白2 分钟前
Mysql分片:一致性哈希算法
数据库·mysql·算法·哈希算法
~ 小团子4 分钟前
每日一SQL 【游戏玩法分析 IV】
数据库·sql·游戏
零叹7 分钟前
MySQL——常用程序and主从复制
数据库·mysql
胚芽鞘6814 小时前
关于java项目中maven的理解
java·数据库·maven
Edingbrugh.南空6 小时前
Flink自定义函数
大数据·flink
gaosushexiangji7 小时前
利用sCMOS科学相机测量激光散射强度
大数据·人工智能·数码相机·计算机视觉
sun0077007 小时前
mysql索引底层原理
数据库·mysql
无级程序员10 小时前
大数据平台之ranger与ldap集成,同步用户和组
大数据·hadoop
workflower10 小时前
MDSE和敏捷开发相互矛盾之处:方法论本质的冲突
数据库·软件工程·敏捷流程·极限编程