由于HDFS sink文件压缩在flume中存在问题(请参考https://blog.csdn.net/weixin_34874025/article/details/86441770 ),解决方案是配置hadoop执行环境使其load native lib。

flume env设置

  1. flume版本:1.9.0
  2. 从hadoop中native lib和jar至flume所在目录中
  3. 配置flume-env.sh
    export JAVA_LIBRARY_PATH=$JAVA_LIBRARY_PATH:$FLUME_HOME/plugins.d/hadoop/native
    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$FLUME_HOME/plugins.d/hadoop/native

根据类名查找缺失的jar包

针对java.lang.NoClassDefFoundError异常,使用java的解包命令jar,结合shell脚本查找缺失的类所在jar包。

#!/bin/bash

cd $HADOOP_HOME
for jar in `find ./ *.jar | grep jar`
do
    result=`jar -tf $jar | grep InfSecException`
    if [ -n "$result" ];then
        echo $jar
    fi
done