一体化监控管理平台解决方案,一体化监控管理平台的应用范围
787
2022-10-13
Hadoop支持Lzo压缩配置及案例
hadoop支持Lzo压缩配置
1)hadoop本身并不支持lzo压缩,故需要使用twitter提供的hadoop-lzo开源组件。hadoop-lzo需依赖hadoop和lzo进行编译,编译步骤如下。2)将编译好后的hadoop-lzo-0.4.20.jar 放入hadoop-2.7.2/share/hadoop/common/
[atguigu@hadoop102 common]$ pwd/opt/module/hadoop-2.7.2/share/hadoop/common[atguigu@hadoop102 common]$ lshadoop-lzo-0.4.20.jar
3)同步hadoop-lzo-0.4.20.jar到hadoop103、hadoop104
[atguigu@hadoop102 common]$ xsync hadoop-lzo-0.4.20.jar
4)core-site.xml增加配置支持LZO压缩
5)同步core-site.xml到hadoop103、hadoop104
[atguigu@hadoop102 hadoop]$ xsync core-site.xml
6)启动及查看集群
[atguigu@hadoop102 hadoop-2.7.2]$ sbin/start-dfs.sh[atguigu@hadoop103 hadoop-2.7.2]$ sbin/start-yarn.sh
7)创建lzo文件的索引,lzo压缩文件的可切片特性依赖于其索引,故我们需要手动为lzo压缩文件创建索引。若无索引,则lzo文件的切片只有一个。
hadoop jar /path/to/your/hadoop-lzo.jar big_file.lzo
案例:以hadoop自带的wordcount为例mr输出结果为lzo格式1.创建word.txt文件,并写上几个单词上传到hdfs上[atguigu@hadoop202 bin]$ vim word.txt[atguigu@hadoop202 bin]$ hdfs dfs -put word.txt input2.运行wordcount案例
[atguigu@hadoop202 bin]$ hadoop jar /opt/module/hadoop-2.7.2/share/hadoop/mapreduce/hadoop-mapreduce-examples-2.7.2.jar wordcount -D mapreduce.output.fileoutputformat.compress=true -D maputformat.compress.codec=com.hadoop.compression.lzo.LzopCodec /input /output
[atguigu@hadoop202 bin]$ hadoop jar /opt/module/hadoop-2.7.2/share/hadoop/common/hadoop-lzo-0.4.20.jar com.hadoop.compression.lzo.DistributedLzoIndexer /output/part-r-00000.lzo
此时hdfs上会产生带有索引的lzo文件。
发表评论
暂时没有评论,来抢沙发吧~