假設你的table有10個region,他們的名字分別爲1,2...10
Hbase 並沒有提供直接合並 2-8這7個region的方法,如果你要合併多個region,那要稍微麻煩一點,具體方法如下
首先使用Hbase shell自帶的merge_region方法:
Merge two regions. Passing 'true' as the optional third parameter will force
a merge ('force' merges regardless else merge will fail unless passed
adjacent regions. 'force' is for expert use only).
NOTE: You must pass the encoded region name, not the full region name so
this command is a little different from other region operations. The encoded
region name is the hash suffix on region names: e.g. if the region name were
TestTable,0094429456,1289497600452.527db22f95c8a9e0116f0cc13c680396. then
the encoded region name portion is 527db22f95c8a9e0116f0cc13c680396
Examples:
hbase> merge_region 'ENCODED_REGIONNAME', 'ENCODED_REGIONNAME'
hbase> merge_region 'ENCODED_REGIONNAME', 'ENCODED_REGIONNAME', true
使用merge_region方法合併多個region後會生成新的region,但是會有2個問題
1:overlap(hbase metadata信息沒做處理)
2:hdfs上的region信息沒做處理
解決這兩個問題可以使用hbase hbck命令,舉例:
hbase hbck ssp_rt -fixHdfsOverlaps -maxMerge 100 -fixMeta -fixAssignments
這個命令會合並hbase metadata中overlap的region並且刪除hdfs上相應的文件