---
title: "hadoop使用lzo压缩"
author: "samwalt"
date: "2012-04-23T21:38:16Z"
tags: []
categories: ["开源软件"]
slug: "hadoop-lzo"
draft: false
lastmod: "2012-04-23T22:56:30Z"
id: 1494119
url: "https://samwalt.iteye.com/blog/1494119"
---

1、安装lzo开发包 \[code="shell"]sudo apt-get install liblzo2-dev\[/code] 2、安装lzop \[code="shell"]sudo apt-get install lzop\[/code] 3、编译hadoop-lzo.jar 用git在此页面下载源码 \[code="html"]https://github.com/kevinweil/hadoop-lzo\[/code] 编译环境 32位os \[code="shell"]export CFLAGS=-m32 export CXXFLAGS=-m32 ant compile-native tar\[/code] 64位os \[code="shell"]export CFLAGS=-m64 export CXXFLAGS=-m64 ant compile-native tar\[/code] 成功编译后，hadoop-lzo\*.jar在build文件夹中 \[code="shell"] cp hadoop-lzo-0.4.13.jar $HADOOP\_HOME/lib/\[/code] core-site.xml \[code="xml"] io.compression.codecs org.apache.hadoop.io.compress.GzipCodec,org.apache.hadoop.io.compress.DefaultCodec,com.hadoop.compression.lzo.LzoCodec,com.hadoop.compression.lzo.LzopCodec io.compression.codec.lzo.class com.hadoop.compression.lzo.LzoCodec \[/code] 给lzo文件创建索引，例如big\_file.lzo文件 单机上创建索引： \[code="shell"]hadoop jar /path/to/your/hadoop-lzo.jar com.hadoop.compression.lzo.LzoIndexer big\_file.lzo\[/code] 用map-reduce job创建索引： \[code="shell"]hadoop jar /path/to/your/hadoop-lzo.jar com.hadoop.compression.lzo.DistributedLzoIndexer big\_file.lzo\[/code]