Flume配置案例@Source:端口,Channel:内存,Sink:控制台

时间:2024-04-14 22:40:01
vim /opt/module/flume/job/port_to_console.conf
-------------------------
在nc-flume-log.conf文件中添加如下内容。
# Name the components on this 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
a1.sources.r1.channels = c1
a1.sinks.k1.channel = c1

测试:

启动flume:
[root@hadoop102 flume]$ bin/flume-ng agent --conf conf/ --name a1 --conf-file job/port_to_console.conf

再开个会话,使用netcat工具向本机的44444端口发送内容:
[root@hadoop102 ~]$ nc localhost 44444
>>>
hello
nihao