Hbase-之hbase shell使用包含预分区的几种方式

Hbase-之hbase shell使用(预分区…)

Hbase的命令可以查看这里,很全:

1 hbase shell入门

  • 最简单的入门进入交互式界面
cd /hbase-2.4.2
./bin/hbase shell

常用的hbase shell练习可以参考 hbase shell 练习

# 查看hbase shell指南
help

# 创建table test
create 'test','cf'

# 列出table,判断是否存在list
list 'test'

# 描述表的信息
describe 'test'

# put数据进table
put 'test','rowkey1','cf:id','1'
put 'test','rowkey2','cf:name','bob'

#scan扫描表
scan 'test'

# get一行数据
get 'test','rowkey1'

#禁用/启用table
disable 'test'
enable 'test'

# drop table
drop 'test'

# 退出交互式hbase shell
quit
stopping hbase....................

# 使用hbase shell的计数命令count,每次抓取1000行
count 'test' ,CACHE => 1000 

2 使用hbase shell的非交互式模式

hbase的非交互式模式与hive的hive -e/-f一样

./bin/hbase shell  -n or --non-interactive

2.1 将系统shell脚本结合hbase shell使用

#实际上 describe 'test'可以换成其它任何hbase shell命令
echo "describe 'test'" | hbase shell -n

3 动态配置JVM选项启动hbase shell

HBASE_SHELL_OPTS="-verbose:gc -XX:+PrintGCApplicationStoppedTime -XX:+PrintGCDateStamps \
  -XX:+PrintGCDetails -Xloggc:$HBASE_HOME/logs/gc-hbase.log" ./bin/hbase shell

4 重写默认配置启动hbase shell

$ ./bin/hbase shell -Dhbase.zookeeper.quorum=ZK0.remote.cluster.example.org,ZK1.remote.cluster.example.org,ZK2.remote.cluster.example.org -Draining=false
...


hbase(main):001:0> @shell.hbase.configuration.get("hbase.zookeeper.quorum")
=> "ZK0.remote.cluster.example.org,ZK1.remote.cluster.example.org,ZK2.remote.cluster.example.org"
hbase(main):002:0> @shell.hbase.configuration.get("raining")
=> "false"

5 通过hbase shell进行region split

5.1 pre-split方式1

#table t1,创建了一个列簇,同时被分成4个region
# <10 \ 10~20 \ 20~30 \ >30
create 't1','cf',SPLITS => ['10','20','30']

5.2 pre-split方式2

vim split.txt 
10
20
30
# 每行算作一个region分隔符,左闭右开

hbase>create 't14','f',SPLITS_FILE=>'splits.txt'

5.3 按照Hbase的自带的分区策略进行预分区

# create table with four regions based on random bytes keys
hbase>create 't2','f1', { NUMREGIONS => 4 , SPLITALGO => 'UniformSplit' }

# create table with five regions based on hex keys
hbase>create 't3','f1', { NUMREGIONS => 5, SPLITALGO => 'HexStringSplit' }
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值