flume简易实现入门

1、下载
 http://www.apache.org/dist/flume/stable/
 下载最新的tar.gz包即可
2、解压
 tar -zxvf ....
3、配置环境变量
 FLUME_HOME和PATH
 记得执行source /etc/profile
4、添加一个简单的测试案例
 a、在conf目录下新建一个文件,test-conf.propertis,内容如下:
 # define the alias(sources->channels->sinks)
 a1.sources = s1
 a1.sinks = k1
 a1.channels = c1

 #describe the source
 a1.sources.s1.type = avro
 a1.sources.s1.bind = hadoop  #agent所在的hostname
 a1.sources.s1.port = 44444

 #describe the sink
 #将数据输出到日志
 a1.sinks.k1.type = logger

 #describe the channel
 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.s1.channels = c1
 a1.sinks.k1.channel = c1  #此处是channel不是channels

 b、在conf目录下新建一个源文件file01并向其中写入数据:
 $ touch file01;
 $ echo "hello world" > file01
 c、启动agent代理
 $ flume-ng agent -n a1 -f test-conf.properties
 启动结果如下:
 。。。。。。。。。。。。。
 若出现异常NoClassFoundException org.apache.flume.tools.GetJavaProperty...可以不用管。
 d、启动avro-client客户端向agent代理发送数据
 打开一个新的终端:
 $ flume-ng avro-client -H hadoop -p 44444 -F file01
 e、可看到agent代理端输出:
 ................
 avro-client客户端发来的数据已经被agent代理接收到,在本例中的配置中,设置的sink类型为logger,其输出结果会保存在日志中。关于flume-ng的介绍及详细使用说明见

 
 

posted @ 2014-07-28 11:50  jseven  阅读(327)  评论(0编辑  收藏  举报