我正在尝试加载数据 HBase
使用 BulkLoad
. 我也在使用 Scala
以及 Spark
编写代码。但每次数据只加载到一个区域。我需要把它加载到多个区域。我使用了以下代码-
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)
我需要帮助。
1条答案
按热度按时间gywdnpxw1#
因为32是每个区域的默认值,所以出现了问题。你应该定义
KeyPrefixRegionSplitPolicy
分割你的文件,你可以增加hbase.mapreduce.bulkload.max.hfiles.perRegion.perFamily
如下所示还可以根据需要增加文件大小