基于Apache Spark的分布式计算集群设计

 2022-05-12 09:05

论文总字数:38098字

摘 要

随着技术与算法的发展,人们对于大规模数据的存储和运算的要求越来越高,因此,对于具有强大算力设备的需求日益增长。然而,无论是采用主流的业界成熟的云计算方案,如Amazon Web Service(AWS)、阿里云、华为云等,或者是自行购买业界主流使用的加速卡如NVidia的GPU或Intel的Xeon Phi协处理器搭配IBM或是浪潮的集群进行运算等,其价格都十分高昂,对于经费缺乏的实验室或者业余的爱好者而言,购买这些专业设备并不现实。在这样的现实背景下,充分利用好手头的设备或是服务器搭建分布式计算集群成为了个人乃至企业的一个优良选择。

在这样的背景条件下,本文借助目前较为流行的大数据计算框架Apache Spark,设计了一种基于该框架的分布式计算集群,同时采用Raspberry Pi Zero验证了本文所设计分布式集群的可行性。

首先,本文讨论了大数据与分布式计算的发展历史、国内外现状,并阐述了本文的主要工作量和创新点。

其次,本文详细介绍了Spark的工作原理,从基本的MapReduce再介绍到Spark生态环境、工作原理,最后到Spark的核心模块——RDD弹性分布式数据集的原理阐述。

然后,本文研究了如何利用虚拟机搭建出符合要求的基于Spark的分布式集群,同时在虚拟机的环境下初步探讨了集群相对于单机对于同一任务进行运算的加速比。

最后本文通过设计并实现了基于树莓派Zero开发板的实机Spark集群搭建。与市面或者各大网站上广泛采用性能更为强大、接口更为多的型号不同,本文采用了成本不到其一半的树莓派Zero W型号,同时在单个开发板只有一个接口的情况下用独创的连接方式组成了集群,不仅测试了实际情况中集群相较于单机对于同一数据进行运算的加速比,还利用分词软件和英文语料库测试了本集群的实用性,进一步论证了分布式集群在现实中的可行性。

关键词:Apache Spark,分布式计算,集群设计与搭建,低成本实机测试

Abstract

With the development of technologies and algorithms, people are increasingly demanding the storage and operation of large-scale data. Therefore, there is an increasing demand for devices with powerful computing power. However, whether it is the mainstream industry mature cloud computing solutions, such as Amazon Web Service (AWS), Alibaba Cloud, Huawei Cloud, etc., or buy the industry's mainstream accelerator cards such as NVidia's GPU or Intel's Xeon Phi co-processing. The price of the device is very high with IBM or Inspur clusters. For labs or amateurs who lack funds, it is not realistic to purchase these professional devices. In this realistic context, making full use of the equipment or servers at hand to build distributed computing clusters has become an excellent choice for individuals and enterprises.

Under such background conditions, this paper designs a distributed computing cluster based on the current popular big data computing framework Apache Spark, and uses Raspberry Pi Zero to verify the feasibility of the distributed cluster designed in this paper.

First of all, this paper discusses the development history of big data and distributed computing, the status quo at home and abroad, and expounds the main workload and innovation of this paper.

Secondly, this paper introduces the working principle of Spark in detail, from the basic MapReduce to the Spark ecosystem and working principle, and finally to the principle of RSD's elastic distributed dataset.

Then, this thesis studies how to use the virtual machine to build a Spark-based distributed cluster that meets the requirements. At the same time, in the virtual machine environment, the speedup ratio of the cluster to the same task is discussed.

Finally, this paper designs and implements a real-world Spark cluster based on the Raspberry Pi Zero development board. Unlike models that are more powerful and have more interfaces on the market or on major websites, this article uses the Raspberry Pi Zero W model, which costs less than half of it, and uses only one interface for a single development board. The original connection method constitutes the cluster. It not only tests the speedup ratio of the cluster to the same data in the actual situation, but also tests the practicability of the cluster by using the word segmentation software and the English corpus, further demonstrating the distributed cluster. Feasibility in reality.

KEY WORDS: Apache Spark, distributed computing, cluster design and construction, low-cost real machine testing

目 录

摘 要 I

Abstract II

第一章 绪论 1

1.1 研究背景及意义 1

1.2 大数据发展历史及特点介绍 1

1.3 国内外大数据研究与发展现状 2

1.3.1 国内 2

1.3.2 国外 2

1.4 本文工作量及创新点 3

1.5 论文组织结构 3

第二章 Apache Spark简介与原理阐释 4

2.1 Spark发展历史 4

2.2 Spark特点 4

2.2.1 采用有向无环图(Directed Acyclic Graph) 5

2.2.2 减少排序次数 5

2.2.3 采用Netty通信框架 5

2.2.4 更高的容错性 5

2.2.5 高达50倍的计算速度 6

2.2.6 易用性好,API多 6

2.3 Spark架构与生态环境 6

2.3.1 底层数据源 6

2.3.2 集群资源管理器 6

2.3.3 核心库Spark Core 7

2.3.4 组件 7

2.4 Spark工作原理 8

2.4.1 SparkContext 8

2.4.2 Spark运行流程 9

2.4.3 Spark以集群方式运行的三种模式 9

2.5 RDD弹性分布式数据集 11

2.5.1 RDD特点 11

2.5.2 RDD属性组成 11

2.5.3 RDD分区(Partition)原理 12

2.5.4 RDD在Spark中的工作原理 12

2.6 本章小结 13

第三章 基于虚拟机的Spark环境搭建及测试 14

3.1 环境配置版本 14

3.1.1 软件版本 14

3.1.2 虚拟机配置 14

3.1.3 虚拟机分布式集群架构设计 14

3.2 集群前期准备工作 15

3.2.1开启Debian操作系统下直接以Root登陆的权限 15

3.2.2 配置静态ip 15

3.2.3 配置ssh连接与集群各机之间的互信 17

3.3 Spark环境搭建 18

3.3.1 配置JAVA、Scala环境 18

3.3.2 部署安装Hadoop 18

3.3.3 配置Spark 19

3.3.4 Spark管理界面 20

3.4 基于所构建虚拟机集群的性能测试 20

3.4.1 SparkPi介绍 21

3.4.2 SparkPi任务提交 21

3.4.3 运行结果误差与比较 21

3.4.4 此小节结论 22

3.5 本章小结 22

第四章 基于树莓派的Spark环境搭建及测试 23

4.1 总体设计方案 23

4.1.1 研究内容概述 23

4.1.2 Raspberry Pi Zero W介绍 23

4.1.3 所需设备型号 23

4.1.4 树莓派Zero集群架构 23

4.2 树莓派Zero集群搭建过程 24

4.2.1 设备安装过程 24

4.2.2 环境配置、软件安装 25

4.3 性能测试 27

4.4 基于Spark的英文分词应用 28

4.4.1 简介 28

4.4.2 算法流程及代码分析 28

4.4.3 提交运行方式及结果分析 30

结 论 31

参考文献 32

致 谢 34

第一章 绪论

1.1 研究背景及意义

从20年纪90年代开始,由于甲骨文(Oracle)等公司发展的数据库技术日益成熟,同时学术界提出了数据挖掘的概念,社会逐渐提高了对于数据利用的重视[1],但此时还只是传统数据挖掘的初级阶段[2]。而从2000年伊始,互联网的鼎盛发展不仅丰富了人们的娱乐生活,同时广泛应用于金融、医疗、物流、管理等领域,在此期间出现了大量的非结构化数据[3],传统的数据库由于其性能和设计原理限制,难以应付这些数据,学术界和工业界因此开展了对数据处理算法的研究。

同时,近些年随着大数据与人工智能或机器学习的应用范围愈发扩大,人们对于高性能并行计算的要求逐渐提高。诚然,英伟达(NVIDIA)和英特尔(Intel)都发布了可以大幅度提高速度的加速卡,例如Tesla Volta 100显卡或者Xeon Phi协处理器[4]。但从性价比来说,这些加速卡结合服务器之后单机的价格过于昂贵,不适用于预算低的项目。所以,尽管超级计算机集群(Super Computer Cluster)已经不如以前那么遥不可及,大部分企业在实际生产过程中还是会用性价比较高的分布式解决方案[5]

剩余内容已隐藏,请支付后下载全文,论文总字数:38098字

您需要先支付 80元 才能查看全部内容!立即支付

该课题毕业论文、开题报告、外文翻译、程序设计、图纸设计等资料可联系客服协助查找;