hadoop-cdh with snappy

hadoop: 2.5.0-cdh5.3.6

snappy: 1.1.3

hadoop 2.*不需要hadoop-snappy。只要机器上安装好snappy, 直接编译就可以

编译命令:

mvn clean package -DskipTests -Pdist,native -Dtar -Drequire.snappy -Dbundle.snappy=true -Dsnappy.lib=/home/hadoop/software/snappy/lib -Dsnappy.prefix=/home/hadoop/software/snappy

注意:snappy.lib和snappy.prefix两个选项都需要。如果没有snappy.lib编译会报错。如果没有snappy.prefix,编译能够通过,但是libhadoop.so里,根本没有继承snappy, 运行时还是会报错。我就是在这个问题上花费了很多时间。官文的说法,snappy.prefix会被忽略,根本不是。

  • Use -Dbundle.snappy to copy the contents of the snappy.lib directory into
    the final tar file. This option requires that -Dsnappy.lib is also given,
    and it ignores the -Dsnappy.prefix option. 如果没有snappy.prefix,即使编译成功,libhadoop.so里面根本没有继承snappy

如果是要让现有的hadoop支持snappy, 只需要使用上面的编译命令,编译hadoop-common-project,然后拷贝lib/native下的所有文件到hadoop的lib/native.

很多文章都说需要配置LD_LIBRARY_PATH,我是把所有的包都放到了lib/native里面,并不需要这个配置,因为hadoop默认就是从lib/native目录去读native库的

测试
yarn jar share/hadoop/mapreduce/hadoop-mapreduce-examples-2.5.0-cdh5.3.6.jar wordcount -Dmapreduce.map.output.compress=true -Dmapreduce.map.output.compress.codec=org.apache.hadoop.io.compress.SnappyCodec /user/hadoop/mapreduce/wordcount/input/text /user/hadoop/mapreduce/wordcount/output/o1

posted @ 2016-08-09 18:06  Ivan.Jiang  阅读(905)  评论(0编辑  收藏  举报