案例九:启动flume采集程序,其中采集两个数据源的数据,其中第一个数据源是服务器1上的端口数据。第二个数据源是服务器2上的目录数据。现在实现将服务器1和服务器2数据源上的数据统一输出到flume日志中

说明

source: 2
channel: 1
sink: 1

注意:

sink
type: avro
hostname: node
port
source
type: avro
bind: node1
port

画图理解

配置文件

服务器1的配置文件

[root@node1 oneother]# cat portToLogger.conf
# 给flume采集进程起一个别名 a1
# 定义flume进程中有几个source、sink、channel,以及每一个source的别名
a1.sources = r1
a1.sinks = k1
a1.channels = c1
# 定义flume进程中source连接到数据源信息
a1.sources.r1.type = netcat
a1.sources.r1.bind = node1
a1.sources.r1.port = 44444
a1.sinks.k1.type = avro
a1.sinks.k1.hostname = node1
a1.sinks.k1.port = 40000
a1.channels.c1.type = memory
a1.channels.c1.capacity = 1000
a1.channels.c1.transactionCapacity = 100
a1.sources.r1.channels = c1
a1.sinks.k1.channel = c1

服务器2的配置文件

[root@node1 twoother]# cat portToLogger.conf
# 给flume采集进程起一个别名 a1
# 定义flume进程中有几个source、sink、channel,以及每一个source的别名
two.sources = r1
two.sinks = k1
two.channels = c1
# 定义flume进程中source连接到数据源信息
two.sources.r1.type = spooldir
two.sources.r1.spoolDir = /opt/test/
two.sinks.k1.type = avro
two.sinks.k1.hostname = node1
two.sinks.k1.port = 40000
two.channels.c1.type = memory
two.channels.c1.capacity = 1000
two.channels.c1.transactionCapacity = 100
two.sources.r1.channels = c1
two.sinks.k1.channel = c1

聚合的配置文件

[root@node1 aggre]# cat flumeToLogger.sh
# 给flume采集进程agent起了一个别名 a1
# 定义flume进程中有几个source 以及每一个source的别名
aggre.sources = r1
aggre.sinks = k1
aggre.channels = c1
# 定义flume进程中source连接到数据源信息
aggre.sources.r1.type = avro
aggre.sources.r1.bind = node1
aggre.sources.r1.port = 40000
aggre.sinks.k1.type = logger
aggre.channels.c1.type = memory
aggre.channels.c1.capacity = 1000
aggre.channels.c1.transactionCapacity = 100
aggre.sources.r1.channels = c1
aggre.sinks.k1.channel = c1
posted @   jsqup  阅读(56)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 三行代码完成国际化适配,妙~啊~
· .NET Core 中如何实现缓存的预热?
点击右上角即可分享
微信分享提示