4.flume实战(一)

需求:从指定网络端口采集数据输出到控制台

使用flume的关键就是写配置文件

a)配置source

b)配置channel

c)配置sink

d)把以上三个组件串起来

我们看一下官网给的配置文件

# example.conf: A single-node Flume configuration

# a1:agent的名称
# r1:source的名称
# k1:sink的名称
# c1:channel的名称
# Name the components on this agent
a1.sources = r1  # 指定source
a1.sinks = k1  # 指定sink
a1.channels = c1  # 指定channel    
# 这里指定的只有一个

# Describe/configure the source
# 这个agent有多个source,我们指定source的类型为netcat,绑定到localhost,我这里也可以写成ubuntu,可以通过hostname查看,监听端口为44444
a1.sources.r1.type = netcat
a1.sources.r1.bind = localhost
a1.sources.r1.port = 44444

# Describe the sink
# 表示将logger输出到控制台
a1.sinks.k1.type = logger

# Use a channel which buffers events in memory
# 使用channel存到内存当中
a1.channels.c1.type = memory
a1.channels.c1.capacity = 1000
a1.channels.c1.transactionCapacity = 100

# Bind the source and sink to the channel
# 把以上三个组件串起来
# 一个source可以接收不同的数据源
a1.sources.r1.channels = c1
# 但是sink只能sink到一个地方去
a1.sinks.k1.channel = c1

  

 

猜你喜欢

转载自www.cnblogs.com/traditional/p/9929786.html