hbase shell 预分区

来源:互联网 发布:淘宝如何登录店铺 编辑:程序博客网 时间:2024/06/05 00:55

使用HBase Shell建表的时候,除了一些常用的option以外,我们还可以同时建立一些预分区,这样可以预防初次插入数据时热点问题。

通过直接输入create,我们可以看到有如下提示:

?
1
2
3
4
5
6
7
8
9
10
11
12
Examples:
 
  hbase> create 't1', {NAME => 'f1', VERSIONS => 5}
  hbase> create 't1', {NAME => 'f1'}, {NAME => 'f2'}, {NAME => 'f3'}
  hbase># The above in shorthand would be the following:
  hbase> create 't1','f1','f2','f3'
  hbase> create 't1', {NAME => 'f1', VERSIONS => 1, TTL => 2592000, BLOCKCACHE => true}
  hbase> create 't1','f1', {SPLITS => ['10','20','30','40']}
  hbase> create 't1','f1', {SPLITS_FILE => 'splits.txt'}
  hbase># Optionally pre-split the table into NUMREGIONS, using
  hbase># SPLITALGO ("HexStringSplit", "UniformSplit" or classname)
  hbase> create 't1','f1', {NUMREGIONS => 15, SPLITALGO => 'HexStringSplit'}

例子中仅给出了要么有普通option,要么是有指定分区等选项,但是没有给出既有普通option(例如VERSIONS,COMPRESSION等),又创建预分区的例子。

如果有这个需求呢?如下对吗?

create 't', {NAME => 'f', VERSIONS => 1, COMPRESSION => 'SNAPPY', SPLITS => ['10','20','30']}

运行后发现肯定是不行的。正确的写法应该是这样的:

?
1
2
create't', {NAME => 'f', VERSIONS => 1, COMPRESSION => 'SNAPPY'},
    {SPLITS => ['10','20','30']}

因为分区时针对全表而非某个Column Family的。

0 0