Flume-Kafka(Scala)

夙愿已清 提交于 2020-01-14 03:37:55

版本信息

Flume 版本:1.7
Kafka版本:kafka_2.11-2.3.1

架构图

在这里插入图片描述

Flume配置文件

# exec_memory_kafka.conf

a1.sources = r1
a1.channels = c1
a1.sinks = k1

a1.sources.r1.type = exec
a1.sources.r1.command = tail -F /home/hadoop/flume-1.7.0/log/test.log
a1.sources.r1.channels = c1

a1.channels.c1.type = memory
a1.channels.c1.capacity = 10000
a1.channels.c1.transactionCapacity = 10000
a1.channels.c1.byteCapacityBufferPercentage = 20
a1.channels.c1.byteCapacity = 800000


a1.sinks.k1.type = org.apache.flume.sink.kafka.KafkaSink
a1.sinks.k1.kafka.topic = flume_kafka
a1.sinks.k1.kafka.bootstrap.servers = localhost:9092
a1.sinks.k1.kafka.flumeBatchSize = 20
a1.sinks.k1.kafka.producer.acks = 1
a1.sinks.k1.kafka.producer.linger.ms = 1
a1.sinks.ki.kafka.producer.compression.type = snappy

a1.sources.r1.channels = c1
a1.sinks.k1.channel = c1

启动flume

bin/flume-ng agent -n a1 -c conf -f conf/exec_memory_kafka.conf  -Dflume.root.logger=INFO,console

发送消息

echo "服务器测试">> test.log 

Kafka消费者

服务器测试

启动kafka

[root@node1 ~]# kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic flume_kafka --from-beginning
服务器测试

代码测试

代码见:kafka-consumer(scala & Java)
注意修改 topic
在这里插入图片描述
服务器端同时也可以收到

[root@node1 ~]# kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic flume_kafka --from-beginning
服务器测试
代码测试

用户手册:http://flume.apache.org/releases/content/1.7.0/FlumeUserGuide.html
官网地址:http://flume.apache.org/index.html

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!