Flume和kafka的整合:使用Flume将日志数据抽取到Kafka中

文章目录


1、Kafka作为Source【数据进入到kafka中,抽取出来】

kafka源 --> memory --> 控制台:

bash 复制代码
a1.sources = r1
a1.sinks = k1
a1.channels = c1

# Bind the source and sink to the channel
a1.sources.r1.channels = c1
a1.sinks.k1.channel = c1

a1.sources.r1.type = org.apache.flume.source.kafka.KafkaSource
a1.sources.r1.batchSize = 100
a1.sources.r1.batchDurationMillis = 2000
a1.sources.r1.kafka.bootstrap.servers = node01:9092,node02:9092,node03:9092
a1.sources.r1.kafka.topics = five
a1.sources.r1.kafka.consumer.group.id = donghu

# Use a channel which buffers events in memory
a1.channels.c1.type = memory
a1.channels.c1.capacity = 1000
a1.channels.c1.transactionCapacity = 100

a1.sinks.k1.type = logger
a1.sinks.k1.maxBytesToLog = 128

2、kafka作为Sink 【数据从别的地方抽取到kafka里面】

netcat --> memory -->kafka:

bash 复制代码
##a1就是flume agent的名称
## source r1
## channel c1
## sink k1
a1.sources = r1
a1.sinks = k1
a1.channels = c1

# Describe/configure the source
a1.sources.r1.type = netcat
a1.sources.r1.bind = bigdata01
a1.sources.r1.port = 44444

# 修改sink为kafka
a1.sinks.k1.type = org.apache.flume.sink.kafka.KafkaSink
a1.sinks.k1.kafka.bootstrap.servers = node01:9092
a1.sinks.k1.kafka.topic = five
a1.sinks.k1.kafka.producer.acks = 1
a1.sinks.k1.kafka.producer.linger.ms = 1

# 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
相关推荐
写代码的【黑咖啡】20 分钟前
如何在大数据数仓中搭建数据集市
大数据·分布式·spark
华清远见成都中心43 分钟前
成都理工大学&华清远见成都中心实训,助力电商人才培养
大数据·人工智能·嵌入式
梦里不知身是客112 小时前
flume防止数据丢失的方法
大数据·flume
SoleMotive.2 小时前
kafka选型
分布式·kafka
鹏说大数据3 小时前
数据治理项目实战系列6-数据治理架构设计实战,流程 + 工具双架构拆解
大数据·数据库·架构
AI逐月5 小时前
Git 彻底清除历史记录
大数据·git·elasticsearch
天远API5 小时前
Java后端进阶:处理多数据源聚合API —— 以天远小微企业报告为例
大数据·api
lang201509286 小时前
深入解析Kafka Broker核心读写机制
分布式·kafka
希艾席帝恩6 小时前
数字孪生如何重塑现代制造体系?
大数据·人工智能·数字孪生·数据可视化·数字化转型
武汉海翎光电6 小时前
从数据采集到智能决策:船舶传感器的技术跃迁之路
大数据·人工智能