ITPub博客

首页 > IT职业 > IT图书 > Flume + Kafka + SparkStreaming分析

Flume + Kafka + SparkStreaming分析

IT图书 作者:wengwb 时间:2021-09-09 10:15:27 0 删除 编辑

1 flume安装

首先我们设置数据来源为端口数据,然后数据发送到hdfs和kafka的cmcc topic中,其中flume的配置文件为:

a1.sources = r1  
a1.sinks = k1 k2 
a1.channels = c1 c2  
  
# 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  a1.sinks.k1.type = org.apache.flume.sink.kafka.KafkaSink  
a1.sinks.k1.topic = cmcc  
a1.sinks.k1.brokerList = hostname:9092  a1.sinks.k1.requiredAcks = 1  a1.sinks.k1.batchSize = 20  
  # Use a channel which buffers events in memory  a1.channels.c1.type = memory  
a1.channels.c1.capacity = 1000  a1.channels.c1.transactionCapacity = 100  a1.channels.c2.type = memory
a1.channels.c2.capacity = 1000a1.channels.c2.transactionCapacity = 100a1.sinks.k2.type = hdfs
a1.sinks.k2.hdfs.useLocalTimeStamp = truea1.sinks.k2.hdfs.path = hdfs://hostname:9000/flume/events/%Y/%m/%d/%H/%M
a1.sinks.k2.hdfs.filePrefix = cmcc
a1.sinks.k2.hdfs.minBlockREplicas = 1a1.sinks.k2.hdfs.fileType = DataStream
a1.sinks.k2.hdfs.writeFormat = Text
a1.sinks.k2.hdfs.rollInterval = 60a1.sinks.k2.hdfs.rollSize = 0# Bind the source and sink to the channel  a1.sources.r1.channels = c1 c2  
a1.sinks.k1.channel = c1
a1.sinks.k2.channel = c2

a1.sources.r1.channels = c1 c2  说明我的数据源是同一份,但是分发到不同通道上。

2,安装kafka

3,测试flume发送数据,hdfs和kafka是否能够收到

flume执行如下命令:

bin/flume-ng agent --conf ./conf/ -f conf/flume-conf.properties -n a1

然后在linux中执行telnet localhost 44444,进行发送数据:

图片描述

Paste_Image.png

然后检查HDFS:

图片描述

Paste_Image.png

检查Kafka数据

图片描述

Paste_Image.png



作者:kason_zhang
链接:https://www.jianshu.com/p/b232ee5339cf


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/2216/viewspace-2819130/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2019-04-16

  • 博文量
    63
  • 访问量
    511