分享

flume 简单安装

nettman 2014-5-29 17:42:36 发表于 安装配置 [显示全部楼层] 回帖奖励 阅读模式 关闭右栏 0 13856
本帖最后由 nettman 于 2014-5-29 18:01 编辑
问题导读:
此文章适合新手尝试安装简单flume,可以作为一种常识和了解
1.如何下载flume?
2.flume配置文件该如何修改?
3.telnet localhost 5858 的作用是什么?






一、flume下载:下载地址
http://www.apache.org/dyn/closer ... me-1.4.0-bin.tar.gz

二、flume安装:
tar zvxf apache-flume-1.4.0-bin.tar.gz

三、修改配置文件

修改conf/flume-conf.properties.template文件名为flume-conf
修改文件内容:

  1. a1.sources = r1  
  2. a1.sinks = k1  
  3. a1.channels = c1  
  4.   
  5. # Describe/configure the source  
  6. a1.sources.r1.type = netcat  
  7. a1.sources.r1.bind = localhost  
  8. a1.sources.r1.port = 5858  
  9.   
  10. # Describe the sink  
  11. a1.sinks.k1.type = logger  
  12.   
  13. # Use a channel which buffers events in memory  
  14. a1.channels.c1.type = memory  
  15. a1.channels.c1.capacity = 1000  
  16. a1.channels.c1.transactionCapacity = 100  
  17.   
  18. # Bind the source and sink to the channel  
  19. a1.sources.r1.channels = c1  
  20. a1.sinks.k1.channel = c1  
复制代码


四启动服务:
bin/flume-ng agent --conf conf --conf-file conf/flume-conf --name a1 -Dflume.root.logger=INFO,console

输出日志:
  1. + exec /etc/local/jdk1.6.0_37/bin/java -Xmx20m -Dflume.root.logger=INFO,console -cp '/usr/local/apache-flume-1.4.0-bin/conf:/usr/local/apache-flume-1.4.0-bin/lib/*' -Djava.library.path= org.apache.flume.node.Application --conf-file conf/flume-conf --name a1  
  2. 2014-04-02 02:08:42,373 (lifecycleSupervisor-1-0) [INFO - org.apache.flume.node.PollingPropertiesFileConfigurationProvider.start(PollingPropertiesFileConfigurationProvider.java:61)] Configuration provider starting  
  3. 2014-04-02 02:08:42,381 (conf-file-poller-0) [INFO - org.apache.flume.node.PollingPropertiesFileConfigurationProvider$FileWatcherRunnable.run(PollingPropertiesFileConfigurationProvider.java:133)] Reloading configuration file:conf/flume-conf  
  4. 2014-04-02 02:08:42,389 (conf-file-poller-0) [INFO - org.apache.flume.conf.FlumeConfiguration$AgentConfiguration.addProperty(FlumeConfiguration.java:930)] Added sinks: k1 Agent: a1  
  5. 2014-04-02 02:08:42,390 (conf-file-poller-0) [INFO - org.apache.flume.conf.FlumeConfiguration$AgentConfiguration.addProperty(FlumeConfiguration.java:1016)] Processing:k1  
  6. 2014-04-02 02:08:42,390 (conf-file-poller-0) [INFO - org.apache.flume.conf.FlumeConfiguration$AgentConfiguration.addProperty(FlumeConfiguration.java:1016)] Processing:k1  
  7. 2014-04-02 02:08:42,424 (conf-file-poller-0) [INFO - org.apache.flume.conf.FlumeConfiguration.validateConfiguration(FlumeConfiguration.java:140)] Post-validation flume configuration contains configuration for agents: [a1]  
  8. 2014-04-02 02:08:42,424 (conf-file-poller-0) [INFO - org.apache.flume.node.AbstractConfigurationProvider.loadChannels(AbstractConfigurationProvider.java:150)] Creating channels  
  9. 2014-04-02 02:08:42,443 (conf-file-poller-0) [INFO - org.apache.flume.channel.DefaultChannelFactory.create(DefaultChannelFactory.java:40)] Creating instance of channel c1 type memory  
  10. 2014-04-02 02:08:42,451 (conf-file-poller-0) [INFO - org.apache.flume.node.AbstractConfigurationProvider.loadChannels(AbstractConfigurationProvider.java:205)] Created channel c1  
  11. 2014-04-02 02:08:42,454 (conf-file-poller-0) [INFO - org.apache.flume.source.DefaultSourceFactory.create(DefaultSourceFactory.java:39)] Creating instance of source r1, type netcat  
  12. 2014-04-02 02:08:42,490 (conf-file-poller-0) [INFO - org.apache.flume.sink.DefaultSinkFactory.create(DefaultSinkFactory.java:40)] Creating instance of sink: k1, type: logger  
  13. 2014-04-02 02:08:42,505 (conf-file-poller-0) [INFO - org.apache.flume.node.AbstractConfigurationProvider.getConfiguration(AbstractConfigurationProvider.java:119)] Channel c1 connected to [r1, k1]  
  14. 2014-04-02 02:08:42,531 (conf-file-poller-0) [INFO - org.apache.flume.node.Application.startAllComponents(Application.java:138)] Starting new configuration:{ sourceRunners:{r1=EventDrivenSourceRunner: { source:org.apache.flume.source.NetcatSource{name:r1,state:IDLE} }} sinkRunners:{k1=SinkRunner: { policy:org.apache.flume.sink.DefaultSinkProcessor@380e28b9 counterGroup:{ name:null counters:{} } }} channels:{c1=org.apache.flume.channel.MemoryChannel{name: c1}} }  
  15. 2014-04-02 02:08:42,570 (conf-file-poller-0) [INFO - org.apache.flume.node.Application.startAllComponents(Application.java:145)] Starting Channel c1  
  16. 2014-04-02 02:08:42,650 (lifecycleSupervisor-1-1) [INFO - org.apache.flume.instrumentation.MonitoredCounterGroup.register(MonitoredCounterGroup.java:110)] Monitoried counter group for type: CHANNEL, name: c1, registered successfully.  
  17. 2014-04-02 02:08:42,650 (lifecycleSupervisor-1-1) [INFO - org.apache.flume.instrumentation.MonitoredCounterGroup.start(MonitoredCounterGroup.java:94)] Component type: CHANNEL, name: c1 started  
  18. 2014-04-02 02:08:42,653 (conf-file-poller-0) [INFO - org.apache.flume.node.Application.startAllComponents(Application.java:173)] Starting Sink k1  
  19. 2014-04-02 02:08:42,656 (lifecycleSupervisor-1-1) [INFO - org.apache.flume.source.NetcatSource.start(NetcatSource.java:150)] Source starting  
  20. 2014-04-02 02:08:42,684 (lifecycleSupervisor-1-1) [INFO - org.apache.flume.source.NetcatSource.start(NetcatSource.java:164)] Created serverSocket:sun.nio.ch.ServerSocketChannelImpl[/127.0.0.1:5858]  
复制代码
再打开一个终端,输入“flume success!”:


  1. lz@ubuntu:~$ telnet localhost 5858  
  2. Trying 127.0.0.1...  
  3. Connected to localhost.  
  4. Escape character is '^]'.  
  5. flume success!  
  6. OK  
复制代码


退出telnet:  输入ctrl+]  然后 q

flume将接收到数据,打印日志:
2014-04-02 02:10:56,707 (SinkRunner-PollingRunner-DefaultSinkProcessor) [INFO - org.apache.flume.sink.LoggerSink.process(LoggerSink.java:70)] Event: { headers:{} body: 66 6C 75 6D 65 20 73 75 63 63 65 73 73 21 0D flume success!. }  

看完此篇,推荐与另外一篇进行对比Kafka与FlumeNG整合实践









加微信w3aboutyun,可拉入技术爱好者群

没找到任何评论,期待你打破沉寂

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关闭

推荐上一条 /2 下一条