sparkStreaming介绍与运行方式

Spark Streaming is an extension of the core Spark API that enables scalable, 
high-throughput, 
fault-tolerant 
stream processing of live data streams.


Spark Streaming个人的定义:
将不同的数据源的数据经过Spark Streaming处理之后将结果输出到外部文件系统


特点
低延时
能从错误中高效的恢复:fault-tolerant 
能够运行在成百上千的节点
能够将批处理、机器学习、图计算等子框架和Spark Streaming综合起来使用


Spark Streaming是否需要独立安装?


One stack to rule them all : 一栈式




GitHub
https://github.com/apache/spark


spark-submit的使用


使用spark-submit来提交我们的spark应用程序运行的脚本(生产)
./spark-submit --master local[2] \
--class org.apache.spark.examples.streaming.NetworkWordCount \
--name NetworkWordCount \
/home/hadoop/app/spark-2.2.0-bin-2.6.0-cdh5.7.0/examples/jars/spark-examples_2.11-2.2.0.jar hadoop000 9999


如何使用spark-shell来提交(测试)
./spark-shell --master local[2]


import org.apache.spark.streaming.{Seconds, StreamingContext}


val ssc = new StreamingContext(sc, Seconds(1))
val lines = ssc.socketTextStream("hadoop000", 9999)
val words = lines.flatMap(_.split(" "))
val wordCounts = words.map(x => (x, 1)).reduceByKey(_ + _)
wordCounts.print()
ssc.start()
ssc.awaitTermination()






工作原理:粗粒度
Spark Streaming接收到实时数据流,把数据按照指定的时间段切成一片片小的数据块,
然后把小的数据块传给Spark Engine处理。



















































猜你喜欢

转载自blog.csdn.net/qq_35394891/article/details/80593304
今日推荐