Spark集群安装与配置
一、Scala安装
1.https://www.scala-lang.org/download/2.11.12.html下载并复制到/home/jun下解压
[jun@master ~]$ cd scala-2.12./
[jun@master scala-2.12.]$ ls -l
total
drwxrwxr-x. jun jun Apr : bin
drwxrwxr-x. jun jun Apr : doc
drwxrwxr-x. jun jun Apr : lib
drwxrwxr-x. jun jun Apr : man
2.启动Scala并使用Scala Shell
[jun@master scala-2.12.]$ bin/scala
Welcome to Scala 2.12. (Java HotSpot(TM) -Bit Server VM, Java 1.8.0_171).
Type in expressions for evaluation. Or try :help. scala> println("hello,world")
hello,world scala> *
res1: Int = scala> *res1
res2: Int = scala> :help
All commands can be abbreviated, e.g., :he instead of :help.
:completions <string> output completions for the given string
:edit <id>|<line> edit history
:help [command] print this summary or command-specific help
:history [num] show the history (optional num is commands to show)
:h? <string> search the history
:imports [name name ...] show import history, identifying sources of names
:implicits [-v] show the implicits in scope
:javap <path|class> disassemble a file or class name
:line <id>|<line> place line(s) at the end of history
:load <path> interpret lines in a file
:paste [-raw] [path] enter paste mode or paste a file
:power enable power user mode
:quit exit the interpreter
:replay [options] reset the repl and replay all previous commands
:require <path> add a jar to the classpath
:reset [options] reset the repl to its initial state, forgetting all session entries
:save <path> save replayable session to a file
:sh <command line> run a shell command (result is implicitly => List[String])
:settings <options> update compiler options, if possible; see reset
:silent disable/enable automatic printing of results
:type [-v] <expr> display the type of an expression without evaluating it
:kind [-v] <type> display the kind of a type. see also :help kind
:warnings show the suppressed warnings from the most recent line which had any scala> :quit
3.将Scala安装包复制到slave节点
二、Spark集群的安装与配置
采用Hadoop Yarn模式安装Spark
1.http://spark.apache.org/downloads.html下载spark-2.3.1-bin-hadoop2.7.tgz.gz并赋值到/home/jun下解压
[jun@master ~]$ cd spark-2.3.-bin-hadoop2./
[jun@master spark-2.3.-bin-hadoop2.]$ ls -l
total
drwxrwxr-x. jun jun Jun : bin
drwxrwxr-x. jun jun Jun : conf
drwxrwxr-x. jun jun Jun : data
drwxrwxr-x. jun jun Jun : examples
drwxrwxr-x. jun jun Jun : jars
drwxrwxr-x. jun jun Jun : kubernetes
-rw-rw-r--. jun jun Jun : LICENSE
drwxrwxr-x. jun jun Jun : licenses
-rw-rw-r--. jun jun Jun : NOTICE
drwxrwxr-x. jun jun Jun : python
drwxrwxr-x. jun jun Jun : R
-rw-rw-r--. jun jun Jun : README.md
-rw-rw-r--. jun jun Jun : RELEASE
drwxrwxr-x. jun jun Jun : sbin
drwxrwxr-x. jun jun Jun : yarn
2.配置Linux环境变量
#spark
export HADOOP_CONF_DIR=$HADOOP_HOME/etc/hadoop
export HDFS_CONF_DIR=$HADOOP_HOME/etc/hadoop
export YARN_CONF_DIR=$HADOOP_HOME/etc/hadoop
3.配置spark-env.sh环境变量,注意三个计算机上都必须要这样配置才行
复制默认配置文件并使用gedit打开
[jun@master conf]$ cp ~/spark-2.3.-bin-hadoop2./conf/spark-env.sh.template ~/spark-2.3.-bin-hadoop2./conf/spark-env.sh
[jun@master conf]$ gedit ~/spark-2.3.-bin-hadoop2./conf/spark-env.sh
增加下面的配置
export SPARK_MASTER_IP=192.168.1.100
export JAVA_HOME=/usr/java/jdk1..0_171/
export SCALA_HOME=/home/jun/scala-2.12./
4.修改Spark的slaves文件
使用gedit打开文件
[jun@master conf]$ cp ~/spark-2.3.-bin-hadoop2./conf/slaves.template slaves
[jun@master conf]$ gedit ~/spark-2.3.-bin-hadoop2./conf/slaves
删除默认的localhost并增加下面的配置
# A Spark Worker will be started on each of the machines listed below.
slave0
slave1
5.将Spark复制到Slave节点
三、Spark集群的启动与验证
1.启动Spark集群
首先确保Hadoop集群处于启动状态,然后执行启动脚本
[jun@master conf]$ /home/jun/spark-2.3.-bin-hadoop2./sbin/start-all.sh
starting org.apache.spark.deploy.master.Master, logging to /home/jun/spark-2.3.-bin-hadoop2./logs/spark-jun-org.apache.spark.deploy.master.Master--master.out
slave0: starting org.apache.spark.deploy.worker.Worker, logging to /home/jun/spark-2.3.-bin-hadoop2./logs/spark-jun-org.apache.spark.deploy.worker.Worker--slave0.out
slave1: starting org.apache.spark.deploy.worker.Worker, logging to /home/jun/spark-2.3.-bin-hadoop2./logs/spark-jun-org.apache.spark.deploy.worker.Worker--slave1.out
2.验证启动状态
(1)通过jps查看进程,可以看到master节点上增加了Master进程,而slave节点上增加了Worker进程
[jun@master conf]$ jps
ResourceManager
SecondaryNameNode
Master
NameNode
Jps [jun@slave0 ~]$ jps
DataNode
Worker
NodeManager
Jps [jun@slave1 ~]$ jps
DataNode
Worker
NodeManager
Jps
(2)通过Web查看系统状态,输入http://master:8080

(3)通过终端命令行向Spark集群提交计算程序
为了直接在目录下加载jar包,先将示例程序jar包复制到Spark主安装目录下
[jun@master conf]$ cp /home/jun/spark-2.3.-bin-hadoop2./examples/jars/spark-examples_2.-2.3..jar /home/jun/spark-2.3.-bin-hadoop2./
执行SparkPi程序
[jun@master spark-2.3.-bin-hadoop2.]$ bin/spark-submit --class org.apache.spark.examples.SparkPi --master yarn-cluster --num-executors --driver-memory 512m --executor-memory 512m --executor-cores spark-examples_2.-2.3..jar
这个时候报了一个错误,意思就是container要用2.3G内存,而实际的虚拟内存只有2.1G。Yarn默认的虚拟内存和物理内存比例是2.1,也就是说虚拟内存是2.1G,小于了需要的内存2.2G。解决的办法是把拟内存和物理内存比例增大,在yarn-site.xml中增加一个设置:
diagnostics: Application application_1532350446978_0001 failed times due to AM Container for appattempt_1532350446978_0001_000002 exited with exitCode: -
Failing this attempt.Diagnostics: Container [pid=,containerID=container_1532350446978_0001_02_000001] is running beyond virtual memory limits. Current usage: 289.7 MB of GB physical memory used; 2.3 GB of 2.1 GB virtual memory used. Killing container.
关闭Yarn然后在配置文件中增加下面的配置,然后重启Yarn
<property>
<name>yarn.nodemanager.vmem-pmem-ratio</name>
<value>2.5</value>
</property>
再次运行SparkPi程序,在final status可以看到运行成功!
-- :: INFO Client: -
client token: N/A
diagnostics: N/A
ApplicationMaster host: 192.168.1.101
ApplicationMaster RPC port:
queue: default
start time:
final status: SUCCEEDED
tracking URL: http://master:18088/proxy/application_1532352327714_0001/
user: jun
-- :: INFO ShutdownHookManager: - Shutdown hook called
-- :: INFO ShutdownHookManager: - Deleting directory /tmp/spark-1ed5bee9-1aa7--b3ec-80ff2b153192
-- :: INFO ShutdownHookManager: - Deleting directory /tmp/spark-7349a4e3--4d09-91ff-e1e48cb59b46
在tracking URL上右键然后选择open link即可在浏览器看到运行状态


点击logs,然后点击stdout,可以看到运行结果Pi is roughly 3.143951143951144

Spark集群安装与配置的更多相关文章
- spark集群安装配置
spark集群安装配置 一. Spark简介 Spark是一个通用的并行计算框架,由UCBerkeley的AMP实验室开发.Spark基于map reduce 算法模式实现的分布式计算,拥有Hadoo ...
- [bigdata] spark集群安装及测试
在spark安装之前,应该已经安装了hadoop原生版或者cdh,因为spark基本要基于hdfs来进行计算. 1. 下载 spark: http://mirrors.cnnic.cn/apache ...
- 大数据技术之_19_Spark学习_01_Spark 基础解析 + Spark 概述 + Spark 集群安装 + 执行 Spark 程序
第1章 Spark 概述1.1 什么是 Spark1.2 Spark 特点1.3 Spark 的用户和用途第2章 Spark 集群安装2.1 集群角色2.2 机器准备2.3 下载 Spark 安装包2 ...
- CentOS6安装各种大数据软件 第十章:Spark集群安装和部署
相关文章链接 CentOS6安装各种大数据软件 第一章:各个软件版本介绍 CentOS6安装各种大数据软件 第二章:Linux各个软件启动命令 CentOS6安装各种大数据软件 第三章:Linux基础 ...
- spark集群安装并集成到hadoop集群
前言 最近在搞hadoop+spark+python,所以就搭建了一个本地的hadoop环境,基础环境搭建地址hadoop2.7.7 分布式集群安装与配置 本篇博客主要说明,如果搭建spark集群并集 ...
- hadoop2.7.7 分布式集群安装与配置
环境准备 服务器四台: 系统信息 角色 hostname IP地址 Centos7.4 Mster hadoop-master-001 10.0.15.100 Centos7.4 Slave hado ...
- Spark入门:第2节 Spark集群安装:1 - 3;第3节 Spark HA高可用部署:1 - 2
三. Spark集群安装 3.1 下载spark安装包 下载地址spark官网:http://spark.apache.org/downloads.html 这里我们使用 spark-2.1.3-bi ...
- 3 Spark 集群安装
第3章 Spark集群安装 3.1 Spark安装地址 1.官网地址 http://spark.apache.org/ 2.文档查看地址 https://spark.apache.org/docs/2 ...
- Springboot 2.0.x 集成基于Centos7的Redis集群安装及配置
Redis简介 Redis是一个基于C语言开发的开源(BSD许可),开源高性能的高级内存数据结构存储,用作数据库.缓存和消息代理.它支持数据结构,如 字符串.散列.列表.集合,带有范围查询的排序集,位 ...
随机推荐
- spring系列常用注解
常见注解使用 - @SpringBootApplication,springboot的核心注解,用于开启自动配置,等效于@Configuraion.@ComponentScan和@EnableAuto ...
- Flask基础(13)-->Flask扩展Flask-Script
Flask基础(12)-->Flask扩展Flask-Script # 前提是安装了Flask-Script # 联网运行 pip install flask-script from flask ...
- [ProblemSolving][Ubuntu][LyX] The selected document class ... requires external files that are not available...
I installed LyX in my Ubuntu(version LTS 18.04), but I just can't make it work. Every time I open an ...
- Python3编码解码url
python2和python3对于url的解码和编码 某天做爬虫时遇到一个post请求的参数是编码过的字符串如下,看不懂,初步判断可能是url编码 str = "%7B%22Shopping ...
- Spring5源码解析-前奏:本地构建Spring5源码
构建环境 macOS 10.13.6 JDK1.8 IntelliJ IDEA 2018.3.6 (Ultimate Edition) Spring v5.1.9.RELEASE Gradle 5.5 ...
- java架构之路-(JVM优化与原理)JVM类的加载机制
话不多说,先上图. ***.class文件执行大概就是这样来走的.我们都知道我们的java文件经过编译以后会生成对应的class文件.先经过类装载子系统,然后塞进运行时内存模型的元空间,开始执行方法, ...
- 快学Scala 第十九课 (trait的abstract override使用)
trait的abstract override使用: 当我看到abstract override介绍的时候也是一脸懵逼,因为快学scala,只介绍了因为TimestampLogger中调用的super ...
- Nginx internal 指令限制访问图片资源文件
Nginx 的 internal 指令可以用来限制 Web 公共目录下的图片等资源文件被任意用户直接访问.一个明显的使用场景是,对于用户上传的认证图片,属于个人隐私资源,不应该让所有用户都能访问得到, ...
- 工业搬运机器人(AGV)为什么要选择视觉导航
在智能制造和仓储物流领域,搬运机器人的需求量在逐年上升.机器人(AGV)的种类千差万别,如何选择成为需求方头痛的问题. 本文将从客户关心的多个方面,对市面上的常见的工业级导航方案做一个比较. 搬运机器 ...
- 如何写md格式的文档
一.标题 标题其实和HTML中的h系列很像,想要设置为标题的文字前面加#来表示一个#是一级标题,二个#是二级标题,以此类推.支持六级标题. 注:标准语法一般在#后跟个空格再写文字, 示例: 效果如下: ...