flume 需求一:从指定网络端口采集数据输出到控制台
需求一:从指定网络端口采集数据输出到控制台
flume官网:https://flume.apache.org/
例子:Flume 1.9.0 User Guide — Apache Flume
使用flume的关键就是写配置文件:
A)配置Source
B)配置Channe
C)配置Sink
D)把以上三个组件串起来
a1:agent的名称
r1:source的名称
k1:sinks的名称
c1:channels的名称
注意:
一个source可以输出到多个channels
配置过程:
(1)
1、cd /kkb/install/apache-flume-1.7.0-bin/conf
2、在/conf
下创建exmaple.conf
example.conf:
# example.conf: A single-node Flume configuration # Name the components on this agent a1.sources = r1 a1.sinks = k1 a1.channels = c1 # Describe/configure the source
#绑定的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
(2)启动agent:
./flume-ng agent -n a1 -c $FLUME_HOME/conf -f /kkb/install/apache-flume-1.7.0-bin/conf/exmaple.conf -Dflume.root.logger=INFO,console
(3)使用telnet
进行测试
另起个终端,输入:telnet localhost 44444
输出成功!!!
其他:
Event: { headers:{} body: 68 65 6C 6C 30 0D hell0. }
Event是flume数据传输的基本单元
Event = 可选的headers +bety array
参考:https://blog.csdn.net/fanfan4569/article/details/82957998
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通