Spark Master UI

本文详细介绍了Spark在本地模式下的运行机制,包括如何在笔记本上运行Spark,不使用独立的Spark Master和Worker,而是在同一台机器上启动一个单独的Java虚拟机(JVM),其中既包含了Driver应用(Sparkshell)也执行了Scala代码的转换和操作。尽管没有Master UI界面,文章提供了Master UI界面的截图供参考。

There are 4 was to run spark:

  • local
  • Standalone
  • YARN
  • Mesos

When Spark is run in local mode (as you're doing on your laptop) a separate Spark Master and separate Spark Workers + Exectuors are not launched.

Instead a single Java Virtual Machine (JVM) is launched with one Executor, whose ID is <driver>. This special Executor runs the Driver (which is the "Spark shell" application in this instance) and this special Executor also runs our Scala code. By default, this single Executor will be started with X threads, where X is equal to the # of cores on your machine.

Local mode is used when you want to run Spark locally and not in a distributed cluster. Spark local mode is different than Standalone mode (which is still designed for a cluster setup).

To summarize, in local mode, the Spark shell application (aka the Driver) and the Spark Executor is run within the same JVM. More precisely, the single Executor that is launched is named <driver> and this Executor runs both the driver code and the executes our Spark Scala transformations and actions.

So, although there is no Master UI in local mode, if you are curious, here is what a Master UI looks like here is a screenshot:

  

https://blueplastic.gitbooks.io/how-to-light-your-spark-on-a-stick/content/spark_web_uis/spark_stages_ui.html

Apache Spark UI 是一个基于 Web 的界面,用于监控和调试 Spark 应用程序的运行情况。它提供了丰富的信息,包括作业(Job)、阶段(Stage)、任务(Task)的执行状态、资源使用情况、执行时间线以及详细的执行日志等。通过 Spark UI,用户可以更好地理解应用程序的执行过程,并进行性能调优和问题排查。 Spark UI 默认运行在 Spark 驱动程序的 4040 端口上。当 Spark 应用启动后,可以通过访问 `http://<driver-node>:4040` 来查看 UI 界面。如果同时运行了多个 Spark 应用,每个应用会依次使用 4040、4041、4042 等端口。 Spark UI 的主要功能包括: - **作业概览(Jobs)**:显示当前应用中所有作业的执行情况,包括完成状态、执行时间、失败原因等。 - **阶段概览(Stages)**:展示每个作业被划分为的阶段,以及每个阶段的执行细节,如任务数量、执行时间、输入输出大小、Shuffle 读写性能等。 - **任务详情(Tasks)**:提供每个任务的执行信息,包括执行节点、运行时间、GC 时间、读写数据量等。 - **存储信息(Storage)**:显示 RDD 或 DataFrame 的缓存情况,包括缓存位置、存储大小等。 - **执行器信息(Executors)**:列出所有执行器的资源使用情况,包括内存、CPU 使用、任务数量等。 - **SQL 查询(SQL)**:如果使用的是 Spark SQL,可以查看 SQL 查询的执行计划和性能指标。 - **流处理信息(Streaming)**:如果使用 Spark Streaming,可以查看流处理的批次间隔、处理时间、接收数据量等信息。 - **环境信息(Environment)**:展示 Spark 应用的配置信息,包括 JVM 参数、Spark 属性、类路径等。 为了安全起见,可以通过启用 ACL(访问控制列表)来限制对 Spark UI 的访问权限。启用方式是设置 `spark.acls.enable` 为 `true`,并配置允许访问的用户列表 `spark.ui.view.acls`。此外,还可以通过身份验证机制增强安全性,防止未授权访问或潜在的安全风险。 ### 提交 Spark 应用时启用 UI 的示例 ```bash spark-submit --class main.class.name --master local[4] your-app.jar ``` 对于 Python 应用: ```bash spark-submit your-script.py ``` 在运行过程中,可以直接通过浏览器访问 Spark UI 查看运行状态。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值