1.0 Flume概述
1.1 Flume 定义
Flume 是 一个高可用,高可靠的,分布式的海量日志采集、聚合和传输的系统
只能采集文本文档。Flume基于流式架构,灵活简单,是动态采集的。
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-yL6ZtDUf-1640089838539)(C:\Users\Administrator\Desktop\image-20211205133350590.png)]
Flume最主要的作用就是,实时读取服务器本地磁盘的数据,将数据写入到HDFS。
1.2 Flume 基础架构
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-SkhV5t4h-1640089838540)(C:\Users\Administrator\AppData\Roaming\Typora\typora-user-images\image-20211205133453733.png)]
核心部件: Source、Channel(缓冲作用)、Sink
-
1.2.1 Agent
Agent 是一个 JVM 进程,以事件的形式将数据从源头送至目的。
主要有三个部分组成,Source 、Channel 、Sink
-
1.2.2 Source
Source 是负责接收数据到 Flume Agent 的组件。
Source 组件可以处理各种类型、各种格式的日志数据,包括 avro、thrift、exec、jms、==spooling directory、netcat、taildir、==sequence generator、syslog、http、legacy。
-
1.2.3 Sink
Sink 不断地轮询 Channel 中的事件且批量地移除它们,并将这些事件批量写入到存储
或索引系统、或者被发送到另一个 Flume Agent。
Sink 组件目的地包括 hdfs、logger、avro、thrift、ipc、file、HBase、solr、自定
义。
Channel 是位于 Source 和 Sink 之间的缓冲区。因此,Channel 允许 Source 和 Sink 运
作在不同的速率上。Channel 是线程安全的,可以同时处理几个 Source 的写入操作和几个
Sink 的读取操作。
Flume 自带两种 Channel:Memory Channel 和 File Channel。(内存和磁盘 )(内存快,磁盘慢安全性高)
Memory Channel 是内存中的队列。Memory Channel 在不需要关心数据丢失的情景下适
用。如果需要关心数据丢失,那么 Memory Channel 就不应该使用,因为程序死亡、机器宕
机或者重启都会导致数据丢失。
File Channel 将所有事件写到磁盘。因此在程序关闭或机器宕机的情况下不会丢失数据。
-
1.2.5 Event
传输单元,Flume 数据传输的基本单元,以 Event 的形式将数据从源头送至目的地。
Event 由 Header 和 Body 两部分组成,Header 用来存放该 event 的一些属性,为 K-V 结构,
Body 用来存放该条数据,形式为字节数组。
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-ywllAF1F-1640089838541)(C:\Users\Administrator\AppData\Roaming\Typora\typora-user-images\image-20211205134613587.png)]
2.0 Flume 入门
2.1 Flume 安装
2.1.1 安装地址
- Flume 官网地址:http://flume.apache.org/
- 文档查看地址:http://flume.apache.org/FlumeUserGuide.html
- 下载地址:http://archive.apache.org/dist/flume/
2.1.2 安装部署
- 解压
- 删除 lib文件下的 guava-11.0.2.jar 删除以兼容 Hadoop 3.1.3
- guava-11.0.2.jar 是谷歌开发的工具包,里面有很多工具类,但是各框架引用的版本不一样,会出现兼容性题。
2.2 Flume 入门案例
2.2.1 监控端口数据官方案例
-
案例需求:
使用 Flume 监听一个端口(50070,新版本9870),收集该端口数据,(logger)并打印到控制台。
-
案例分析
-
实现步骤
-
安装netcat工具
yum install -y netcat
-
开启一个通信
nc -lk 9999
nc localhost 9999
两者可以发送信息-
判断 44444 端口是否被占用
sudo netstat -nlp | grep 44444
-
创建 Flume Agent 配置文件 net-flume-logger.conf
见名知意:通过 net(端口) 传送到 flume 再到 logger.conf
job/net-flume-logger.conf
-
在 net-flume-logger.conf 文件中添加如下内容。
添加内容如下: # 命名此代理上的组件 # Name the components on this agent (agent)单台服务里面要唯一 a1.sources = r1 #相当于内部变量 a1.sinks = k1 a1.channels = c1 #以s结尾的可以配多个 # 描述/配置源 # Describe/configure the source #soure的配置 监控端口数据 a1.sources.r1.type = netcat #类型 a1.sources.r1.bind = localhost #本机名 a1.sources.r1.port = 44444 #44444端口 # Describe the sink #sink的配置 a1.sinks.k1.type = logger #类型 # Use a channel which buffers events in memory #channel的配置 a1.channels.c1.type = memory #类型 a1.channels.c1.capacity = 1000 #容量,最多放1000个指针 a1.channels.c1.transactionCapacity = 100 #事物的容量,防止数据丢失 # 注意:事物的容量要小于总容量 # 将源和接收器绑定到通道 # Bind the source and sink to the channel a1.sources.r1.channels = c1 #一个sources可以绑定多个channels a1.sinks.k1.channel = c1 #一个slinks只能绑定一个channel #注:配置文件来源于官方手册
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-fc5TZ2Hc-1640089838542)(C:\Users\Administrator\AppData\Roaming\Typora\typora-user-images\image-20211205144139999.png)]
-
先开启 flume 监听端口
第一种:
bin/flume-ng agent --conf conf/ --name
a1 --conf-file job/flume-netcat-logger.conf -
Dflume.root.logger=INFO,console
第二种:
bin/flume-ng agent -c conf/ -n a1 -f
job/flume-netcat-logger.conf -Dflume.root.logger=INFO,console
-
使用 netcat 工具向本机的 44444 端口发送内容
nc localhost 44444
-
2.2.2 实时监控单个追加文件
-
案例需求: 实时监控 Hive 日志 , 并上传到 HDFS 中
-
需求分析:
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-VDiTkDbL-1640089838542)(C:\Users\Administrator\AppData\Roaming\Typora\typora-user-images\image-20211205145054646.png)]
-
实现步骤:
-
确认 Hadoop 和 Java 环境变量配置正确
-
创建flume-file-hdfs.conf文件
-
添加以下内容
# Name the components on this agent a2.sources = r2 a2.sinks = k2 a2.channels = c2 # Describe/configure the source a2.sources.r2.type = exec a2.sources.r2.command = tatil -f /tmp/root/hive.log #tail -F /opt/apache-hive-2.3.4-bin/logs/hive # Describe the sink a2.sinks.k2.type = hdfs a2.sinks.k2.hdfs.path = hdfs://master:9000/flume/%Y%m%d/%H # 8020 --> 9820 # 9000 是 core-site.xml 里面的设置的端口号。 #上传文件的前缀 a2.sinks.k2.hdfs.filePrefix = logs- #是否按照时间滚动文件夹 a2.sinks.k2.hdfs.round = true #多少时间单位创建一个新的文件夹 a2.sinks.k2.hdfs.roundValue = 1 #重新定义时间单位 a2.sinks.k2.hdfs.roundUnit = hour #是否使用本地时间戳 a2.sinks.k2.hdfs.useLocalTimeStamp = true #积攒多少个 Event 才 flush 到 HDFS 一次 a2.sinks.k2.hdfs.batchSize = 100 #设置文件类型,可支持压缩 a2.sinks.k2.hdfs.fileType = DataStream #多久生成一个新的文件 a2.sinks.k2.hdfs.rollInterval = 60 #设置每个文件的滚动大小 a2.sinks.k2.hdfs.rollSize = 134217700 #文件的滚动与 Event 数量无关 a2.sinks.k2.hdfs.rollCount = 0 # Use a channel which buffers events in memory a2.channels.c2.type = memory a2.channels.c2.capacity = 1000 a2.channels.c2.transactionCapacity = 100 # Bind the source and sink to the channel a2.sources.r2.channels = c2 a2.sinks.k2.channel = c2
注意:对于所有与时间相关的转义序列,Event Header 中必须存在以 “timestamp”的 key
(除非 hdfs.useLocalTimeStamp 设置为 true,此方法会使用 TimestampInterceptor 自
动添加 timestamp)。
a3.sinks.k3.hdfs.useLocalTimeStamp = true
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-zxar2LXu-1640089838543)(C:\Users\Administrator\AppData\Roaming\Typora\typora-user-images\image-20211205150850828.png)]
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-ZXiFt1QS-1640089838543)(C:\Users\Administrator\AppData\Roaming\Typora\typora-user-images\image-20211205150947059.png)]
-
运行Flume
bin/flume-ng agent --conf conf/ --name a2 --conf-file job/flume-file-hdfs.conf
-
开启 hadoop 和 hive 并操作 hive 产生日志
sbin/start-dfs.sh ---- sbin/start-yarn.sh ---- bin/hive
-
2.2.3 实时监控目录下多个新文件
-
**案例需求:**使用 Flume 监听整个目录的文件,并上传至 HDFS
-
**需求分析:**实时读取目录文件到HDFS案例
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-79p1WVKC-1640089838544)(C:\Users\Administrator\AppData\Roaming\Typora\typora-user-images\image-20211205171320179.png)]
-
实现步骤:
-
创建一个文件:
vim flume-dir-hdfs.conf
-
添加以下内容
a3.sources = r3 a3.sinks = k3 a3.channels = c3 # Describe/configure the source a3.sources.r3.type = spooldir a3.sources.r3.spoolDir = /opt/module/flume/upload a3.sources.r3.fileSuffix = .COMPLETED a3.sources.r3.fileHeader = true #忽略所有以.tmp 结尾的文件,不上传 a3.sources.r3.ignorePattern = ([^ ]*\.tmp) # Describe the sink a3.sinks.k3.type = hdfs a3.sinks.k3.hdfs.path = hdfs://hadoop102:9820/flume/upload/%Y%m%d/%H #上传文件的前缀 a3.sinks.k3.hdfs.filePrefix = upload- #是否按照时间滚动文件夹 a3.sinks.k3.hdfs.round = true #多少时间单位创建一个新的文件夹 a3.sinks.k3.hdfs.roundValue = 1 #重新定义时间单位 a3.sinks.k3.hdfs.roundUnit = hour #是否使用本地时间戳 a3.sinks.k3.hdfs.useLocalTimeStamp = true #积攒多少个 Event 才 flush 到 HDFS 一次 a3.sinks.k3.hdfs.batchSize = 100 #设置文件类型,可支持压缩 a3.sinks.k3.hdfs.fileType = DataStream #多久生成一个新的文件 a3.sinks.k3.hdfs.rollInterval = 60 #设置每个文件的滚动大小大概是 128M a3.sinks.k3.hdfs.rollSize = 134217700 #文件的滚动与 Event 数量无关 a3.sinks.k3.hdfs.rollCount = 0 # Use a channel which buffers events in memory a3.channels.c3.type = memory a3.channels.c3.capacity = 1000 a3.channels.c3.transactionCapacity = 100 # Bind the source and sink to the channel a3.sources.r3.channels = c3 a3.sinks.k3.channel = c3
-
实时读取目录文件到 HDFS 案例
-
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-1eLc7UME-1640089838545)(C:\Users\Administrator\AppData\Roaming\Typora\typora-user-images\image-20211205171519973.png)]
-
启动监控文件夹命令 :
bin/flume-ng agent -c conf / -n a3 -f job/flume-dir-hdfs.conf
-
向 upload 文件夹中添加文件
在/usr/flume/flume 目录下创建upload文件夹
向 upload 文件夹中添加文件
-
查看 HDFS 上的数据
-
2.2.4 实时监控目录下的多个追加文件
Exec source 适用于监控一个实时追加的文件,不能实现断点续传;
Spooldir Source适合用于同步新文件,但不适合对实时追加日志的文件进行监听并同步
而 Taildir Source适合用于监听多个实时追加的文件,并且能够实现断点续传
它可以监控动态文件,以及不同目录的不同文件
-
案例需求: 使用 Flume 监听整个目录的实时追加文件,并上传至HDFS
-
需求分析:
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-jmuYG3CS-1640089838545)(C:\Users\Administrator\AppData\Roaming\Typora\typora-user-images\image-20211205190208626.png)]
-
实现步骤:
-
创建配置文件 flume-taildir-hdfs.conf
-
添加如下内容:
a3.sources = r3 a3.sinks = k3 a3.channels = c3 # Describe/configure the source a3.sources.r3.type = TAILDIR a3.sources.r3.positionFile = /usr/flume/flume/tail_dir.json a3.sources.r3.filegroups = f1 f2 a3.sources.r3.filegroups.f1 = /usr/flume/flume/files/.*file.* a3.sources.r3.filegroups.f2 = /usr/flume/flume/files2/.*log.* # Describe the sink a3.sinks.k3.type = hdfs a3.sinks.k3.hdfs.path = hdfs://master:9000/flume/upload2/%Y%m%d/%H #上传文件的前缀 a3.sinks.k3.hdfs.filePrefix = upload- #是否按照时间滚动文件夹 a3.sinks.k3.hdfs.round = true #多少时间单位创建一个新的文件夹 a3.sinks.k3.hdfs.roundValue = 1 #重新定义时间单位 a3.sinks.k3.hdfs.roundUnit = hour #是否使用本地时间戳 a3.sinks.k3.hdfs.useLocalTimeStamp = true #积攒多少个 Event 才 flush 到 HDFS 一次 a3.sinks.k3.hdfs.batchSize = 100 #设置文件类型,可支持压缩 a3.sinks.k3.hdfs.fileType = DataStream #多久生成一个新的文件 a3.sinks.k3.hdfs.rollInterval = 60 #设置每个文件的滚动大小大概是 128M a3.sinks.k3.hdfs.rollSize = 134217700 #文件的滚动与 Event 数量无关 a3.sinks.k3.hdfs.rollCount = 0 # Use a channel which buffers events in memory a3.channels.c3.type = memory a3.channels.c3.capacity = 1000 a3.channels.c3.transactionCapacity = 100 # Bind the source and sink to the channel a3.sources.r3.channels = c3 a3.sinks.k3.channel = c3
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-UZVwrZNT-1640089838546)(C:\Users\Administrator\AppData\Roaming\Typora\typora-user-images\image-20211206100431381.png)]
-
启动监控文件夹命令:
bin/flume-ng agent -c conf / -n a3 -f job/flume-taildir-hdfs.conf
-
在/user/flume/flume目录下创建files文件夹
-
向upload文件夹中添加数据
-
查看HDFS上的数据
Taildir 说明:
Taildir Source 维护了一个 json 格式的 position File,其会定期的往 position File
中更新每个文件读取到的最新的位置,因此能够实现断点续传。
Position File 的格式如下:
{"inode":2496272,"pos":12,"file":"/opt/module/flume/files/file1.txt"}
{"inode":2496275,"pos":12,"file":"/opt/module/flume/files/file2.txt"}
注:
Linux 中储存文件元数据的区域就叫做 inode,每个 inode 都有一个号码,
操作系统用 inode 号码来识别不同的文件,
Unix/Linux 系统内部不使用文件名,而使用 inode 号码来识别文件。
-
-
3.0 Flume 进阶
3.1 Flume 事务
3.4 Flume 企业开发案例
3.4.1 复制和多路复用
-
案例需求:
单数据源多出口案例 (选择器)
使用 Flume-1 监控文件变动,Flume-1 将变动内容传递给 Flume-2,Flume-2 负责存储到 HDFS。
同时 Flume-1 将变动内容传递给 Flume-3,Flume-3 负责输出到 Local FileSystem。
-
需求分析:
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-ziVn44um-1640089838546)(C:\Users\Administrator\AppData\Roaming\Typora\typora-user-images\image-20211206171546672.png)]
9000 属于是服务端口
Replicating ChannelSelector 是我们用的选择器
Avro Sink :核心需要的 channel , type 类型用的是 avro ,hostname ,port
Avro Source :核心需要的 channels, type 类型用的是 avro ,bind 绑定hostname
port 。Sink channel 只能有一个,Source可以有多个。上面的是服务端,这个是客户端。
File_roll Sink :核心需要的是 channel , type 类型用的是 file_roll , sink.directory
-
实现步骤:
-
准备工作:
在/usr/flume/flume/job下创建group1文件夹 :
cd group1/
在/usr/flume/datas/目录下创建flume3文件夹:
mkdir flume3
-
创建 flume-file-flume.conf
配置 1 个接受日志文件的 source 和两个 channel、两个sink,
分别输送给 flume-flile-flume.hdfs 和 flume-flume-dir
-
编辑配置文件:
[@master group1]$ vim flume-file-flume.conf
-
添加如下内容:
# Name the components on this agent a1.sources = r1 a1.sinks = k1 k2 a1.channels = c1 c2 # 将数据流复制给所有 channel a1.sources.r1.selector.type = replicating # Describe/configure the source a1.sources.r1.type = exec a1.sources.r1.command = tail -F /tmp/root/hive.log a1.sources.r1.shell = /bin/bash -c # Describe the sink # sink 端的 avro 是一个数据发送者 a1.sinks.k1.type = avro a1.sinks.k1.hostname = master a1.sinks.k1.port = 4141 a1.sinks.k2.type = avro a1.sinks.k2.hostname = master a1.sinks.k2.port = 4142 # Describe the channel a1.channels.c1.type = memory a1.channels.c1.capacity = 1000 a1.channels.c1.transactionCapacity = 100 a1.channels.c2.type = memory a1.channels.c2.capacity = 1000 a1.channels.c2.transactionCapacity = 100 # Bind the source and sink to the channel a1.sources.r1.channels = c1 c2 a1.sinks.k1.channel = c1 a1.sinks.k2.channel = c2
-
-
创建 flume-flume-hdfs.conf
配置上级 Flume 输出的 Source , 输出的是到HDFS 的Sink。
- 编辑配置文件:
[@mater group1]$ vim flume-flume-hdfs.conf
- 添加如下内容
# Name the components on this agent a2.sources = r1 a2.sinks = k1 a2.channels = c1 # Describe/configure the source # source 端的 avro 是一个数据接收服务 a2.sources.r1.type = avro a2.sources.r1.bind = master a2.sources.r1.port = 4141 #从4141拿数据 # Describe the sink a2.sinks.k1.type = hdfs a2.sinks.k1.hdfs.path = hdfs://master:9000/flume2/%Y%m%d/%H #上传文件的前缀 a2.sinks.k1.hdfs.filePrefix = flume2- #是否按照时间滚动文件夹 a2.sinks.k1.hdfs.round = true #多少时间单位创建一个新的文件夹 a2.sinks.k1.hdfs.roundValue = 1 #重新定义时间单位 a2.sinks.k1.hdfs.roundUnit = hour #是否使用本地时间戳 a2.sinks.k1.hdfs.useLocalTimeStamp = true #积攒多少个 Event 才 flush 到 HDFS 一次 a2.sinks.k1.hdfs.batchSize = 100 #设置文件类型,可支持压缩 a2.sinks.k1.hdfs.fileType = DataStream #多久生成一个新的文件 a2.sinks.k1.hdfs.rollInterval = 30 #设置每个文件的滚动大小大概是 128M a2.sinks.k1.hdfs.rollSize = 134217700 #文件的滚动与 Event 数量无关 a2.sinks.k1.hdfs.rollCount = 0 # Describe the channel a2.channels.c1.type = memory a2.channels.c1.capacity = 1000 a2.channels.c1.transactionCapacity = 100 # Bind the source and sink to the channel a2.sources.r1.channels = c1 a2.sinks.k1.channel = c1
- 编辑配置文件:
-
创建 flume-flume-dir.conf
配置上级 Flume 输出的 Source , 输出是到本地目录的 Sink。
- 编辑配置文件:
[@master group1]$ vim flume-flume-dir.conf
- 添加如下内容
# Name the components on this agent a3.sources = r1 a3.sinks = k1 a3.channels = c2 # Describe/configure the source a3.sources.r1.type = avro a3.sources.r1.bind = hadoop102 a3.sources.r1.port = 4142 # Describe the sink a3.sinks.k1.type = file_roll a3.sinks.k1.sink.directory = /usr/flume/data/flume3 # Describe the channel a3.channels.c2.type = memory a3.channels.c2.capacity = 1000 a3.channels.c2.transactionCapacity = 100 # Bind the source and sink to the channel a3.sources.r1.channels = c2 a3.sinks.k1.channel = c2
提示:
输出的本地目录必须是已经存在的目录,如果该目录不存在,并不会创建新的目录。
-
分别执行配置文件
分别启动对应的flume进程
flume-flume-dir :
bin/flume-ng agent -c conf / -n a1 -f job/group1/flume-flume-dir.conf
flume-flume-hdfs :先启动这个source服务端
bin/flume-ng agent -c conf / -n a2 -f job/group1/flume-flume-hdfs.conf
flume-file-flume : 之后在启动4142的服务端
bin/flume-ng agent -c conf / -n a3 -f job/group1/flume-file-flume.conf
-
启动 Hadoop 和 Hive
[@master hadoop-2.7.7]$sbin/start-dfs.sh
[@master hadoop-2.7.7]$sbin/start-yarn.sh
[@master hive]$bin/hive
-
检查HDFS上的数据
-
检查 /usr/flume/datas/flume3 目录中数据
[atguigu@hadoop102 flume3]$ ll
总用量 8
-rw-rw-r--. 1 atguigu atguigu 5942 5 月 22 00:09 1526918887550-3
-
3.4.2 负载均衡和故障转移
-
案例需求:
使用 Flume1 监控一个端口,其中 sink 组 分别对接 Flume2 和 Flume3 , 采用 FailoverSinkProcessor , 实现故障转移的功能。
-
需求分析:
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-Xf37ewEM-1640089838547)(C:\Users\Administrator\AppData\Roaming\Typora\typora-user-images\image-20211207135830523.png)]
-
实现步骤:
-
准备工作
在 /usr/flume/flume/job 目录下创建 group2 文件夹 :
mkdir group2
-
创建 flume-netcat-flume.conf
配置 1 个 netcat source 和 1 个 channel 、1 个 sink group (2 个 sink) 分别输送给 flume-flume-console1 和 flume-flume-console2
-
添加以下内容
# Name the components on this agent a1.sources = r1 a1.channels = c1 a1.sinkgroups = g1 a1.sink2 = k1 k2 # Describe/configure the source a1.sources.r1.type = netcat a1.sources.r1.bind = localhost a1.sources.r1.port = 44444 a1.sinkgroups.g1.processor.type = failover a1.sinkgroups.g1.processor.priority.k1 = 5 a1.sinkgroups.g1.processor.priority.k2 = 10 a1.sinkgroups.g1.processor.maxpenalty = 10000 # Describe the sink a1.sinks.k1.type = avro a1.sinks.k1.hostname = master a1.sinks.k1.port = 4141 a1.sinks.k2.type = avro a1.sinks.k2.hostname = master a1.sinks.k2.port = 4142 # Describe the channel 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.sinkgroups.g1.sinks = k1 k2 a1.sinks.k1.channel = c1 a1.sinks.k2.channel = c1
-
创建 flume-flume-console1.conf
配置上级 Flume 输出 Source , 输出是到本地控制台
-
编辑配置文件
# Name the components on this agent a2.sources = r1 a2.sinks = k1 a2.channels = c1 # Describe/configure the source a2.sources.r1.type = avro a2.sources.r1.bind = master a2.sources.r1.port = 4141 # Describe the sink a2.sinks.k1.type = logger # Describe the channel a2.channels.c1.type = memory a2.channels.c1.capacity = 1000 a2.channels.c1.transactionCapacity = 100 # Bind the source and sink to the channel a2.sources.r1.channels = c1 a2.sinks.k1.channel = c1
-
创建 flume-flume-console2.conf
配置上级 Flume 输出的 Source,输出是到本地控制台。
-
编辑配置文件
# Name the components on this agent a3.sources = r1 a3.sinks = k1 a3.channels = c2 # Describe/configure the source a3.sources.r1.type = avro a3.sources.r1.bind = master a3.sources.r1.port = 4142 # Describe the sink a3.sinks.k1.type = logger # Describe the channel a3.channels.c2.type = memory a3.channels.c2.capacity = 1000 a3.channels.c2.transactionCapacity = 100 # Bind the source and sink to the channel a3.sources.r1.channels = c2 a3.sinks.k1.channel = c2
-
分别执行配置文件
bin/flume-ng agent -c conf / -n a3 -f job/group2/flume-flume-console2.conf-Dflume.root.logger=INFO,console
bin/flume-ng agent -c conf / -n a2 -f job/group2/flume-flume-console1 .conf-Dflume.root.logger=INFO,console
bin/flume-ng agent -c conf / -n a1 -f job/group2/flume-netcat-flume.conf
-
使用 netcat 工具向本机的 44444 端口发送内容
nc loacalhost 4444
-
查看 Flume2 以及 Flume3 的控制台打印日志
-
将 Flume2 kill 观察 Flume3 的控制台打印情况。
-
-
查看 Flume2 以及 Flume3 的控制台打印日志
11. 将 Flume2 kill 观察 Flume3 的控制台打印情况。