Elephant Bird インストールメモ

pigの出力結果を圧縮した状態で出力するテストのために導入

環境

CentOS 5.7 64bit
JDK 6u30 64bit
Apache Ant 1.8.2
Hadoop 0.20.2-cdh3u3
Pig 0.8.1-cdh3u3
Hadoop-LZO 0.4.15

thrift(version 0.5.0 指定) インストール

yum install php-devel python-devel
wget http://archive.apache.org/dist/incubator/thrift/0.5.0-incubating/thrift-0.5.0.tar.gz -P /home/src/archives
tar zxvfC archives/thrift-0.5.0.tar.gz /home/src
cd /home/src/thrift-0.5.0
./configure
make
make install

Protocol Buffer(version 2.3.0 指定) インストール

wget http://protobuf.googlecode.com/files/protobuf-2.3.0.tar.gz -P /home/src/archives
tar zxvfC archives/protobuf-2.3.0.tar.gz /home/src
cd /home/src/protobuf-2.3.0
./configure
make
make install

Elephant Bird ビルド

wget --no-check-certificate https://github.com/kevinweil/elephant-bird/tarball/v2.1.3 -P /home/src/archives -O elephant-bird-v2.1.3.tar.gz
tar zxvfC archives/elephant-bird-v2.1.3.tar.gz /home/src
cd /home/src/kevinweil-elephant-bird-8594985
ant release-jar

できた jar ファイルを適当なところにコピー

cp /home/src/kevinweil-elephant-bird-8594985/dist/elephant-bird-2.1.3.jar /usr/local/hadoop/lib/

テスト

$ echo -e "test\nasdf\nghjk" > test.txt
$ hadoop fs -put test.txt .
$ pig
grunt> ls test.txt
hdfs://hadoop-nn01:9000/user/hadoop/test.txt<r 1>       15
grunt> register /usr/local/hadoop/lib/hadoop-lzo-0.4.15.jar
grunt> register /usr/local/hadoop/lib/elephant-bird-2.1.3.jar
grunt> A = load 'test.txt' using TextLoader();
grunt> B = FILTER A BY $0 MATCHES 'test';
grunt> store B into 'test.txt.lzo' using com.twitter.elephantbird.pig.store.LzoPigStorage();
grunt> ls test.txt.lzo
hdfs://hadoop-nn01:9000/user/hadoop/test.txt.lzo/_logs  <dir>
hdfs://hadoop-nn01:9000/user/hadoop/test.txt.lzo/part-m-00000.lzo<r 1>  55
grunt> quit
$ hadoop fs -get test.txt.lzo/part-m-00000.lzo .
$ echo `lzop -dc part-m-00000.lzo`
test