Flume pull方式和push方式整合
发布日期:2021-08-25 15:35:21 浏览次数:14 分类:技术文章

本文共 2466 字,大约阅读时间需要 8 分钟。

  • Pull方式

Flume Agent 编写

# Name the components on this agentsimple-agent.sources = netcat-sourcesimple-agent.sinks = spark-sinksimple-agent.channels = memory-channel# Describe/configure the sourcesimple-agent.sources.netcat-source.type = netcatsimple-agent.sources.netcat-source.bind = localhostsimple-agent.sources.netcat-source.port = 44444# Describe the sinksimple-agent.sinks.spark-sink.type = org.apache.spark.streaming.flume.sink.SparkSinksimple-agent.sinks.spark-sink.hostname =localhostsimple-agent.sinks.spark-sink.port =41414simple-agent.sinks.spark-sink.channel = memoryChannel# Use a channel which buffers events in memorysimple-agent.channels.memory-channel.type = memory# Bind the source and sink to the channelsimple-agent.sources.netcat-source.channels = memory-channelsimple-agent.sinks.spark-sink.channel = memory-channel复制代码

启动Flume

flume-ng agent \--name simple-agent \--conf conf $FLUME_HOME/conf \--conf-file $FLUME_HOME/conf/flume_pull_streaming.conf \-Dflume.root.logger=INFO,console &复制代码
  • Push方式

Flume Agent的编写

# Name the components on this agentsimple-agent.sources = netcat-sourcesimple-agent.sinks = avro-sinksimple-agent.channels = memory-channel# Describe/configure the sourcesimple-agent.sources.netcat-source.type = netcatsimple-agent.sources.netcat-source.bind = localhostsimple-agent.sources.netcat-source.port = 44444# Describe the sinksimple-agent.sinks.avro-sink.type = avrosimple-agent.sinks.avro-sink.hostname = localhostsimple-agent.sinks.avro-sink.port = 41414# Use a channel which buffers events in memorysimple-agent.channels.memory-channel.type = memory# Bind the source and sink to the channelsimple-agent.sources.netcat-source.channels = memory-channelsimple-agent.sinks.avro-sink.channel = memory-channel复制代码

启动flume

flume-ng agent \--name simple-agent \--conf conf $FLUME_HOME/conf \--conf-file $FLUME_HOME/conf/flume_push_streaming.conf \-Dflume.root.logger=INFO,console &复制代码

==注意在本地和服务器上切换的时候需要修改flume的sink的hostname==

本地测试总结

  1. 启动SparkStreaming作业
  2. 启动flume agent
  3. 通过telnet输入数据,观察IDEA控制台的输出

提交到服务器

spark-submit \--class com.gwf.spark.FlumePushWordCount \--master local[2] \--packages org.apache.spark:spark-streaming-flume_2.11:2.2.0 \/Users/gaowenfeng/Documents/IDE/newsell/spark-train/target/spark-train-1.0-SNAPSHOT.jar localhost 41414复制代码
spark-submit \--class com.gwf.spark.FlumePushWordCount \--master local[2] \/Users/gaowenfeng/Documents/IDE/newsell/spark-train/target/spark-train-1.0-SNAPSHOT.jar localhost 41414复制代码

转载地址:https://blog.csdn.net/weixin_33858336/article/details/88001758 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:[译] ASP.NET Core 中的框架级依赖注入
下一篇:Spark SQL/Hive调优

发表评论

最新留言

能坚持,总会有不一样的收获!
[***.219.124.196]2024年04月14日 16时59分35秒

关于作者

    喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!

推荐文章