步骤1:下载 http://spark.apache.org/downloads.html
解压tar -zxvf spark-2.4.5-bin-hadoop2.7.tgz -C /usr/local
步骤2:配置环境变量 sudo vim /etc/profile
export SPARK_HOME=/usr/local/spark-2.4.5-bin-hadoop2.7
export PATH=$SPARK_HOME/bin:$PATH
刷新环境变量 source /etc/profile
步骤3:Local模式启动
Local 模式是最简单的一种运行方式,它采用单节点多线程方式运行,不用部署,开箱即用,适合日常测试开发。
local:只启动一个工作线程;
local[k]:启动 k 个工作线程;
local[*]:启动跟 cpu 数目相同的工作线程数。
直接执行命令 spark-shell --master local[2]
Setting default log level to "WARN".
To adjust logging level use sc.setLogLevel(newLevel)、For SparkR, use setLogLevel(newLevel).
20/03/12 00:06:13 WARN lineage.LineageWriter: Lineage directory /var/log/spark/lineage doesn't exist or is not writable、Lineage for this application will be disabled.
Spark context Web UI available at http://cdh:4040
Spark context available as 'sc' (master = local[2], app id = local-1583942771326).
Spark session available as 'spark'.
Welcome to
____ __
/ __/__ ___ _____/ /__
_ / _ / _ `/ __/ '_/
/___/ .__/_,_/_/ /_/_ version 2.4.0-cdh6.2.0
/_/
Using Scala version 2.11.12 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_181)
Type in expressions to have them evaluated.
Type :help for more information.
scala>
步骤4:查看Spark的Web UI界面
访问http://ip地址:4040