fdeli 发表于 2015-11-27 19:31:38

flume 安装

  flume下载:http://www.apache.org/dyn/closer.cgi/flume/1.4.0/apache-flume-1.4.0-bin.tar.gz
  flume安装:tar zvxf apache-flume-1.4.0-bin.tar.gz


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

a1.sources = r1
a1.sinks = k1
a1.channels = c1
# Describe/configure the source
a1.sources.r1.type = netcat
a1.sources.r1.bind = localhost
a1.sources.r1.port = 5858
# Describe the sink
a1.sinks.k1.type = logger
# Use a channel which buffers events in memory
a1.channels.c1.type = memory
a1.channels.c1.capacity = 1000
a1.channels.c1.transactionCapacity = 100
# Bind the source and sink to the channel
a1.sources.r1.channels = c1
a1.sinks.k1.channel = c1


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


  


  输出日志:
  

+ 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
2014-04-02 02:08:42,373 (lifecycleSupervisor-1-0) Configuration provider starting
2014-04-02 02:08:42,381 (conf-file-poller-0) Reloading configuration file:conf/flume-conf
2014-04-02 02:08:42,389 (conf-file-poller-0) Added sinks: k1 Agent: a1
2014-04-02 02:08:42,390 (conf-file-poller-0) Processing:k1
2014-04-02 02:08:42,390 (conf-file-poller-0) Processing:k1
2014-04-02 02:08:42,424 (conf-file-poller-0) Post-validation flume configuration contains configuration for agents:
2014-04-02 02:08:42,424 (conf-file-poller-0) Creating channels
2014-04-02 02:08:42,443 (conf-file-poller-0) Creating instance of channel c1 type memory
2014-04-02 02:08:42,451 (conf-file-poller-0) Created channel c1
2014-04-02 02:08:42,454 (conf-file-poller-0) Creating instance of source r1, type netcat
2014-04-02 02:08:42,490 (conf-file-poller-0) Creating instance of sink: k1, type: logger
2014-04-02 02:08:42,505 (conf-file-poller-0) Channel c1 connected to
2014-04-02 02:08:42,531 (conf-file-poller-0) 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}} }
2014-04-02 02:08:42,570 (conf-file-poller-0) Starting Channel c1
2014-04-02 02:08:42,650 (lifecycleSupervisor-1-1) Monitoried counter group for type: CHANNEL, name: c1, registered successfully.
2014-04-02 02:08:42,650 (lifecycleSupervisor-1-1) Component type: CHANNEL, name: c1 started
2014-04-02 02:08:42,653 (conf-file-poller-0) Starting Sink k1
2014-04-02 02:08:42,656 (lifecycleSupervisor-1-1) Source starting
2014-04-02 02:08:42,684 (lifecycleSupervisor-1-1) Created serverSocket:sun.nio.ch.ServerSocketChannelImpl


再打开一个终端,输入“flume success!”:  
  

lz@ubuntu:~$ telnet localhost 5858
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
flume success!
OK
  退出telnet:输入ctrl+]然后 q
  



flume将接收到数据,打印日志:  
  

2014-04-02 02:10:56,707 (SinkRunner-PollingRunner-DefaultSinkProcessor) Event: { headers:{} body: 66 6C 75 6D 65 20 73 75 63 63 65 73 73 21 0D flume success!. }


  
  


  


  
页: [1]
查看完整版本: flume 安装