1、下载1.5.2版本flume地址:
http://archive.apache.org/dist/flume/1.5.2/
官网下载地址:
http://flume.apache.org/download.html
[root@baozi local]# cd apache-flume-1.5.2-bin
[root@baozi apache-flume-1.5.2-bin]# ll
总用量 128
drwxr-xr-x. 2 501 games 4096 6月 21 11:19 bin
-rw-r--r--. 1 501 games 62228 11月 13 2014 CHANGELOG
drwxr-xr-x. 2 501 games 4096 6月 21 11:19 conf
-rw-r--r--. 1 501 games 6172 11月 13 2014 DEVNOTES
drwxr-xr-x. 10 501 games 4096 11月 13 2014 docs
drwxr-xr-x. 2 root root 4096 6月 21 11:19 lib
-rw-r--r--. 1 501 games 22517 11月 13 2014 LICENSE
-rw-r--r--. 1 501 games 249 11月 13 2014 NOTICE
-rw-r--r--. 1 501 games 1779 11月 13 2014 README
-rw-r--r--. 1 501 games 1586 11月 13 2014 RELEASE-NOTES
drwxr-xr-x. 2 root root 4096 6月 21 11:19 tools
[root@baozi apache-flume-1.5.2-bin]# ll conf
总用量 12
-rw-r--r--. 1 501 games 1661 11月 13 2014 flume-conf.properties.template
-rw-r--r--. 1 501 games 1197 11月 13 2014 flume-env.sh.template
-rw-r--r--. 1 501 games 3063 11月 13 2014 log4j.properties
2、把flume-env.sh.template拷贝一份,重命名为flume-env.sh:
[root@baozi apache-flume-1.5.2-bin]# cp conf/flume-env.sh.template conf/flume-env.sh
[root@baozi apache-flume-1.5.2-bin]#
3、编辑flume-env.sh文件:
[root@baozi apache-flume-1.5.2-bin]# vim conf/flume-env.sh
JAVA_HOME=/usr/local/jdk
4、编辑文件并命名为agent1.conf:
[root@baozi apache-flume-1.5.2-bin]# vim conf/agent1.conf
agent1.sources = as1
agent1.channels = c1
agent1.sinks = s1
# 定义source
agent1.sources.as1.type = avro
agent1.sources.as1.bind = 0.0.0.0
agent1.sources.as1.port = 41414
agent1.sources.as1.channels = c1
# 定义channel
agent1.channels.c1.type = memory
# 定义sink
agent1.sinks.s1.channel = c1
agent1.sinks.s1.type = logger
5、查看flume版本:
[root@baozi apache-flume-1.5.2-bin]# bin/flume-ng version
Flume 1.5.2
Source code repository: https://git-wip-us.apache.org/repos/asf/flume.git
Revision: 229442aa6835ee0faa17e3034bcab42754c460f5
Compiled by hshreedharan on Wed Nov 12 12:51:22 PST 2014
From source with checksum 837f81bd1e304a65fcaf8e5f692b3f18
[root@baozi apache-flume-1.5.2-bin]#
6、启动flume:
[root@baozi apache-flume-1.5.2-bin]# bin/flume-ng agent --conf conf/ -f conf/agent1.conf -n agent1 -Dflume.root.logger=DEBUG,console
[root@baozi apache-flume-1.5.2-bin]# jps
18645 Application
19708 Jps
[root@baozi apache-flume-1.5.2-bin]#
编辑文件log.0000:
[root@baozi apache-flume-1.5.2-bin]# vim log.0000
[root@baozi apache-flume-1.5.2-bin]# more log.0000
hello world
7、启动客户端:
[root@baozi apache-flume-1.5.2-bin]# bin/flume-ng avro-client --conf conf/ -H 192.168.1.200 -p 41414 -F log.0000
8、在启动flume的那个终端会打印出log.0000文本的内容:
2015-06-21 11:46:16,752 (SinkRunner-PollingRunner-DefaultSinkProcessor) [INFO - org.apache.flume.sink.LoggerSink.process(LoggerSink.java:70)] Event: { headers:{} body: 68 65 6C 6C 6F 20 77 6F 72 6C 64 hello world }