零、Mapreduce的局限性
1、繁杂:不管是开发、还是测试代码,即使写一个word count都要借助于map和reduce这样是很烦的
2、进程级别:MapTask、ReduceTask
IO:网络和磁盘IO
排序:
Memory:
3、不适合迭代处理
不适合实时流式处理,mapreduce只适合离线处理
如下图:
- 各个框架各自为战及单独使用Spark框架
一、Spark概述及特点
Apache Spark is a fast and general engine for large-scale data processing.
Lighting-fast cluster computing ==> 它是计算框架,不负责存储。
Q:Spark能否替换掉Hadoop??
Spark类似于MapReduce都是一个分布式计算框架,Hadoop中的hdfs、zookeeper都是基于论文实现的。
对于MapReduce中key的类型是实现什么接口?writable
http://hadoop.apache.org/docs/stable/api/org/apache/hadoop/io/Writable.html
1.speed
基于内存的处理,肯定快于磁盘。
-
memory
-
thread
-
sort
-
DAG:rdd.map.filter…collect(触发执行) 这种方式被称为是pipeline(流水线式的)
1、 Apache Spark achieves high performance for both batch and streaming data, using a state-of-the-art DAG scheduler, a query optimizer, and a physical execution engine.
-
Apache Spark对于批处理和流处理都能实现高性能,使用最先进的DAG调度器、查询优化器、和一个物理执行引擎。
2. Ease of Use(易用性)
write applications quickly in Java, Scala , Python , R
Spark offers 80 high-level operators that make it easy to build parallel apps,and you can use it interactively(交互式的) from the scala,python,R.
High-level operators(高级别的操作):join、groupBy、count在Spark中都有提供。
df = spark.read.json("logs,json")
df.where("age > 20").select("name.first").show()
//spark's python DataFrame API
Read JSON files with automatic schema information
3.Generality(通用性)
Combine SQL,Streaming,and complex analytic (结合SQL、Streaming、复杂计算)
Spark提供了强有力的支持对于SQL、DataFrames、Mlib对于机器学习。
4.Runs Everywhere
Spark runs on Hadoop,Mesos,standalone,
or in the cloud.it can access diverse data sources including
HDFS, Cassandra, Hbase, and S3.
==>Spark能跑在不同的运行模式上,此处的hadoop可以指的是hdfs存储,
更多的是指yarn;
它支持多样的数据源,spark可以直接对s3,PK哥公司把历史数据丢到S3上。
==>早期起步的大数据公司,Hadoop可以理解为大数据的代表,
数据肯定存放在hdfs上,如果新出的框架不支持HDFS的读写,该怎么办呢,就是不用。解决:直接装一个spark就行,不需要做任何数据迁移的工作。
Spark SQL的外部数据源是核心*****
总结:fast + general + engine
write code:Java/Scala/Python/R interactive shell
run:memory/DAG/thread mode1
二、Spark版本介绍及选择依据参考
接下来的学习部署统一都使用Spark2.4.2版本,2.4.2的含义:
2:major version:APIs change
4:minor version:APIs/features add
2:patch version:only bug fixes
第三位选择:最好选择非0的,因为bug未被修复过
三、如何学习Spark
1、spark官网:
spark.apache.org **********
2、可以选择邮件订阅:
http://spark.apache.org/community.html#mailing-lists
3、查看spark托管在github上代码的网址:
https://github.com/apache/spark
4、源码中的examples:
https://github.com/apache/spark/blob/master/examples/src/main/scala/org/apache/spark/examples/streaming/DirectKafkaWordCount.scala
5、spark user list
http://apache-spark-user-list.1001560.n3.nabble.com/
6、source code(源码面前了无秘密,老子什么水平才能达到源码面前了无秘密啊)
此处为楼主本章学习视频连接:
出处:若泽数据 有一起学习的也可以联系下我QQ:2032677340
链接:https://pan.baidu.com/s/1-PSvfvfd4ZpEggg8NhQ7sQ
提取码:y4c6
四、Spark Survey
学Spark,必定学习Scala,加油吧。