Flume采集日志

角色


Source 数据来源 (exec, kafka, http…)
Channel 数据通道 (memory,file,jdbc)
Sink 数据目的地 (kafka,hdfs,es…)

Agent 代理,负责从source中采集数据,发送给collector
Collector 收集者,收集agent发来的数据上传到outer storage,可以设置load balance,fail over
Outer storage 外部存储,接收collector上传的数据

 

安装配置


下载tar包

解压即安装

 

测试


修改配置文件,监听44444端口
# 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
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

启动

通过telnet测试


telnet 127.0.0.1 44444
窗口中输入字符并回车

flume日志中会输出内容

Note:可使用cat, tail -200等从头或者指定位置开始采集日志

原文地址:https://www.cnblogs.com/zhya/p/9639826.html