Hbase-shell命令指南

x33g5p2x  于2020-09-08 发布在 Shell  
字(1.0k)|赞(0)|评价(0)|浏览(824)

1.基础命令

#连接Hbase
./bin/hbase shell

#创建表,指定表名test和列族名cf
create 'test','cf'

#列出test表
list 'test'

#列出test表详细信息
describe 'test'

#增加数据
put 'test','row1','cf:a','value1'

put 'test','row2','cf:b','value2'

put 'test','row3','cf:c','value3'

#扫描表所有数据
scan 'test'

#查询单行数据
get 'test','row1'

#禁用表(删除表之前需要先禁用表,可以用enable启动表)
disable 'test'

#删除表
drop 'test'

2.更多命令

Hbase shell支持系统Bash shell命令

echo "describe 'test1'" | ./hbase shell -n

执行文件命令

./hbase shell ./sample_commands.txt

预分割表

create 't1','f',SPLITS => ['10','20','30']

#根据随机字节键创建包含四个区域的表
create 't2','f1', { NUMREGIONS => 4 , SPLITALGO => 'UniformSplit' }

#基于十六进制键创建具有五个区域的表
create 't3','f1', { NUMREGIONS => 5, SPLITALGO => 'HexStringSplit' }

Hbase开启Debug模式,看到更多的输出信息

debug

Hbase shell中启动debug级别日志记录

./bin/hbase shell -d

表的行数

count '<tablename>', CACHE => 1000

备份

hbase backup create full hdfs://host5:9000/data/backup -t SALES2,SALES3 -w 3

备份恢复

hbase restore <backup_path> <backup_id>

hbase restore /tmp/backup_incremental backupId_1467823988425 -t mytable1,mytable2

合并备份

hbase backup merge backupId_1467823988425,backupId_1467827588425

相关文章

微信公众号