【问题标题】:HBASE Bulk-Load in multiple region for a single table单个表的多个区域中的 HBASE 批量加载
【发布时间】:2017-11-16 12:40:39
【问题描述】:

我正在尝试使用BulkLoadHBase 中加载数据。我也在使用ScalaSpark 来编写代码。但每次数据只加载到一个区域。我需要将其加载到多个区域。我使用了以下代码 -

Hbase 配置

def getConf: Configuration = {
    val hbaseSitePath = "/etc/hbase/conf/hbase-site.xml"
    val conf = HBaseConfiguration.create()
    conf.addResource(new Path(hbaseSitePath))
    conf.setInt("hbase.mapreduce.bulkload.max.hfiles.perRegion.perFamily", 100)
    conf   
}

使用上述配置,我只能在一个区域中加载 80GB 的数据。

但是当我尝试在多个区域中加载相同数量的数据时,下面提到的配置会出现异常

java.io.IOException: 试图将超过 32 个 hfiles 加载到一个系列 一个地区的

更新配置 -

def getConf: Configuration = {

  val conf = HBaseConfiguration.create()
  conf.addResource(new Path(hbaseSitePath))
  conf.setInt("hbase.mapreduce.bulkload.max.hfiles.perRegion.perFamily", 32)

  conf.setLong("hbase.hregion.max.filesize", 107374182)
  conf.set("hbase.regionserver.region.split.policy","org.apache.hadoop.hbase.regionserver.ConstantSizeRegionSplitPolicy")
  conf
}

为了保存记录,我使用下面的代码 -

val kv = new KeyValue(Bytes.toBytes(key), columnFamily.getBytes(),
        columnName.getBytes(), columnValue.getBytes())

      (new ImmutableBytesWritable(Bytes.toBytes(key)), kv)

rdd.saveAsNewAPIHadoopFile(pathToHFile, classOf[ImmutableBytesWritable], classOf[KeyValue],
      classOf[HFileOutputFormat2], conf) //Here rdd is the input

    val loadFiles = new LoadIncrementalHFiles(conf)
    loadFiles.doBulkLoad(new Path(pathToHFile), hTable)

需要这方面的帮助。

【问题讨论】:

  • 你的行键是连续的吗?当您将具有顺序键的记录写入 Hbase 时,HBase 仅命中一个 Region。此行为特定于 HBase,与使用 Spark 无关。查看这篇文章:sematext.com/blog/2012/04/09/…
  • 我正在保存密钥,例如 001_16062017105407、002_16062017105455、003_16062017105505 和升序。

标签: scala apache-spark hbase hadoop2


【解决方案1】:

您遇到问题是因为 32 是每个区域的默认值。你应该定义KeyPrefixRegionSplitPolicy来分割你的文件,你可以增加hbase.mapreduce.bulkload.max.hfiles.perRegion.perFamily如下

conf.setInt("hbase.mapreduce.bulkload.max.hfiles.perRegion.perFamily", 1024)

也尝试增加文件大小为

  conf.setLong("hbase.hregion.max.filesize", 107374182)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-05-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多