Flume基础知识(十):Flume 聚合实战

1)案例需求:

hadoop100上的 Flume-1 监控文件/opt/module/group.log,

hadoop101上的 Flume-2 监控某一个端口的数据流,

Flume-1 与 Flume-2 将数据发送给 hadoop102 上的 Flume-3,Flume-3 将最终数据打印 到控制台。

2)需求分析

 

3)实现步骤:

(1)准备工作 分发 Flume

 [root@hadoop100 module]$ xsync flume

在 hadoop102、hadoop103 以及 hadoop104 的/opt/module/flume/job 目录下创建一个 group3 文件夹。

[root@hadoop100 job]$ mkdir group3 
[root@hadoop101 job]$ mkdir group3 
[root@hadoop102 job]$ mkdir group3

(2)创建 flume1-logger-flume.conf

配置 Source 用于监控 hive.log 文件,配置 Sink 输出数据到下一级 Flume。

在 hadoop100 上编辑配置文件

 [root@hadoop100 group3]$ vim flume1-logger-flume.conf

添加如下内容

# Name the components on this agent
a1.sources = r1
a1.sinks = k1
a1.channels = c1
# Describe/configure the source
a1.sources.r1.type = exec
a1.sources.r1.command = tail -F /opt/module/datas/group.log
a1.sources.r1.shell = /bin/bash -c
# Describe the sink
a1.sinks.k1.type = avro
a1.sinks.k1.hostname = hadoop102
a1.sinks.k1.port = 4141
# 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.sinks.k1.channel = c1

(3)创建 flume2-netcat-flume.conf

配置 Source 监控端口 44444 数据流,配置 Sink 数据到下一级 Flume:

在 hadoop101 上编辑配置文件

 [root@hadoop100 group3]$ vim flume2-netcat-flume.conf 

添加如下内容

# Name the components on this agent
a2.sources = r1
a2.sinks = k1
a2.channels = c1
# Describe/configure the source
a2.sources.r1.type = netcat
a2.sources.r1.bind = hadoop101
a2.sources.r1.port = 44444
# Describe the sink
a2.sinks.k1.type = avro
a2.sinks.k1.hostname = hadoop102
a2.sinks.k1.port = 4141
# Use a channel which buffers events in memory
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

(4)创建 flume3-flume-logger.conf

配置 source 用于接收 flume1 与 flume2 发送过来的数据流,最终合并后 sink 到控制 台。

在 hadoop104 上编辑配置文件

[root@hadoop104 group3]$ vim flume3-flume-logger.conf 

添加如下内容

# Name the components on this agent
a3.sources = r1
a3.sinks = k1
a3.channels = c1
# Describe/configure the source
a3.sources.r1.type = avro
a3.sources.r1.bind = hadoop102
a3.sources.r1.port = 4141
# Describe the sink
# Describe the sink
a3.sinks.k1.type = logger
# Describe the channel
a3.channels.c1.type = memory
a3.channels.c1.capacity = 1000
a3.channels.c1.transactionCapacity = 100
# Bind the source and sink to the channel
a3.sources.r1.channels = c1
a3.sinks.k1.channel = c1

(5)执行配置文件

分别开启对应配置文件:flume3-flume-logger.conf,flume2-netcat-flume.conf, flume1-logger-flume.conf。

[root@hadoop102 flume]$ bin/flume-ng agent --conf conf/ --name a3 --conf-file job/group3/flume3-flume-logger.conf -Dflume.root.logger=INFO,console
[root@hadoop101 flume]$ bin/flume-ng agent --conf conf/ --name a2 --conf-file job/group3/flume1-logger-flume.conf
[root@hadoop100 flume]$ bin/flume-ng agent --conf conf/ --name a1 --conf-file job/group3/flume2-netcat-flume.conf

(6)在 hadoop101 上向/opt/module 目录下的 group.log 追加内容

[root@hadoop103 module]$ echo 'hello' > group.log

(7)在 hadoop100 上向 44444 端口发送数据

[root@hadoop100 flume]$ telnet hadoop100 44444

(8)检查 hadoop104 上数据

 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/603186.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

数据库事务的特性

数据库事务具有 ACID 特性,其中 ACID 是指原子性(Atomicity)、一致性(Consistency)、隔离性(Isolation)和持久性(Durability)。这些特性是为了确保数据库在事务处理中的可…

Android 13.0修改recovery 菜单项字体大小

1.概述 在13.0的系统rom定制化开发中,在系统进入recovery模式后,界面会g_menu_actions 菜单选项和 提示文字,而这些文字的大小不像上层一样是通过设置属性来表示大小的 而它确是通过字体png图片的大小来计算文字的宽和高的,然后可以修改字体大小,接下来就实现菜单项字体大…

RocketMQ详细介绍及核心问题解释(很全)

1. RocketMq是什么 一个纯Java、分布式队列模型的消息中间件,具有高可用、高可靠、高实时、低延迟的特点。(记住这句就行了) 2. RocketMq有什么功能 1、业务解耦:这也是发布订阅的消息模型。生产者发送指令到MQ中,然…

python中parsel模块的css解析

一、爬虫页面分类 1.想要爬取的内容全部在标签中,可以使用xpath去进行解析如下图 2.想要爬取的内容呈现json的数据特征,用.json()转换为字典格式 3.页面不规则,标签中包含大括号,如下面想要获取键值内容怎么做,先用re正…

Binius:基于binary fields的SNARKs(Part 2)

1. 引言 前序博客有: Binius:基于binary fields的SNARKs(Part 1)Binius:助力ZK行业发展 本文重点关注: 1)concatenated codes:可扩展对small fields的多项式承诺方案2&#xff0…

Docker学习与应用(六)-Docker网络

1、Docker网络 Docker有多种网络模式可以选择,可以根据应用场景和需求选择合适的网络模式。 桥接模式(Bridge Mode):默认情况下,Docker使用桥接模式创建一个虚拟网络,所有容器会连接到这个虚拟网络中。每个…

回家用go?还是go to?

语法 go 副词 go to 名词 home比较特殊 前面无修饰词就是副词 前面有修饰词就是名词 案例

【MATLAB第88期】基于MATLAB的6种神经网络(ANN、FFNN、CFNN、RNN、GRNN、PNN)多分类预测模型对比含交叉验证

【MATLAB第88期】基于MATLAB的6种神经网络(ANN、FFNN、CFNN、RNN、GRNN、PNN)多分类预测模型对比含交叉验证 前言 本文介绍六种类型的神经网络分类预测模型 1.模型选择 前馈神经网络 (FFNN) 人工神经网络 (ANN) 级联前向神经网络 (CFNN) 循环神经网…

消息队列-什么是MQ?何时使用MQ?怎么选择MQ?

什么是MQ? MessageQueue:就是消息 队列,任务队列,指令 队列。 功能:应用程序之间(生产者与消费者)的通信方式。 使用场景 从下面这个场景来感受MQ 的诞生 如果我们有很多任务需要处理,任务…

Logstash相关问题及答案(2024)

1、什么是Logstash? Logstash是Elastic Stack(曾被称为ELK Stack,即Elasticsearch、Logstash、Kibana三者的组合)的一部分,是一个开源的服务器端数据处理管道,可以同时从多个来源采集数据,转换数…

Mac打包Unix可执行文件为pkg

Mac打包Unix可执行文件为pkg 方式一:通过packages页面打包 1.下载packages app Distribution:自定义化更高,包括修改安装页面的内容提示 我这里主要演示Distribution模式的项目:通过unix可执行文件postinstall.sh脚本实现通过ma…

听GPT 讲Rust源代码--compiler(31)

File: rust/compiler/rustc_ast_passes/src/node_count.rs 在Rust源代码的rust/compiler/rustc_ast_passes/src/node_count.rs文件中,它定义了Rust编译器中的AST节点计数器。该文件的作用是统计不同类型的AST节点在程序中的数量,以便在优化和调试过程中能…

【Python】Excel多sheet逐行合并为一个sheet

我有一个excel,内含多个sheet,我要将不同sheet合并在一个sheet中,依然保存在这个excel文件中,命名为合并,要求列名依次对应,逐行合并,请为我写出python代码 import pandas as pd# 读取 Excel 文…

acwing KMP算法

【数据结构】KMP算法&#xff08;详解&#xff09; #include <iostream> #include <string> #include <vector>using namespace std; const int N 1e6 10; int n1, n2; char s1[N], s2[N]; vector<int> next_val(N);void get_next() {// next数组中…

详解Keras:keras.preprocessing.image

keras.preprocessing.image Keras 库中的一个模块&#xff0c;用于处理和增强图像数据&#xff0c;它提供了一些实用的函数&#xff0c;如图像的加载、预处理、增强等。 常用函数 1、load_img 用于加载图像文件&#xff0c;并返回一个 NumPy 数组表示该图像 示例 from ker…

unity编辑器Scene界面输出位置及路径

工程Asset下新建Editor文件夹&#xff1b; Editor文件夹下新建脚本LogPosition using System.Collections; using System.Collections.Generic; using UnityEditor; using UnityEngine; public class LogPosition : EditorWindow {//最终输出的数据.static string logtext;//增…

@PathVariable详解

PathVariable 用于获取URL路径中的参数值 通过 PathVariable 可以将 URL 中占位符参数绑定到控制器处理方法的入参中&#xff1a;URL 中的 {xxx} 占位符可以通过PathVariable(“xxx”) 绑定到操作方法的入参中。 一般与RequestMapping(method RequestMethod.GET)一起使用 …

K8S-应用访问

1 service对象定位 2 Service 实践 手工创建Service 根据应用部署资源对象&#xff0c;创建SVC对象 kubectl expose deployment nginx --port80 --typeNodePortyaml方式创建Service nginx-web的service资源清单文件 apiVersion: v1 kind: Service metadata:name: sswang-ngi…

04 帧 Frame

文章目录 04 帧 Frame4.1 相机相关信息4.2 特征点提取4.2.1 特征点提取 ExtractORB()4.3 ORB-SLAM2对双目/RGBD特征点的预处理4.3.1 双目视差公式4.3.2 双目图像特征点匹配 ComputeStereoMatches()4.3.3 根据深度信息构造虚拟右目图像&#xff1a;ComputeStereoFromRGBD() 4.4 …

静态网页设计——环保网(HTML+CSS+JavaScript)(dw、sublime Text、webstorm、HBuilder X)

前言 声明&#xff1a;该文章只是做技术分享&#xff0c;若侵权请联系我删除。&#xff01;&#xff01; 感谢大佬的视频&#xff1a; https://www.bilibili.com/video/BV1BC4y1v7ZY/?vd_source5f425e0074a7f92921f53ab87712357b 使用技术&#xff1a;HTMLCSSJS&#xff08;…