一、handoop

开源的大数据框架。

框架的核心组件

  • HDFS: Hadoop Distributed File System
  • MapReduce: processing unit
  • YARN: Yet Another Resource Negotiator
  • Hadoop Common:collection of common utilities and libraries that support other Hadoop modules.

HDFS

  • starage layer of Hadoop
  • split files into blocks, creates replicas of the blocks, stores them on different machines(block是读写的最小单位,默认的大小根据系统,可能是64M或者128M)
  • provide access to streaming data(streaming意思是数据流是持续的,而非批量式的)
  • 使用命令行工具与Hadoop交互
  • write once read many

HDFS中的Nodes概念:

在这里插入图片描述

rack:40-50个data nodes(secondary node)的集合

rack awareness in HDFS指的是选择node的时候要选择挨得最近的rack,这样可以减少network traffic. 实现这一目标是依赖name node(primary node),其中保存着rack的相关信息。这种做法同样有利于replication

HDFS的架构:
在这里插入图片描述

mapreduce

并行计算框架,包含两个主要任务,map和reduce。能够应对各种数据类型:关系,半关系,非关系型。

handoop 生态系统

  • Ingest: Flume & Sqoop
  • Store:HDFS & HBase(allow dynamic change)
  • Process and Analyze:Pig & Hive
  • Access:Impala & Hue

举个例子:

我们传入一个word文件,查看文件中有多少个字。下图说明数据具体流程。

在这里插入图片描述

二、spark 相关概念

特性

  • in memory
  • be written in Scala and work in JVM
  • distributed computing

spark的组件:

在这里插入图片描述

spark架构

Driver是公司的CEO,Cluster是部门负责人,executor是打工仔,跟真实的物理层打交道。

Spark context将任务分解到cluster上,

Cluster Manager来管理cluster上资源的分配。

在这里插入图片描述

Driver program驱动程序

单进程,driver program 运行用户的程序给cluster分配工作(Job);
Spark Context 将job 分解为tasks ,将data分解为partitions,小的tasks面向partitions可以在Cluster上的多个worker node平行执行。
在这里插入图片描述

driver program有两种deploy Modes
在这里插入图片描述

Executor
多进程,平行处理cluster的工作。
每个worker node可以启动执行程序Executor,来处理task,每个executor会给分配几个core,每个core运行一个task。
所以提高并行效果,需要增多cores或者Executors.
执行完成之后,要么生成新的RDD(transform)要么返回给driver(Action)

stage and shuffles

stage的概念其实是和shuffle绑定在一起的。当有shuffle的时候,就将整个job分割开为一系列tesks,分割的界限就是shuffle操作。
在这里插入图片描述
shuffle是耗费时间的,因为需要序列化,以及需要和io打交道。但是有些操作是必须和其他的partitions打交道,比如groupby().

举个例子:
在这里插入图片描述
stage1可能是个map操作.

建议在collection之前使用reduce,因为在大数据上使用collection,很容易占满内存

cluster manager

cluster manager is essential for scaling big data. 有如下几种:

  • Spark Standalone: Spark启动就有,最适合simple cluster的应用场景
    在这里插入图片描述
    设置流程如下所示:
    在这里插入图片描述

  • Apache Hadoop YARN

  • 在这里插入图片描述

  • Apache Mesos

  • Kubernetes:用来运行容器应用的开源系统,主要解决集群资源调度的问题。
    使用Kubernetes的优势:

  1. Kubernetes runs containerized applications on a cluster ​providing flexible, automated deployments.
  2. Kubernetes provides developers with a portable, consistent experience whether working with an application on-premises or in the cloud.
  3. Kubernetes benefits application performance with features including network service discovery, cluster load balancing, automated scaling, and orchestrated storage.
    在K8s上启动Spark Application:
    在这里插入图片描述

Local Mode

在这里插入图片描述
使用local mode 启动方法:

在这里插入图片描述

如何运行一个Apache Spark Application

unifies interface: spark-submit
在这里插入图片描述

或者使用spark shell一键启动。

Logo

开源、云原生的融合云平台

更多推荐