问题
使用hdfs作为sinks时报错信息如下:
2021-08-24 15:10:11,638 INFO avro.ReliableSpoolingFileEventReader:
Preparing to move file /tmp/logs/log.txt to /tmp/logs/log.txt.COMPLETED
2021-08-24 15:10:15,199 INFO hdfs.HDFSDataStream:
Serializer = TEXT, UseRawLocalFileSystem = false
2021-08-24 15:10:15,240 ERROR hdfs.HDFSEventSink: process failed
# 删除一些无用的报错信息
Exception in thread "SinkRunner-PollingRunner-DefaultSinkProcessor"
java.lang.NoSuchMethodError: com.google.common.base.
Preconditions.checkArgument(ZLjava/lang/String;Ljava/lang/Object;)V
at org.apache.hadoop.conf.Configuration.set(Configuration.java:1357)
at org.apache.flume.sink.
DefaultSinkProcessor.process(DefaultSinkProcessor.java:67)
at org.apache.flume.SinkRunner$PollingRunner.run(SinkRunner.java:145)
at java.lang.Thread.run(Thread.java:748)
解决
问题出在 NoSuchMethodError,但是这个类在哪个jar文件里,这是个问题!!!这种问题只能求助无私的分享者《线索一》《Hive文件上传HDFS出错》:
# 查询guava的版本
[root@tcloud ~]# find /usr/local/hadoop-3.1.3/ -name '*guava-*'
/usr/local/hadoop-3.1.3/share/hadoop/hdfs/lib/guava-27.0-jre.jar
/usr/local/hadoop-3.1.3/share/hadoop/common/lib/guava-27.0-jre.jar
[root@tcloud ~]# find /usr/local/flume/ -name '*guava-*'
/usr/local/flume/lib/guava-11.0.2.jar
# 删掉flume的低版本guava-11.0.2.jar【先做备份】
[root@tcloud ~]# rm /usr/local/flume/lib/guava-11.0.2.jar
# 复制${HADOOP_HOME}/share/hadoop/common/lib/guava-27.0-jre.jar到/usr/local/flume/lib/
[root@tcloud ~]# cp /usr/local/hadoop-3.1.3/share/hadoop/common/lib/guava-27.0-jre.jar/usr/local/flume/lib/
[root@tcloud ~]# find /usr/local/flume/ -name '*guava-*'
/usr/local/flume/lib/guava-27.0-jre.jar
测试成功了!感谢无私的程序员朋友!👍 👍 👍