前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Flume pull方式和push方式整合

Flume pull方式和push方式整合

作者头像
Meet相识
发布2018-09-12 17:02:57
9070
发布2018-09-12 17:02:57
举报
文章被收录于专栏:技术专栏技术专栏
  • Pull方式

Flume Agent 编写

代码语言:javascript
复制
# Name the components on this agent
simple-agent.sources = netcat-source
simple-agent.sinks = spark-sink
simple-agent.channels = memory-channel

# Describe/configure the source
simple-agent.sources.netcat-source.type = netcat
simple-agent.sources.netcat-source.bind = localhost
simple-agent.sources.netcat-source.port = 44444

# Describe the sink
simple-agent.sinks.spark-sink.type = org.apache.spark.streaming.flume.sink.SparkSink
simple-agent.sinks.spark-sink.hostname =localhost
simple-agent.sinks.spark-sink.port =41414
simple-agent.sinks.spark-sink.channel = memoryChannel

# Use a channel which buffers events in memory
simple-agent.channels.memory-channel.type = memory


# Bind the source and sink to the channel
simple-agent.sources.netcat-source.channels = memory-channel
simple-agent.sinks.spark-sink.channel = memory-channel

启动Flume

代码语言:javascript
复制
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的编写

代码语言:javascript
复制
# Name the components on this agent
simple-agent.sources = netcat-source
simple-agent.sinks = avro-sink
simple-agent.channels = memory-channel

# Describe/configure the source
simple-agent.sources.netcat-source.type = netcat
simple-agent.sources.netcat-source.bind = localhost
simple-agent.sources.netcat-source.port = 44444

# Describe the sink
simple-agent.sinks.avro-sink.type = avro
simple-agent.sinks.avro-sink.hostname = localhost
simple-agent.sinks.avro-sink.port = 41414

# Use a channel which buffers events in memory
simple-agent.channels.memory-channel.type = memory


# Bind the source and sink to the channel
simple-agent.sources.netcat-source.channels = memory-channel
simple-agent.sinks.avro-sink.channel = memory-channel

启动flume

代码语言:javascript
复制
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控制台的输出

提交到服务器

代码语言:javascript
复制
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
代码语言:javascript
复制
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
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2018.06.20 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档