最近遇到hbase高频插入的需求,有些注意的点简单记录一下:
1、建表
建表的时候尽量预分区,避免region集中在少数几个regionserver,避免region hotspot
如何建立预分区的表?
1、shell
1、 hbase> create 't1', 'f1', SPLITS => ['10', '20', '30']
2、 hbase> create 't1', 'f1', SPLITS_FILE => 'splits.txt', OWNER => 'johndoe'
# Optionally pre-split the table into NUMREGIONS, using
# SPLITALGO ("HexStringSplit", "UniformSplit" or classname)
3、 hbase> create 't1', 'f1', {NUMREGIONS => 15, SPLITALGO => 'HexStringSplit'}
4、 hbase> create 't1', 'f1', {NUMREGIONS => 15, SPLITALGO => 'HexStringSplit', CONFIGURATION => {'hbase.hregion.scan.loadColumnFamiliesOnDemand' => 'true'}}
ok,一个一个分析:
1、第一个命令新建一个 表 t1,列族 f1,预分4个region,region的 startkey 和 endkey 分别为 < , 10>, <10, 20>, <20, 30>,<30,>
2、第二个命令需要一个预分的文件splits.txt, 这个文件的每一行代表一个endkey,比如说splits.txt的内容为:
10
20
30
&n