Spark Streaming + Flume整合官网文档阅读及运行示例
- 当Flume+Spark Streaming程序运行时,需要保证Spark的一个worker运行在同一台机器上.
- Flume可以通过配置文件指定推送到该台机器的一个端口.
|
agent.sinks = avroSink
agent.sinks.avroSink.type = avro
agent.sinks.avroSink.channel = memoryChannel
agent.sinks.avroSink.hostname = <选择机器的ip地址>
agent.sinks.avroSink.port = <选择机器的端口号>
|
documentation 获得更多的配置信息
|
groupId = org.apache.spark
artifactId = spark-streaming-flume_2.10
version = 1.5.0
|
|
import org.apache.spark.streaming.flume._
val flumeStream = FlumeUtils.createStream(streamingContext, [选择的机器ip], [选择的机器端口号])
|
section)
|
object FlumeLog { def main(args: Array[String]) { StreamingExamples.setStreamingLogLevels() val host = "localhost" val port = 19999 val batchInterval = Milliseconds(2000) // Create the context and set the batch size val sparkConf = new SparkConf().setAppName("FlumeEventCount") val ssc = new StreamingContext(sparkConf, batchInterval) // Create a flume stream val stream = FlumeUtils.createStream(ssc, host, port, StorageLevel.MEMORY_ONLY_SER_2) // Print out the count of events received from this server in each batch stream.count().map(cnt => "Received " + cnt + " flume events." ).print() ssc.start() ssc.awaitTermination() } } |
用于统计flume的event事件.
(b)编写flume的配置文件
|
a1.channels = c1 a1.sinks = k1 a1.sources = r1 a1.sinks.k1.type = avro a1.sinks.k1.channel = c1 a1.sinks.k1.hostname = localhost a1.sinks.k1.port = 19999 a1.sources.r1.type = exec a1.sources.r1.command = tail -F /home/file/bigdatatest/datalake/SougouQ.data a1.sources.r1.bind = localhost a1.sources.r1.port = 44444 a1.sources.r1.channels = c1 a1.channels.c1.type = memory a1.channels.c1.capacity = 1000 a1.channels.c1.transactionCapacity = 100 |
其中的sinks按照文档中的进行配置.sources用于从日志文件SougouQ.data中读取数据.SougouQ.data中的数据动态生成.
(c)运行
首先启动Spark Streaming程序,可以看到如下输出信息:

Approach using a Custom Sink)
- Flume将数据推送到sink中,并且数据保持buffered状态
- Spark Streaming使用一个可靠的Flume接收器(reliable Flume receiver )和转换器(transaction)从sink拉取数据.只要当数据被接收并且被Spark
Streaming备份后,转换器才运行成功.
guarantees ).然而,这种模式需要为Flume配置一个正常的sink.以下为配置步骤
link):
|
link).:
|
link):
|
|
documentation 中查看.
|
section)
object FlumeLogPull {
|
host, port, StorageLevel.MEMORY_ONLY_SER_2)
|
a1.channels = c1 a1.sinks = k1 a1.sources = r1
a1.sinks.k1.type = org.apache.spark.streaming.flume.sink.SparkSink
a1.sinks.k1.channel = c1 a1.sinks.k1.hostname = localhost a1.sinks.k1.port = 19999 a1.sources.r1.type = exec
a1.sources.r1.command = tail -F /home/file/bigdatatest/datalake/SougouQ.data a1.sources.r1.bind = localhost a1.sources.r1.port = 44444 a1.sources.r1.channels = c1 a1.channels.c1.type = memory
a1.channels.c1.capacity = 100000 a1.channels.c1.transactionCapacity = 100000 |

Spark Streaming + Flume整合官网文档阅读及运行示例的更多相关文章
- mongodb官网文档阅读笔记:与写性能相关的几个因素
Indexes 和全部db一样,索引肯定都会引起写性能的下降,mongodb也没啥特别的,相对索引对读性能的提示,这些消耗通常是能够接受的,所以该加入的索引还是要加入.当然须要慎重一些.扯点远的,以前 ...
- mongodb官网文档阅读笔记:write concern
write concern保证了mongodb写操作的级别,不同的write concern设置相应了不同级别的写操作.设置的级别越高.那么写操作的性能的持久化做得越好,可是写性能也就越差. mong ...
- 部署openstack的官网文档解读mysql的配置文件
部署openstack的官网文档解读mysql的配置文件(使用与ubutu和centos7等系统) author:headsen chen 2017-10-12 16:57:11 个人原创,严禁转载 ...
- redis过期机制(官网文档总结)
官网地址:https://redis.io/commands/expire redis过期定义如下: Set a timeout on key. After the timeout has expir ...
- Hortonworks官网文档怎么找?
Hortonworks官网文档怎么找? 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 俗话说,授人予鱼不如授人予渔,网上部署HDP的部署方式的博客有很多,看得你是眼花缭乱的.其实万 ...
- Unity shader 官网文档全方位学习(一)
转载:https://my.oschina.net/u/138823/blog/181131 摘要: 这篇文章主要介绍Surface Shaders基础及Examples详尽解析 What?? Sha ...
- 【VR】Leap Motion 官网文档 FingerModel (手指模型)
前言: 感谢关注和支持这个Leap Motion系列翻译的朋友们,非常抱歉因为工作原因非常久没有更新,今后这个翻译还会继续(除非官方直接给出中文文档).本篇献给大家的是 <FingerModel ...
- Spring Security 官网文档学习
文章目录 通过`maven`向普通的`WEB`项目中引入`spring security` 配置 `spring security` `configure(HttpSecurity)` 方法 自定义U ...
- mybatis官网文档mybatis_doc
在平时的学习中,我们可以去参考官网的文档来学习,这个文档有中文的,方便我们去阅读,而且这里的分类很详细. 官网文档链接:http://www.mybatis.org/mybatis-3/zh/inde ...
随机推荐
- Java阻塞队列的实现
阻塞队列与普通队列的区别在于,当队列是空的时,从队列中获取元素的操作将会被阻塞,或者当队列是满时,往队列里添加元素的操作会被阻塞.试图从空的阻塞队列中获取元素的线程将会被阻塞,直到其他的线程往空的队列 ...
- Python小代码_11_生成小于 n 的裴波那契数列
def fib(n): a, b = 1, 1 while a < n: print(a, end=' ') a, b = b, a + b fib(100000) #输出结果 #1 1 2 3 ...
- dokcer自动化构建部署java web 基于jenkins+maven+nuxus容器
# dokcer自动化构建部署java web 基于jenkins+maven+nuxus容器 #环境centos 7.4 docker 18.03.0-ce # nuxus,创建maven本地源(可 ...
- 两个activity之间透明过渡效果和经验
来看下效果图: 大致效果解释: 1. 当用户点击登录时logo下滑一定距离 2. 下滑后旋转90时 变化图标 3. 继续旋转90度 4. 然后移动到左上角 透明度渐变到上个activity 最后销毁当 ...
- linux系统性能监控--内存利用率
Linux提供了对物理内存进行合理.高效的访问并可以访问潜在的海量虚存的技术.虚存通常稍多于操作系统实际拥有的内存容量,以便将较少使用的数据卸载到磁盘存储器上,同时又呈现出系统拥有大量物理内存的假象. ...
- sublime snippet 示例
<snippet> <content><