1.下载
/*
对日志收集的三个核心要素进行了抽象:
1. Source:日志从哪里产生
2. Sink:日志会被推送到什么地方
3. Channel:Source通过什么样的渠道,送到Sink
*/
cd /opt
wget https://mirror.bit.edu.cn/apache/flume/1.9.0/apache-flume-1.9.0-bin.tar.gz
tar -zxvf apache-flume-1.9.0-bin.tar.gz
cd /opt/apache-flume-1.9.0-bin/conf
2.修改配置
//查看java安装路径
echo $JAVA_HOME
cp flume-env.sh.template flume-env.sh
vim flume-env.sh
export JAVA_HOME=/usr/local/java
// 创建 job/flume-netcat-logger.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
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
## channel 与 sink 的关系是 1对多 的关系。1个sink只可以绑定1个channel,1个channel可以绑定多个sink。
a1.sinks.k1.channel = c1
3.启动
bin/flume-ng agent --conf conf --conf-file job/flume-netcat-logger.conf --name a1 -Dflume.root.logger=INFO,console
4.校验
//查看端口时候通
// yum install -y telnet
telnet localhost 44444
参考:https://www.cnblogs.com/fonxian/p/11973711.html
参考:https://rdc.hundsun.com/portal/article/941.html