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 ...
随机推荐
- JS区分中英文字符的两种方法: 正则和charCodeAt()方法
1.正则regExpForm.onblur=function(){ entryVal=this.value; entryLen=entryVal.length; cnChar=entryVal.mat ...
- Mysql锁机制--读锁
Mysql 系列文章主页 =============== 1 准备数据 1.1 建表 1.1.1 建立 Employee表 DROP TABLE IF EXISTS employee; CREATE ...
- Gradle入门--基本配置
Gradle配置: Gradle构建脚本 build.gradle Gradle属性文件 gradle.properties Gradle设置文件 settings.gradle build.grad ...
- 【问底】徐汉彬:亿级Web系统搭建——单机到分布式集群
http://www.csdn.net/article/2014-11-06/2822529/3 大规模流量的网站架构,从来都是慢慢"成长"而来.而这个过程中,会遇到很多问题,在不 ...
- Tomcat关闭日志输出
tomcat中禁用catalina.out的输出,又可能很大. 1.直接修改catalina.sh文件的输出语句. 在文件中找到以下内容. if [ -z "$CATALINA_OUT&qu ...
- mongoDB安装和启动
安装: 1. mongodb(V3.4.7)安装包下载地址:https://www.mongodb.com/download-center#community 下载成功后直接运行,安装模式选择cust ...
- javaweb面试题
1.Tomcat的优化经验 答:去掉对web.xml的监视,把JSP提前编辑成Servlet:有富余物理内存的情况下,加大Tomcat使用的JVM内存. 2.什么是Servlet? 答:可以从两个方面 ...
- Linux: Check version info
一.查看Linux内核版本命令(两种方法): 1.cat /proc/version [root@localhost ~]# cat /proc/version Linux version 2.6.1 ...
- ROS机器人程序设计(原书第2版)补充资料 kinetic
Effective Robotics Programming with ROS Third Edition Find out everything you need to know to build ...
- APP自动化框架LazyAndroid使用手册(3)--核心API介绍
作者:黄书力 概述 在前一篇博文中,简要介绍了一款安卓UI自动化测试框架LazyAndroid (http://blog.csdn.net/kaka1121/article/details/53204 ...
