【问题标题】:HBase ImportTsv tuningHBase ImportTsv 调优
【发布时间】:2019-12-27 23:26:23
【问题描述】:

我在 Cloudera 5.16 和 Hadoop 2.6 上。

我使用 ImportTsv 将大的 csv 文件加载到 HBase。

hbase org.apache.hadoop.hbase.mapreduce.ImportTsv -Dimporttsv.separator=';' -Dimporttsv.columns=HBASE_ROW_KEY,data:name,data:age mynamespace:mytable /path/to/csv/dir/*.csv

我的问题是,无论文件大小如何(我的文件有 300k 行,而其他文件有 1k 行),操作需要 20 到 30 秒。

19/08/22 15:11:56 INFO mapreduce.Job: Job job_1566288518023_0335 running in uber mode : false
19/08/22 15:11:56 INFO mapreduce.Job:  map 0% reduce 0%
19/08/22 15:12:06 INFO mapreduce.Job:  map 67% reduce 0%
19/08/22 15:12:08 INFO mapreduce.Job:  map 100% reduce 0%
19/08/22 15:12:08 INFO mapreduce.Job: Job job_1566288518023_0335 completed successfully
19/08/22 15:12:08 INFO mapreduce.Job: Counters: 34
        File System Counters
                FILE: Number of bytes read=0
                FILE: Number of bytes written=801303
                FILE: Number of read operations=0
                FILE: Number of large read operations=0
                FILE: Number of write operations=0
                HDFS: Number of bytes read=2709617
                HDFS: Number of bytes written=0
                HDFS: Number of read operations=6
                HDFS: Number of large read operations=0
                HDFS: Number of write operations=0
                HDFS: Number of bytes read erasure-coded=0
        Job Counters
                Launched map tasks=3
                Data-local map tasks=3
                Total time spent by all maps in occupied slots (ms)=25662
                Total time spent by all reduces in occupied slots (ms)=0
                Total time spent by all map tasks (ms)=25662
                Total vcore-milliseconds taken by all map tasks=25662
                Total megabyte-milliseconds taken by all map tasks=26277888
        Map-Reduce Framework
                Map input records=37635
                Map output records=37635
                Input split bytes=531
                Spilled Records=0
                Failed Shuffles=0
                Merged Map outputs=0
                GC time elapsed (ms)=454
                CPU time spent (ms)=14840
                Physical memory (bytes) snapshot=1287696384
                Virtual memory (bytes) snapshot=8280121344
                Total committed heap usage (bytes)=2418540544
                Peak Map Physical memory (bytes)=439844864
                Peak Map Virtual memory (bytes)=2776657920
        ImportTsv
                Bad Lines=0
        File Input Format Counters
                Bytes Read=2709086
        File Output Format Counters
                Bytes Written=0

我根据密钥创建了多个区域来分发 put,但它没有改变任何东西。

create 'mynamespace:mytable', {NAME => 'data', COMPRESSION => 'SNAPPY'}, {SPLITS => ['0','1','2','3','4','5']}

有人知道如何优化这个操作吗?

谢谢。

【问题讨论】:

    标签: import hbase cloudera bulkinsert


    【解决方案1】:

    我认为您可以做几件事来改善这一点:

    1. 查看您创建表的方式,我可以看到您没有预先定义将服务于该特定表的区域数。假设这是您要填充的新表,HBase 将不得不承担拆分现有区域的额外负载,并且您的导入将花费更长的时间。

    我的建议是通过添加以下内容为您的表格设置区域数:

    NUMREGIONS => "some reasonable number depending on the size of the initial table"

    当我说初始表时,我的意思是容纳您知道要加载到其中的数据量。稍后将逐渐添加的数据在这一点上不一定需要容纳。 (因为您不想让“一半”空区域进程运行)

    1. 我不确定您的密钥的分布有多均匀,通常使用密钥的 md5 散列来使区域服务器之间的条目均匀分布并避免偏差。 这可能是要考虑的另一点,因为您最终可能会遇到单个映射器比其他映射器获得更多负载的情况,因此作业的长度将取决于该单个映射器的执行。所以我会非常小心地使用预分割,除非你真的知道你在做什么。 作为替代方案,我建议您将其用于您的表格,而不是手动预拆分:

    SPLITALGO => 'UniformSplit'

    我还建议你在上面搜索一下。

    我不是很了解你的具体用例,所以我不能给你更深刻的答案,但我相信这些会帮助你提高数据导入表的性能。

    【讨论】:

    • 嘿 Sergey,我已经尝试了几个区域和不同的拆分算法,但没有任何改变。启动 mapreduce 大约需要 12 秒,执行映射和 reduce 需要 12-15 秒
    • 好吧,我想在这种情况下,您将不得不接受启动 map reduce 作业的开销限制,因为在这种规模下,您将无法做出太大的改变:)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多