0

我正在尝试将集群应用程序中每个节点的输出合并到一个简单、一目了然的位置。我不需要永久存储数据,我只想在同一个位置查看所有标准输出。最终我会想要存储更少的信息,可能使用日志文件,但现在,我只想要 app -> stdOut -> IRC,而 Flume 似乎是一个不错的选择。

我看到的所有使用 exec 源代码的示例都显示了使用 tail 的命令,即使文档使您看起来可以使用任何输出到标准输出的进程。我的配置(见下文)将我的应用程序作为命令运行,但为了进行故障排除,它运行一个简单的 shell 脚本,以设定的时间间隔回显“测试”。

我让一切都在运行,IRC 接收器加入了 IRC 通道,但它从不发送任何消息。日志中的最后一项是 Exec 正在启动。

编辑: 水槽版本flume-ng-1.2.0+24.43-1~squeeze

水槽.config:

agent.sources = exec1
agent.channels = mem1
agent.sinks = irc1
agent.sources.exec1.type = exec
agent.sources.exec1.command = sh /var/lib/app/test.sh
agent.sources.exec1.channels = mem1
agent.sinks.irc1.type = irc
agent.sinks.irc1.hostname = 192.168.17.16
agent.sinks.irc1.nick = flume
agent.sinks.irc1.chan = agents
agent.sinks.irc1.channel = mem1
agent.channels.mem1.type = memory
agent.channels.mem1.capacity = 100

log4j.properties:

flume.root.logger=INFO,LOGFILE
flume.log.dir=/var/log/flume-ng
flume.log.file=flume.log
log4j.logger.org.apache.flume.lifecycle = INFO
log4j.logger.org.jboss = WARN
log4j.logger.org.mortbay = INFO
log4j.logger.org.apache.avro.ipc.NettyTransceiver = WARN
log4j.rootLogger=${flume.root.logger}
log4j.appender.LOGFILE=org.apache.log4j.RollingFileAppender
log4j.appender.LOGFILE.MaxFileSize=100MB
log4j.appender.LOGFILE.MaxBackupIndex=10
log4j.appender.LOGFILE.File=${flume.log.dir}/${flume.log.file}
log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout
log4j.appender.LOGFILE.layout.ConversionPattern=%d{ISO8601} %p %c{2}: %m%n
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.target=System.err
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%d (%t) [%p - %l] %m%n

测试.sh:

#!/bin/bash
x=1
while [ $x -ge 1 ]
do
  echo "Test $x"
  x=$(( $x + 1 ))
  sleep 5
done

水槽.日志:

2013-01-31 12:45:08,184 INFO nodemanager.DefaultLogicalNodeManager: Node manager starting
2013-01-31 12:45:08,184 INFO properties.PropertiesFileConfigurationProvider: Configuration provider starting
2013-01-31 12:45:08,184 INFO lifecycle.LifecycleSupervisor: Starting lifecycle supervisor 9
2013-01-31 12:45:08,186 INFO properties.PropertiesFileConfigurationProvider: Reloading configuration file:/etc/flume-ng/conf/flume.conf
2013-01-31 12:45:08,194 INFO conf.FlumeConfiguration: Processing:irc1
2013-01-31 12:45:08,194 INFO conf.FlumeConfiguration: Added sinks: irc1 Agent: agent
2013-01-31 12:45:08,194 INFO conf.FlumeConfiguration: Processing:irc1
2013-01-31 12:45:08,194 INFO conf.FlumeConfiguration: Processing:irc1
2013-01-31 12:45:08,194 INFO conf.FlumeConfiguration: Processing:irc1
2013-01-31 12:45:08,194 INFO conf.FlumeConfiguration: Processing:irc1
2013-01-31 12:45:08,207 INFO conf.FlumeConfiguration: Post-validation flume configuration contains configuration  for agents: [agent]
2013-01-31 12:45:08,208 INFO properties.PropertiesFileConfigurationProvider: Creating channels
2013-01-31 12:45:08,249 INFO instrumentation.MonitoredCounterGroup: Monitoried counter group for type: CHANNEL, name: mem1, registered successfully.
2013-01-31 12:45:08,249 INFO properties.PropertiesFileConfigurationProvider: created channel mem1
2013-01-31 12:45:08,262 INFO sink.DefaultSinkFactory: Creating instance of sink: irc1, type: irc
2013-01-31 12:45:08,266 INFO nodemanager.DefaultLogicalNodeManager: Starting new configuration:{ sourceRunners:{exec1=EventDrivenSourceRunner: { source:org.apache.flume.source.ExecSource@498665a0 }} sinkRunners:{irc1=SinkRunner: { policy:org.apache.flume.sink.DefaultSinkProcessor@167a1116 counterGroup:{ name:null counters:{} } }} channels:{mem1=org.apache.flume.channel.MemoryChannel@27f7c6e1} }
2013-01-31 12:45:08,266 INFO nodemanager.DefaultLogicalNodeManager: Starting Channel mem1
2013-01-31 12:45:08,266 INFO instrumentation.MonitoredCounterGroup: Component type: CHANNEL, name: mem1 started
2013-01-31 12:45:08,266 INFO nodemanager.DefaultLogicalNodeManager: Starting Sink irc1
2013-01-31 12:45:08,267 INFO irc.IRCSink: IRC sink starting
2013-01-31 12:45:08,267 INFO nodemanager.DefaultLogicalNodeManager: Starting Source exec1
2013-01-31 12:45:08,267 INFO source.ExecSource: Exec source starting with command:sh /var/lib/app/test.sh

编辑批量大小似乎是问题所在,因为它一直等到 20 条消息(默认?),在我看到任何输出之前是 100 秒。现在使用 batchsize = 1,标准记录器输出结果,但 IRC 抱怨 NullPointerException,可能是因为 Event.body 不知何故为空?

4

1 回答 1

0

IRC 接收器的文档(在此处找到:Flume 1.x 用户指南)说不需要配置分割线是错误的。它在代码中没有默认值,因此您必须对其进行配置。

查看源代码(在此处找到:IRCSink.java),您还必须指定“splitlines”或遭受 NullPointerException。有处理“splitchars”为空的代码,但不是分割线。报告为FLUME-1892编辑:这张票已在一月份解决。这应该不再是问题。)

于 2013-01-31T22:54:10.307 回答