Hadoop集⼩⽂件合并
Hadoop集运⾏⼀段时间后⼩⽂件越来越多,namenode不堪重负,不仅GC越来越频繁,还会偶尔挂掉
Hadoop集⼤部分⽂件都来源于数仓,由于数仓未对相关配置进⾏优化,所以才会产⽣很多⼩⽂件
为了解决⼩⽂件问题:
优化hive参数
开发⼯具合并集现有⼩⽂件
扫描-d指定库中的表,查看表每个分区的⼩⽂件情况,如果⽂件多于-fs指定的⽂件个数则进⾏合并(不指定fs参数则fs值是
Math.max(1,分区⽬录totalFile Size/hdfsBlockSize);
合并引擎使⽤spark thrfit server。虽然实现⽐较简单,但是能真正解决⼩⽂件问题,如果觉得对你有帮助,⿇烦给个星
说明:
Usage: htool -d <database> [options]
-d,--database                specify database to merge
-dp,--dataPath <arg>        store the metadata of merged data.the dpath
is required, when the -i option are specified
-fs,--files <arg>            how many files will merged into
-i,--incremental            incremental merge data (是否增量合并,如果开启增量合并则会在-dp指定的⽬录中记录已合并库:表:分区,下次运⾏任务是会⾃动跳过已合-m,--parallel <n>            use 'n' tasks to merge in parallel
-p,--password <arg>          jdbc connection password
-r,--part <arg>              set partition to merge
-sts,--thriftserver <arg>    specify JDBC connect string of spark thrift
server
-t,--table <arg>            specify table to merge.if it is not set,htool
will use all table in the database
-u,--user <arg>              jdbc connection user
-x,--min-profit <n>          min-profit,default 1(收益值,只合并当前分区⽂件个数-fs⼤于此值的分区)
thrift
附上合并前后对⽐:
合并前:
合并2天后:

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。