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 学习笔记2 面向对象(上)
类和对象 类是某一批对象的抽象,可以把类理解成某种概念.对象是一个具体存在的实体.类和对象是面向对象的核心. 类定义的是多个实例的特征,类不是具体存在,实例才是具体存在. 定义类(class)的语法: ...
- 使用Fiddler改变线上js文件的引用路径
一般的项目开发都是先在本地环境开发,测试环境中完成测试,最后再提交到线上环境. 但是由于版本构建工具有时出现bug或者一些缓存的因素导致测试环境代码可能和线上不一样,这是多么蓝瘦的事情.此处说的是在原 ...
- 使用linux部署tomcat项目
1.下载对应的Tomcat服务器包 Apache Tomcat官网下载: http://tomcat.apache.org/download-70.cgi 比如我们使用的是 apache-tomca ...
- C# 基础问答
1.静态变量和非静态变量的区别? 2.const 和 static readonly 区别? 3.extern 是什么意思? 4.abstract 是什么意思? 5.internal 修饰符起什么作用 ...
- Android颜色配置器
一.Android Color设置 1.在xml文件中 想设置颜色直接设置background的属性或者其他的color属性.随便设置一个颜色如#000,再点击左边的颜色方块,弹出颜色选择器选择颜色 ...
- Spring Boot Cache Redis缓存
1.集成MyBatis 1.1.引入maven依赖 1.2.生成Mapper 具体可以看MyBatis Generator官网 http://www.mybatis.org/generator/run ...
- Bootstrap3 表格-基本表格
为任意 <table> 标签添加 .table 类可以为其赋予基本的样式 - 少量的内补(padding)和水平方向的分隔线.这种方式看起来很多余!?但是我们觉得,表格元素使用的很广泛,如 ...
- (Java)微信之个人公众账号开发(二)——接收并处理用户消息(下)
接下来,我们再讲一下图文消息: 如图: 大家可以先从开发者文档中了解一下图文消息的一些参数: 如上图,用户回复4时,ipastor返回了几条图文消息,上图中属于多图文消息,当然还有单图文消息,图文消息 ...
- 没事不要在for循环期间增减迭代序列的成员
>>> arr=[4, 4, 9, 7, 7] >>> for i,a in enumerate(arr): arr.pop(i) print(i,a) 4 0 4 ...
- Centos6.5 mysql安装
cenos中安装软件使用yum进行安装,小米加步枪不如ak47. 第1步.yum安装mysql yum -y install mysql-server 第2步.设置开机启动 chkconfig ...
