学习地址:
(重要)http://os.51cto.com/art/201104/256669.htm
(重要)http://heipark.iteye.com/blog/1172759
http://blog.chinaunix.net/space.php?uid=1838361&do=blog&id=2982485
ant下载:
http://mirror.bjtu.edu.cn/apache/ant/binaries/
lzo的下载:
http://www.oberhumer.com/opensource/lzo/download/
1.ant安装
http://mirror.bjtu.edu.cn/apache/ant/binaries/
tar jxvf apache-ant-1.8.2-bin.tar.bz2
[root@localhost apache-ant-1.8.2]# vi /etc/profile
添加ant的环境变量:
vi /etc/profile
export ANT_HOME=/usr/local/apache-ant-1.8.2
export PATH=$PATH:$ANT_HOME/bin
source /etc/profile
2.lzo-2.06.tar.gz的安装:lzo的下载:
http://www.oberhumer.com/opensource/lzo/download/
[root@localhost soft]# tar zxvf lzo-2.06.tar.gz
[root@localhost soft]# cd lzo-2.06
[root@localhost lzo-2.06]# ./configure --enable-shared
[root@localhost lzo-2.06]# make
[root@localhost lzo-2.06]# make install
#编辑/etc/ld.so.conf,加入/usr/local/lib/后,执行/sbin/ldconfig
或者cp /usr/local/lib/liblzo2.* /usr/lib64/
#如果没有这一步,最终会导致以下错误:
lzo.LzoCompressor: java.lang.UnsatisfiedLinkError: Cannot load liblzo2.so.2 (liblzo2.so.2: cannot open shared object file: No such file or directory)!
3、安装 lzo编码/解码器(hadoop-lzo)的安装(重要):
(1)解压并安装 下载地址:https://github.com/kevinweil/hadoop-lzo
[root@localhost soft]# tar zxvf kevinweil-hadoop-lzo-2dd49ec.tar.gz
[root@localhost soft]# cd kevinweil-hadoop-lzo-2dd49ec
[root@localhost kevinweil-hadoop-lzo-2dd49ec]# ant compile-native tar
# 32位OS
export JAVA_HOME=/path/to/32bit/jdk
export CFLAGS=-m32
export CXXFLAGS=-m32
ant compile-native
# 64位OS
export JAVA_HOME=/path/to/64bit/jdk
export CFLAGS=-m64
export CXXFLAGS=-m64
ant compile-native tar
成功编译后,打开build文件夹,hadoop-lzo*.jar就躺在里面。
如果出错,请参考: http://os.51cto.com/art/201104/256669.htm
(2)复制 hadoop-lzo-0.4.14.jar 到 $HADOOP_HOME/lib 下,我这里是/home/dbrg/soft/hadoop-0.20.2/lib下,并用chown修改对应的所有者。
[root@localhost kevinweil-hadoop-lzo-2dd49ec]# cd build
[root@localhost build]# cp hadoop-lzo-0.4.14.jar /home/dbrg/soft/hadoop-0.20.2/lib
(3)将lzo本地库,复制到$HADOOP_HOME下,即
[root@localhost kevinweil-hadoop-lzo-2dd49ec]# cp -r build /home/dbrg/soft/hadoop-0.20.2/
上面这一步是 为了让JNI找到库文件需要配置JAVA_LIBRARY_PATH。 bin/hadoop的命令会自动加载这个路径。
因为经常会报 "java.lang.RuntimeException: native-lzo library not available" 的错误,上面这一步就是最简单的解决方法。
(4)配置lzo:
(1)编辑core-site.xml文件:即vi core-site.xml
<property>
<name>io.compression.codecs</name>
<value>org.apache.hadoop.io.compress.DefaultCodec,org.apache.hadoop.io.compress.GzipCodec,org.apache.hadoop.io.compress.BZip2Codec,com.hadoop.compression.lzo.LzopCodec</value>
</property>
<property>
<name>io.compression.codec.lzo.class</name>
<value>com.hadoop.compression.lzo.LzoCodec</value>
</property>
(2)编辑mapred-site.xml文件, 即:vi mapred-site.xml
<property>
<name>mapreduce.map.output.compress</name>
<value>true</value>
</property>
<property>
<name>mapreduce.map.output.compress.codec</name>
<value>com.hadoop.compression.lzo.LzoCodec</value>
</property>
错误:安装:kevinweil-hadoop-lzo-2dd49ec.tar.gz 出错:解决: 是由于系统时间问题。用date命令设置新的时间就行。
[javadoc] /Application/soft/kevinweil-hadoop-lzo-2dd49ec/src/java/com/hadoop/compression/lzo/LzoIndexer.java:51: warning - @param argument "lzoUri" is not a parameter name.
compile-java:
[exec] checking whether build environment is sane...
[exec] configure: error: newly created file is older than distributed files!
[exec] Check your system clock
BUILD FAILED
/Application/soft/kevinweil-hadoop-lzo-2dd49ec/build.xml:247: exec returned: 1
Total time: 8 seconds
(4) lzop的下载地址:
http://www.lzop.org/download/
[root@localhost lzop-1.03]# export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
[root@localhost lzop-1.03]# ./configure
[root@localhost lzop-1.03]# make
[root@localhost lzop-1.03]# make install
查看是否安装成功。
[dbrg@localhost lzop-1.03]$ lzop