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 ...
随机推荐
- jquery easyui panel title文字格式设置
$('#txtLeftPercent').panel({ title: '剩余权重:' + '<b style="color:red">' + 100 + '%< ...
- Safari 3D transform变换z-index层级渲染异常
(猛戳来源:http://www.zhangxinxu.com/wordpress/?p=5569)
- django.db.utils.ProgrammingError: 1146 的解决办法
在models中设置完数据库相关的东西后执行命令 python manage.py makemigrations 此处无错误 再次执行 python manage.py migrate 发生报错 错误 ...
- Java 程序运行过程中的内存分析
作为 java 程序员,都应该知道 Java 程序运行在 JVM(Java Virtual Machine,Java 虚拟机)上,可以把 JVM 理解成 Java 程序和操作系统之间的桥梁,JVM 实 ...
- centos 6安装 H3C iNode 上网客户端
我的安装目录是/usr/iNode 直接把客户端安装包拷到这个文件夹下然后解压: #rar x iNode2.-R0162.rar 然后进入文件夹,里边有一个install.sh文件,这是一个安装文件 ...
- ABP文档笔记 - 通知
基础概念 两种通知发送方式 直接发送给目标用户 用户订阅某类通知,发送这类通知时直接分发给它们. 两种通知类型 一般通知:任意的通知类型 "如果一个用户发送一个好友请求,那么通知我" ...
- Android POJO 转换器 —> RapidOOO
博客搬迁至https://blog.wangjiegulu.com RSS订阅:https://blog.wangjiegulu.com/feed.xml 原文链接:https://blog.wang ...
- python打造一个分析网站SQL注入的脚本
前言: 昨天晚上其实就已经写完代码.只不过向FB投稿了,打算延迟一晚上在写博客 所有才到今天早上写.好了,接下来进入正题. 思路: 1.从网站源码中爬取那些类适于:http://xxx.com/xx. ...
- leetcode刷题笔记342 4的幂
题目描述: 给定一个整数 (32位有符整数型),请写出一个函数来检验它是否是4的幂. 示例:当 num = 16 时 ,返回 true . 当 num = 5时,返回 false. 问题进阶:你能不使 ...
- Python列表函数&方法
Python包含以下函数: 序号 函数 1 cmp(list1, list2)比较两个列表的元素 2 len(list)列表元素个数 3 max(list)返回列表元素最大值 4 min(list)返 ...
