Spark Streaming(1)Spark Streaming Concept and Zookeeper/Kafka on Local
I was using Spark for more than 1 year now, from 0.7 to 0.9 on production. Recently I came back to Spark and considering upgrade the version to 1.3.1. There are a lot of new things and good idea after 0.9.
1. Introduction
Standalone Cluster
master machine is a single point.
https://spark.apache.org/docs/latest/spark-standalone.html#standby-masters-with-zookeeper
We have options #1 use zookeeper to manage several masters
spark-env.sh,
spark.deploy.recoveryMode, default value is NONE, should be changed to ZOOKEEPER
spark.deploy.zookeeper.url, eg, 192.168.1.100:2181, 192.168.1.102:2181
spark.deploy.zookeeper.dir, eg, /spark
For spark job, standalone cluster will have all the jars and files in the working directory, we need to set spark.worker.cleanup.appDataTtl to clean them. But YARN cluster will automatically do that.
Cluster Job Schedule
standalone cluster - FIFO, spark.cores.max and spark.deploy.defaultCores and others to set how much resource one application can use.
mesos
YARN - —num-executor, —executor-memory and etc.
Spark Streaming
source from kafka, flume, twitter, zeromq, kinesis
original DStream time1 time2 time3 time4 time5
windowed DStream window time1 window time2
checkpoint
ssc.checkpoint(hdfsPath), usually checkpoint time will be 5 - 10 times sliding
dstream.checkpoint(checkpointInterval)
receive the streaming in parallel,
val numstreams = 5
val kafkaStreams = (1 to numStreams).map { i => KafkaUtils.createStream(…) }
val unifiedStream = streamingContext.union(kafkaStreams)
Recovery the Task from Checkpoint
def functionToCreateContext(): StreamingContext = {
val ssc = new StreamingContext(...)
val lines = sac.socketTextStream(...)
...
ssc.checkpoint(checkpointDirectory)
ssc
}
val context = StreamingContext.getOrCreate()checkpointDirectory, functionToCreateContext _)
context . ...
context. start()
context.awaitTermination()
2. Zookeeper
http://sillycat.iteye.com/blog/2015175
Install zookeeper
> wget http://apache.mesi.com.ar/zookeeper/stable/zookeeper-3.4.6.tar.gz
Unzip that, Place it in the working directory, add the bin to the path.
Set up the configuration
> cp conf/zoo_sample.cfg conf/zoo.cfg
Start the Server
>zkServer.sh start zoo.cfg
Check status
>zkServer.sh status
Or
>jps
2194
2294 QuorumPeerMain
2330 Jps
Connect from client
>zkCli.sh -server localhost:2181
zookeeper>help
zookeeper>quit
3. Kafka
Download the binary with version 8.2.1
> wget http://psg.mtu.edu/pub/apache/kafka/0.8.2.1/kafka_2.10-0.8.2.1.tgz
Place that in the working directory and Add that to path
Command to start kafka
> kafka-server-start.sh config/server.properties
Create a topic
> bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test
Created topic "test".
List the topic
> bin/kafka-topics.sh --list --zookeeper localhost:2181
test
Producer sending some messages
> bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test
Start a Consumer
> bin/kafka-console-consumer.sh --zookeeper localhost:2181 --topic test --from-beginning
References:
http://uohzoaix.github.io/studies/categories/#spark
spark streaming
http://dataunion.org/15193.html
http://dataunion.org/6308.html
http://colobu.com/2015/01/05/kafka-spark-streaming-integration-summary/
分享到:
相关推荐
使用 Zookeeper 管理 Kafka offset,利用 SparkStreaming 进行流处理。完整代码示例。
一个手动管理spark streaming集成kafka时的偏移量到zookeeper中的小项目
项目以宜信贷风控系统实时数据采集系统为背景,主要描述了技术架构、核心技术难点及代码实现全过程,涉及技术包括但不限于:Kafka\zookeeper,Spark,SparkStreaming,HBase,实时访问技术,爬虫技术等
生成的数据主要是模拟某学习网站学习视频课程的访问量(其中*以“ / class”开头的表示实战课程,然后通过流水线Flume + Kafka + SparkStreaming进行实时日志的收集,HBase来存储数据)*注意事项(使用的软件工具及...
这是使用Spark Streaming,Kafka和Elasticsearch进行近实时流处理的示例。 此项目的先决条件 Elasticsearch设置 i)Elasticsearch 6.3.0或最新版本并将其解压缩。 ii)运行以下命令。 $ bin/elasticsearch Kafka...
主要功能提供了快速使用 spark streaming + kafka 开发流式程序的骨架,示例中的代码大部分都加上了详细的注释提供了手动管理kafka的offset存储到zookeeper的方法,并解决了一些bug,如kafka扩容分区,重启实
Spark Streaming 五、Flink 核心概念综述 开发环境搭建 Data Source Data Transformation Data Sink 窗口模型 状态管理与检查点机制 Standalone 集群部署 六、HBase 简介 系统架构及数据结构 基本环境搭建 集群环境...
使用Spark Streaming进行旧金山犯罪统计 在此项目中,我们分析了从Kaggle提取的SF犯罪率的真实数据集,以使用Apache Spark结构化流技术提供统计分析。 先决条件 在继续之前,有必要安装下一个软件: Scala2.11 ...
使用以下命令启动 zooKeeper 节点,直到此目录 ../kafka_2.9.2-0.8.1.1/bin ./zookeeper-server-start.sh ../config/zookeeper.properties 湾使用以下命令启动 kafka 代理,直到 ../kafka_2.9.2-0.8.1.1/bin ./...
该项目提供了一个在使用spark streaming2.1+kafka0.9.0.0的版本集成时,手动存储偏移量到zookeeper中,因为自带的checkpoint弊端太多,不利于 项目升级发布,并修复了一些遇到的bug,例子中的代码已
使用Java 8,Spark Streaming,Kafka, 一个演示项目,使用Spark Streaming来分析Twitter上的流行主题标签。 数据来自Twitter Streaming API源,并提供给Kafka。 消费者com.twitter.producer.service从Kafka接收...
包括SparkCore、SparkSQL、SparkStreaming、DataFrame,以及介绍Scala、SparkAPI、SparkSQL、SparkStreaming、DataFrame原理和CDH版本环境下实战操作,其中Flume和Kafka属于Apache*开源项目也放在本篇讲解。...
笔记: 从 Kafka 流式传输并将事件计数写入 Phoenix 的示例应用程序您需要更新 zookeeper URL 以在您的环境中工作。 运行: sbt "run-main SparkStreamingPhoenix" 这个项目需要./lib中的'phoenix-4.4.0-HBase-###-...
介绍 基于Spark的高校数据分析系统 。同时实现了Spark-core(被注释了);Spark-ML,Spark-streaming。...运行环境:centos 6.x、java、kafka、zookeeper、Flume、Hbase、HDFS、YARN、Spark、MySQl。
(我正在维护该项目,并添加有关Hadoop分布式模式,在云上部署Hadoop,Spark高性能,Spark流应用程序演示,Spark分布式集群等的更多演示。请给我一些支持。) 架构师大数据应用 数据输入:Apache Sqoop,Apache ...
We'll also show you how to build asynchronous streaming systems using Kafka Streams and Apache Spark. Finally, we wind up by aggregating your logs in Kafka, creating your own metrics, and monitoring...
期望能够设置Zookeeper和Kafka Broker来运行示例。 或使用Confluent平台。 Kafka Stream示例都具有相关的测试,而不是运行Jar。 请检查各个模块自述文件以检查其运行方式。 单元测试 检出每个文件的单元测试,以查看...
Streaming,入侵检测采用Spark MLlib,数据存储使用HDFS与Redis,可视化采用Flask、SocketIO、Echarts、Bootstrap 项目使用 简易使用说明 开箱即用,直接在v2目录中使用 python3 app.py # 开启后直接访问,即可...
大数据技术培训教程。视频+源码 Scala编程进阶 Spark核心编程进阶 Spark内核原理进阶 Spark Streaming实战开发进阶 hadoop zookeeper kafka资源
来源是Kafka主题,这些事件作为事件流被吸收聚合引擎是Flink 计数存储在Redis中近似计数由Redis公开的HLL方法提供设置 :- 安装Kafka(kafka_2.11-1.0.0) 安装Redis(4.0.10) 启动zookeeper-> ./bin/zookeeper-...