Spark集群权威指南

本文详细介绍了Spark的运行模式,包括Local、Standalone、YARN和Mesos,并比较了不同部署方式。在集群模式中,讲解了Spark的组件概念,如Driver、Executor和Stage。此外,还提供了在Hadoop集群上安装、配置Spark的步骤,包括解压安装、环境变量配置、验证安装。同时,文中还涉及了安装部署Hive,配置MySQL作为元数据库,并解决启动过程中的问题。最后,讨论了SparkSQL的配置和验证。
摘要由CSDN通过智能技术生成


Spark集群权威指南


Spark运行模式

Spark部署模式主要有四种:最简单就是Local模式(单机本地模式)、当然 Spark 还有自带的Standalone模式(使用Spark自带的简单集群管理器)。还有单机伪分布式模式,复杂的则运行在集群中,目前能很好的运行在 YARN模式(使用YARN作为集群管理器)和Mesos模式(使用Mesos作为集群管理器)中。对于大多数情况 Standalone 模式就足够了,如果企业已经有 Yarn 或者 Mesos 环境,也是很方便部署的。需要说明的是,当安装好Spark以后,里面就自带了scala环境。

local(本地模式):常用于本地开发测试,本地还分为local单线程和local-cluster多线程;

standalone(集群模式):典型的Mater/slave模式,不过也能看出Master是有单点故障的;Spark支持ZooKeeper来实现 HA

on yarn(集群模式): 运行在 yarn 资源管理器框架之上,由 yarn 负责资源管理,Spark 负责任务调度和计算

on mesos(集群模式): 运行在 mesos 资源管理器框架之上,由 mesos 负责资源管理,Spark 负责任务调度和计算

on cloud(集群模式):比如 AWS 的 EC2,使用这个模式能很方便的访问 Amazon的 S3;Spark 支持多种分布式存储系统:HDFS 和 S3


分布式部署方式比较

standalone模式自带完整的服务,可单独部署到一个集群中,无需依赖任何其他资源管理系统从一定程度上说,该模式是Mesos和YARN模式的基础

Spark On Mesos模式。这是很多公司采用的模式,官方推荐这种模式。

Spark On YARN模式。这是一种最有前景的部署模式。

参考:http://blog.csdn.net/zhangqiagn1104/article/details/49800541

上面涉及到Spark的许多部署模式,究竟哪种模式好这个很难说,需要根据你的需求,如果你只是测试Spark Application,你可以选择local模式。而如果你数据量不是很多,Standalone 是个不错的选择。当你需要统一管理集群资源(Hadoop、Spark等),可以选择Yarn或mesos,但是这样维护成本就会变高。

在集群模式中会遇到的概念:

应用(Application):构建在Spark上的用户程序,包括驱动程序和集群上的执行器;

应用jar包(Application jar):一个包含用户的Spark应用的jar文件。在一些情况下用户可能会创建一个超级jar包(Uber jar),来包含应用和依赖。用户的jar包不要包含Spark和Hadoop的依赖,这些会在运行时添加;

驱动程序(Driver program):就是执行应用中的main方法并创建SparkContext的进程;

集群管理器(Clustermanager):一个可以在集群上获得资源的外部组件(比如standalone,Mesos和YARN);

部署模式(Deploy mode):部署模式用来分别驱动程序在哪里运行。在集群(cluster)模式,框架将驱动程序启动在急群众。在客户端(client)模式,驱动程序在集群外启动;

工作器节点(Worker node):集群中任何可以运行应用的节点;

执行器(Executor):在工作器节点上运行应用的进程,可以执行任务,保存数据。每个应用都有自己的执行器;

任务(Task):发送给一个执行器的一组计算;

工作(Job):由一组执行Spark行动操作的任务构成的并行计算,可以在驱动程序的日志中看到这个术语;

阶段(Stage):每一个工作分解为若干个小的一组任务叫做阶段(和MapReduce中的map阶段和reduce阶段类似)。

 

 

解压并安装Spark

解压Spark

该部分的安装需要在 Hadoop 已经成功安装的基础上,并且要求 Hadoop 已经正常启动。我们将 Spark 安装在 HadoopMaster 节点上。所以下面的所有操作都在HadoopMaster 节点上进行。

Spark版本spark-2.1.1

命令:

sudotar –zxvf /home/hadoop/Desktop/ spark-2.1.1-b

Welcome to this first edition of Spark: The Definitive Guide! We are excited to bring you the most complete resource on Apache Spark today, focusing especially on the new generation of Spark APIs introduced in Spark 2.0. Apache Spark is currently one of the most popular systems for large-scale data processing, with APIs in multiple programming languages and a wealth of built-in and third-party libraries. Although the project has existed for multiple years—first as a research project started at UC Berkeley in 2009, then at the Apache Software Foundation since 2013—the open source community is continuing to build more powerful APIs and high-level libraries over Spark, so there is still a lot to write about the project. We decided to write this book for two reasons. First, we wanted to present the most comprehensive book on Apache Spark, covering all of the fundamental use cases with easy-to-run examples. Second, we especially wanted to explore the higher-level “structured” APIs that were finalized in Apache Spark 2.0—namely DataFrames, Datasets, Spark SQL, and Structured Streaming—which older books on Spark don’t always include. We hope this book gives you a solid foundation to write modern Apache Spark applications using all the available tools in the project. In this preface, we’ll tell you a little bit about our background, and explain who this book is for and how we have organized the material. We also want to thank the numerous people who helped edit and review this book, without whom it would not have been possible.
本资源为网页,不是PDF Apache Spark 2.0.2 中文文档 Spark 概述 编程指南 快速入门 Spark 编程指南 概述 Spark 依赖 Spark 的初始化 Shell 的使用 弹性分布式数据集(RDDS) 并行集合 外部数据集 RDD 操作 RDD 持久化 共享变量 Broadcast Variables (广播变量) Accumulators (累加器) 部署应用到集群中 使用 Java / Scala 运行 spark Jobs 单元测试 Spark 1.0 版本前的应用程序迁移 下一步 Spark Streaming Spark Streaming 概述 一个简单的示例 基本概念 依赖 初始化 StreamingContext Discretized Streams(DStreams)(离散化流) Input DStreams 和 Receivers DStreams 上的 Transformations(转换) DStreams 上的输出操作 DataFrame 和 SQL 操作 MLlib 操作 缓存 / 持久化 CheckPointing 累加器和广播变量 应用程序部署 监控应用程序 性能 降低批处理的时间 设置合理的批处理间隔 内存 容错语义 迁移指南(从 0.9.1 或者更低版本至 1.x 版本) 快速跳转 Kafka 集成指南 DataFrames,Datasets 和 SQL Spark SQL 概述 SQL Datasets 和 DataFrames Spark SQL 入门指南 起始点 : SparkSession 创建 DataFrame 无类型 Dataset 操作(aka DataFrame 操作) 以编程的方式运行 SQL 查询 创建 Dataset RDD 的互操作性 数据源 通用的 Load/Save 函数 Parquet文件 JSON Datasets Hive 表 JDBC 连接其它数据库 故障排除 性能调优 缓存数据到内存 其它配置选项 分布式 SQL引擎 运行 Thrift JDBC/ODBC 运行 Spark SQL CLI 迁移指南Spark SQL 1.6 升级到 2.0 从 Spark SQL 1.5 升级到 1.6 从 Spark SQL 1.4 升级到 1.5 从 Spark SQL 1.3 升级到 1.4 从 Spark SQL 1.0~1.2 升级到 1.3 兼容 Apache Hive 参考 数据类型 NaN 语义 Structured Streaming MLlib(机器学习) 机器学习库(MLlib)指南 ML Pipelines(ML管道) Extracting, transforming and selecting features(特征的提取,转换和选择) Classification and regression(分类和回归) Clustering(聚类) Collaborative Filtering(协同过滤) ML Tuning: model selection and hyperparameter tuning(ML调优:模型选择和超参数调整) Advanced topics(高级主题) MLlib:基于RDD的API Data Types - RDD-based API(数据类型) Basic Statistics - RDD-based API(基本统计) Classification and Regression - RDD-based API(分类和回归) Collaborative Filtering - RDD-based API(协同过滤) Clustering - RDD-based API(聚类 - 基于RDD的API) Dimensionality Reduction - RDD-based API(降维) Feature Extraction and Transformation - RDD-based API(特征的提取和转换) Frequent Pattern Mining - RDD-based API(频繁模式挖掘) Evaluation metrics - RDD-based API(评估指标) PMML model export - RDD-based API(PMML模型导出) Optimization - RDD-based API(最) GraphX(图形处理) Spark R 部署 集群模式概述 提交应用 Spark Standalone 模式 Spark on Mesos Spark on YARN Spark on YARN 上运行 准备 Spark on YARN 配置 调试应用 Spark 属性 重要提示 在一个安全的集群中运行 用 Apache Oozie 来运行应用程序 Kerberos 故障排查 Spark 配置 Spark 监控 指南 作业调度 Spark 安全 硬件配置 构建 Spark
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值