Class path contains multiple SLF4J bindings.

启动 Flume 时,会看到如下内容:

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/flume-1.9.0/lib/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/hadoop-2.7.7/share/hadoop/common/lib/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]

错误内容:

启动 Flume 时,找到了多个 SLF4J bindings(绑定),SLF4J 如同 log4j 一样,是打印日志的工具。

Found binding in...,在加载 jar 包时,找到了两个本版本不同的 SLF4J,导致了程序出错。

错误原因:

启动 Flume 时,在 /flume-1.9.0 目录下找到了 SLF4J,又在 /hadoop-2.7.7 目录下找到了 SLF4J。

由于 Flume 是 Hadoop 生态的一个日志采集工具,所以当启动 Flume 后,Flume 就会去加载 Hadoop_HOME 中的类,所以启动时可以看到加载了许多 Hadoop 下的包,当 SLF4J 时,在 Flume 自己目录下也有 SLF4J,就导致了类的冲突,而且版本不一样。

解决办法:

在提示中的路径下,对 Flume 的 SLF4J 删除或重命名。

比如:将该 jar 包重命名为 .jar.bak 结尾的文件,bak 表示 backup(备份)。

mv /opt/flume-1.9.0/lib/slf4j-log4j12-1.7.25.jar /opt/flume-1.9.0/lib/slf4j-log4j12-1.7.25.jar.bak

重启 Flume就没有该错误了。

更多推荐