因缺失log4j.properties 配置文件导致flume无法正常启动
作者:尹正杰
版权声明:原创作品,谢绝转载!否则将追究法律责任。
一.报错:log4j:WARN No appenders could be found for logger (org.apache.flume.lifecycle.LifecycleSupervisor).
[root@flume120 ~]# cat /yinzhengjie/data/flume/job/flume-telnet.conf # 这里的“yinzhengjie”是agent的名称,它是我们自定义的。我们分别给“yinzhengjie”的sources,sinks,channels的别名分别为r1,k1和c1。 yinzhengjie.sources = r1 yinzhengjie.sinks = k1 yinzhengjie.channels = c1 # 指定source的类型为netcat(source的type有很多,咱们不用记住它,需要用的时候去官网查就好),绑定source的主机是“node106.yinzhengjie.org.cn”,绑 定的端口为“8888” yinzhengjie.sources.r1.type = netcat yinzhengjie.sources.r1.bind = flume120.aggrx yinzhengjie.sources.r1.port = 8888 # 指定sink的类型,我们这里指定的为logger,即控制台输出。 yinzhengjie.sinks.k1.type = logger # 指定channel的类型为memory,指定channel的容量是1000,每次传输的容量是100 yinzhengjie.channels.c1.type = memory yinzhengjie.channels.c1.capacity = 1000 yinzhengjie.channels.c1.transactionCapacity = 100 # 绑定source和sink yinzhengjie.sources.r1.channels = c1 yinzhengjie.sinks.k1.channel = c1 [root@flume120 ~]#
[root@flume120 ~]# ll /yinzhengjie/data/flume/job/ total 4 -rw-r--r-- 1 root root 1003 Oct 16 20:10 flume-telnet.conf [root@flume120 ~]# [root@flume120 ~]# flume-ng agent -c /yinzhengjie/data/flume/job/ --conf-file=/yinzhengjie/data/flume/job/flume-telnet.conf -name yinzhengjie -Dflume.root.logger=INFO,console Warning: JAVA_HOME is not set! Info: Including Hive libraries found via () for Hive access + exec /soft/jdk/bin/java -Xmx20m -Dflume.root.logger=INFO,console -cp '/yinzhengjie/data/flume/job:/soft/flume/lib/*:/lib/*' -Djava.library.path= org.apache.flume.node.Application --conf-file=/yinzhengjie/data/flume/job/flume-telnet.conf -name yinzhengjie log4j:WARN No appenders could be found for logger (org.apache.flume.lifecycle.LifecycleSupervisor). log4j:WARN Please initialize the log4j system properly. log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
上面也告诉你解决方案啦,就是让你初始化:“log4j”这个配置文件。解决方案就是将你安装的flume软件conf目录中的“log4j.properties”文件拷贝到我们上面使用“--conf”指定到路径:“/yinzhengjie/data/flume/job/”
[root@flume120 ~]# ll /yinzhengjie/data/flume/job/ total 4 -rw-r--r-- 1 root root 1003 Oct 16 20:10 flume-telnet.conf [root@flume120 ~]# [root@flume120 ~]# cp /soft/apache-flume-1.7.0-bin/conf/log4j.properties /yinzhengjie/data/flume/job/ #将log4j.properties文件拷贝过来。 [root@flume120 ~]# [root@flume120 ~]# ll /yinzhengjie/data/flume/job/ total 8 -rw-r--r-- 1 root root 1003 Oct 16 20:10 flume-telnet.conf -rw-r--r-- 1 root root 3107 Oct 16 20:15 log4j.properties [root@flume120 ~]#
执行以上操作后,服务可以正常启动啦。