解决 使用Snappy 压缩方式报错“java.lang.UnsatisfiedLinkError: no snappyjava in java.library.path”
,将libsnappyjava.so文件放到$JAVA_HOME/jre/lib/amd64/下了 操作过程如下: 首先把$HADOOP_HOME/share/hadoop/common/lib/snappy-java-1.1.1.7.jar copy到临时目录下,然后unzip snappy-java-1.1.1.7.jar 解压后会有如下目录: 4096 Aug 31 15:58 META-INF
4096 Apr 14 16:05 org 进入libsnappyjava.so所在目录: $cd org/xerial/snappy/native/Linux/x86_64/ 就可以看到如下文件: libsnappyjava.so
copy 到$JAVA_HOME/jre/lib/amd64/ 测试程序如下: [mw_shl_code=bash,true]import org.xerial.snappy.Snappy;
/**
* * Created by stark_summer on 15/8/8.
* */
public class TestSnappy {
public static void main(String[] args) throws Exception{
String input = "Hello snappy-java! Snappy-java is a JNI-based wrapper of "
+ "Snappy, a fast compresser/decompresser.";
byte[] compressed = Snappy.compress(input.getBytes("UTF-8"));
byte[] uncompressed = Snappy.uncompress(compressed);
String result = new String(uncompressed, "UTF-8");
System.out.println(result);
}
}
[/mw_shl_code]
编译:javac -classpath ./snappy-java-1.1.1.7.jar TestSnappy.java执行:java TestSnappy 执行结果:
Hello snappy-java! Snappy-java is a JNI-based wrapper of Snappy, a fast compresser/decompresser.
将“libsnappyjava.so”文件copy到 hadoop集群:$JAVA_HOME/jre/lib/amd64/下,hive on hadoop,使用snappy方式压缩不在报错,搞定了 将SPARK_HOME/conf/spark-defaults.conf spark.io.compression.codec lzf 注释或者去掉这行,spark将使用默认snappy压缩方式,也不再报错了
PS: 目前用最笨的方式解决了,但还是要进一步排查此问题
|