Hive中常用的数据压缩snappy
2018-03-19 本文已影响994人
明明德撩码
Hive的数据压缩
压缩格式: bzip2, gzip, lzo, snappy等
压缩比:bzip2>gzip>lzo bzip2最节省存储空间
解压速度:lzo>gzip>bzip2 lzo解压速度是最快的
用的最多的是snappy
检查hadoop支持那些压缩格式
检查命令:[root@hadoop-senior hadoop-2.5.0]# bin/hadoop checknative

下载snappy并安装
编译hadoop 2.x源码

并把native下的文件复制到现在/opt/modules/hadoop-2.5.0/lib/native
再次检查hadoop支持的压缩类型(都为true)

使用snappy前后比较
没有压缩前
bin/yarn jar share/hadoop/mapreduce/hadoop-mapreduce-examples-2.5.0.jar wordcount /user/beifeng/mapreduce/wordcount/input /user/beifeng/mapreduce/wordcount/output0310
![]()
压缩后
bin/yarn jar share/hadoop/mapreduce/hadoop-mapreduce-examples-2.5.0.jar wordcount -Dmapreduce.map.output.compress=true -Dmapreduce.map.output.compress.codec=org.apache.hadoop.io.compress.SnappyCodec /user/beifeng/mapreduce/wordcount/input /user/beifeng/mapreduce/wordcount/output0310
说明:上面加黑的是开启压缩,并配置了压缩类。
![]()