温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

Flume怎么采集发送消息到kafka

发布时间:2021-07-09 17:54:38 来源:亿速云 阅读:259 作者:chen 栏目:大数据

这篇文章主要讲解了“Flume怎么采集发送消息到kafka”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“Flume怎么采集发送消息到kafka”吧!

Flume agent脚本及配置如下

Mac

安装:

brew install flume

启动脚本:

nohup /usr/local/Cellar/flume/1.9.0/bin/flume-ng agent --conf /data/flume/run/flume/conf/conf.d/ --conf-file /data/flume/run/flume/conf/conf.d/mg-res_test.conf --name mg-res_test -Dflume.codeadmin.logger=INFO,console &

linux

安装:

http://flume.apache.org/download.html

启动脚本:

nohup /data/flume/run/flume/bin/flume-ng agent --conf /data/flume/run/flume/conf/conf.d/ --conf-file /data/flume/run/flume/conf/conf.d/mg-res_test.conf --name mg-res_test -Dflume.codeadmin.logger=INFO,console &

配置说明

/data/flume/run/flume/conf/conf.d/mg-res_test.conf

flume主要配置信息,关注中文描述的部分即可

# Name the components on this agent
mg-res_test.sources = mg-res_test
mg-res_test.sinks = mg-res_test
mg-res_test.channels = mg-res_test
# Describe/configure the source
mg-res_test.sources.mg-res_test.type = TAILDIR
# flume 记录偏移量文件
mg-res_test.sources.mg-res_test.positionFile=/data/logs/test/res-test/mg-res_test.json
mg-res_test.sources.mg-res_test.filegroups=f1
# 待采集的日志文件
mg-res_test.sources.mg-res_test.filegroups.f1=/data/logs/test/res-test/app.log
mg-res_test.sources.mg-res_test.fileHeader=true

# Describe the sink
mg-res_test.sinks.mg-res_test.channel = mg-res_test
mg-res_test.sinks.mg-res_test.type = org.apache.flume.sink.kafka.KafkaSink
# kafka topic配置 以实际为准
mg-res_test.sinks.mg-res_test.kafka.topic = res-test
# kafka 配置信息 以实际为准
mg-res_test.sinks.mg-res_test.kafka.bootstrap.servers = localhost:9092
mg-res_test.sinks.mg-res_test.kafka.flumeBatchSize = 2
mg-res_test.sinks.mg-res_test.kafka.producer.acks = 1
mg-res_test.sinks.mg-res_test.kafka.producer.linger.ms = 1
mg-res_test.sinks.mg-res_test.kafka.producer.compression.type = snappy
# Use a channel which buffers events in memory
mg-res_test.channels.mg-res_test.type = memory
mg-res_test.channels.mg-res_test.capacity = 100000
mg-res_test.channels.mg-res_test.transactionCapacity = 10000
# Bind the source and sink to the channel
mg-res_test.sources.mg-res_test.channels = mg-res_test
mg-res_test.sinks.mg-res_test.channel = mg-res_test

/data/flume/run/flume/conf/conf.d/flume-env.sh

配置java home即可

export JAVA_OPTS="-Xms128m -Xmx128m -Dcom.sun.management.jmxremote"
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_192.jdk/Contents/Home

验证

本地环境可以直接启动kafka消费看有没有消息进入,测试环境请查询kafka消息增量或业务系统实际消费情况

kafka-console-consumer --bootstrap-server localhost:9092 --topic res-test --from-beginning

感谢各位的阅读,以上就是“Flume怎么采集发送消息到kafka”的内容了,经过本文的学习后,相信大家对Flume怎么采集发送消息到kafka这一问题有了更深刻的体会,具体使用情况还需要大家实践验证。这里是亿速云,小编将为大家推送更多相关知识点的文章,欢迎关注!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI