• spark调优篇-spark on yarn web UI


    spark on yarn 的执行过程在 yarn RM 上无法直接查看,即 http://192.168.10.10:8088,这对于调试程序很不方便,所以需要手动配置

    配置方法

    1. 配置 spark-defaults.conf 

    cp spark-defaults.conf.template spark-defaults.conf

    添加如下配置

    spark.eventLog.enabled           true
    spark.eventLog.dir               hdfs://hadoop10:9000//user/root/history
    spark.serializer                 org.apache.spark.serializer.KryoSerializer
    spark.driver.memory              5g
    spark.executor.extraJavaOptions  -XX:+PrintGCDetails -Dkey=value -Dnumbers="one two three"
    spark.history.fs.logDirectory      hdfs://hadoop10:9000//user/root/history
    spark.yarn.historyServer.address master:18080

    spark.eventLog.enabled 设置为 true 表示开启日志记录

    spark.eventLog.dir 表示存储日志的地址,application 运行过程中所有的日志均存于该目录下,一般设置为 hdfs 路径,也可以设置为 本地路径

      // HDFS:hdfs://hadoop10:9000//user/root/history  事先创建目录

      // 本地:file:///directory

    spark.history.fs.logDirectory 这个配置和 spark.eventLog.dir 保持一致,spark histroy server 只展示该路径下的信息

    spark.yarn.historyServer.address 设置 history server 的 ip port,指向 http://192.168.10.10:8088 上的 Tracking UI

    spark.eventLog.compress 是否压缩记录 Spark 事件信息,前提 spark.eventLog.enabled 为 true,默认使用的是 snappy

    2. 修改 spark-env.sh

    在原来基础上添加

    export SPARK_HISTORY_OPTS="-Dspark.history.retainedApplications=15"

    spark.history.retainedApplications 设置在 History Server 显示的 Application 历史记录个数,如果超过这个值,旧的应用程序信息将被删除.

    3. 启动 Spark History Server

    sbin/start-history-server.sh

    此时打开 http://192.168.10.10:18080 即可查看

    web UI 解析

    web ui 包括以下几部分

    假设执行如下命令

    spark-submit --master yarn --num-executors 8 --executor-cores 5 gpsfreq.py

    启动 8 个 Executor,每个 Executor 启动 5 个 core,共 40 个 core

    stage

    点开第 0个 stage

    根据我上面的分析,做了如下改动

    减少了 executor 数 和 executor core 数

    spark-submit --master yarn --num-executors 4 --executor-cores 1 gpsfreq.py

    结果效率提升了2倍

     把 textFile 设定 3 个分区,仍然采用上面的命令

    运行效率更高了,而且解决了最初的问题

    参考资料:

    https://www.jianshu.com/p/4d28edc599ea  为Spark on Yarn配置WebUI日志记录

    https://blog.csdn.net/zyj8170/article/details/58158966  Spark on YARN配置日志Web UI

    https://www.cnblogs.com/hexu105/p/8182472.html  spark on yarn UI界面详解

  • 相关阅读:
    JAVA动态添加枚举值
    maven仓库配置
    AWS S3 上传下载文件
    golang http client的MaxConnsPerHost限制
    redis cli的特殊用法
    go调度: 第三部分-并发
    tcmalloc的memory heap profiler
    【流数据处理】MySql/PG/Oracle+Kafka+Flink(CDC捕获) 部署及实时计算
    【概念】详解MapReduce原理
    一次失败的创业经历
  • 原文地址:https://www.cnblogs.com/yanshw/p/12038633.html
Copyright © 2020-2023  润新知