编写
编写步骤:
- 给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 = 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 = 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 = c1
a1.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:打印到控制台