编写
编写步骤:
- 给Agent三个组件起别名
- 指定Agent.sources的源
- 指定Agent.sinks的源
- 指定Agent.channel的源
- 配置关系:r1 —> k1 —> c1
官方案例代码:
# example.conf: A single-node Flume configuration# Name the components on this agent# 给Agent三个组件起别名a1.sources = r1a1.sinks = k1a1.channels = c1# Describe/configure the source# 选择源a1.sources.r1.type = netcata1.sources.r1.bind = localhosta1.sources.r1.port = 44444# 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# 指定Agent组件关系a1.sources.r1.channels = c1a1.sinks.k1.channel = c1
启动程序
flume-ng agent --conf conf --conf-file /home/hadoop/kylin/a.conf --name a1 -Dflume.root.logger=INFO,console
flume-ng:启动
—conf conf —conf-file example.conf:指定配置文件的方式运行
—name a1:Agent名字
-Dflume.root.logger=INFO,console:打印到控制台
