【问题标题】:Change Executor Memory (and other configs) for Spark Shell更改 Spark Shell 的执行程序内存(和其他配置)
【发布时间】:2014-05-23 05:37:14
【问题描述】:

如何更改 Apache Spark Shell 的执行程序内存(和其他配置)?

特别是我想在启动它时给 spark-shell 提供单位,例如 -Dspark-cores-max=12,以便我在 spark shell 中的工作将使用这些配置设置。

【问题讨论】:

    标签: apache-spark


    【解决方案1】:

    从 spark 1.2.0 开始,您可以通过向 spark-shell 提供以下参数来设置 memorycores

    spark-shell --driver-memory 10G --executor-memory 15G --executor-cores 8
    

    要查看其他选项,您可以使用以下命令来触发 shell

    spark-shell --help
    

    【讨论】:

      【解决方案2】:

      如果您在以独立模式(1 个节点)安装的 spark 上运行 spark-shell,请使用

      ./bin/spark-shell --driver-memory 4g
      

      如果您在安装在集群(2 个以上节点)上的 spark 上运行 spark-shell,请使用

      ./bin/spark-shell --executor-memory 4g
      

      4g 是 4GB。

      【讨论】:

        【解决方案3】:

        已弃用使用已接受的答案

        这样写一个脚本:

        #!/bin/bash
        export SPARK_JAVA_OPTS="$*"
        MASTER=spark://ec2-99-99-99-99:7077 /usr/share/spark/bin/spark-shell
        

        /usr/share/spark/bin/spark-shell 应该是长 spark-shell 启动脚本所在的路径。在我的集群上,/usr/local/bin/ 中有另一个脚本,但这只是与上面类似的几行代码,并且硬编码了 SPARK_JAVA_OPTS

        无论如何,示例使用:

        my-spark-starter-script -Dspark-cores-max=12 -Dspark.executor.memory=26000m
        

        【讨论】:

          【解决方案4】:

          用于为执行程序配置核心和内存。

          spark-shell --帮助

          --ma​​ster MASTER_URL spark://host:port, mesos://host:port, yarn,
          --executor-memory MEM 每个执行器的内存(例如 1000M、2G)(默认值:1G)。
          --total-executor-cores NUM 所有执行器的总核心数。
          --executor-cores NUM 每个执行器使用的核心数。 (默认值:YARN 和 K8S 模式下为 1,或独立模式下工作线程上的所有可用内核)。
          --num-executors NUM 要启动的执行器数量(默认:2)。如果启用了动态分配,则初始数量

          最终命令: 如果您的系统有 6 个内核和 6GB RAM。

          案例 1:创建 6 个执行器,每个执行器具有 1 个核心和 1GB RAM

          spark-shell --master spark://sparkmaster:7077 --executor-cores 1 --executor-memory 1g

          案例 2:创建 3 个执行器,每个执行器具有 1 个核心和 2GB RAM。最大内存6GB,3核比较理想。

          spark-shell --master spark://sparkmaster:7077 --executor-cores 1 --executor-memory 2g

          案例 3:创建 2 个执行器,每个执行器具有 3 个核心和 3GB RAM。使用所有 RAM 和内核

          spark-shell --master spark://sparkmaster:7077 --executor-cores 3 --executor-memory 3g

          案例 4:创建 2 个执行器,每个 3 个核心,只有 1GB 内存。

          spark-shell --master spark://sparkmaster:7077 --executor-cores 3 --executor-memory 1g

          案例 5:如果我们只想使用一个 1 核和 1GB RAM 的执行器

          spark-shell --master spark://sparkmaster:7077 --total-executor-cores 1 --executor-cores 1 --executor-memory 1g

          案例 6:如果我们只想使用两个 executor,每个 1 core 和 1GB RAM

          spark-shell --master spark://sparkmaster:7077 --total-executor-cores 2 --executor-cores 1 --executor-memory 1g

          案例 7:如果我们只想使用两个执行器,每个执行器有 2 个内核和 2GB RAM(总共 4 个内核和 4GB RAM)

          spark-shell --master spark://sparkmaster:7077 --total-executor-cores 4 --executor-cores 2 --executor-memory 2g

          案例8:如果我们应用--total-executor-cores 2,那么只会创建一个执行器。

          spark-shell --master spark://sparkmaster:7077 --total-executor-cores 4 --executor-cores 2 --executor-memory 2g

          CASE 9 : 总执行器核心数:3 不能被每个执行器的核心数整除:2,剩下的核心数:1 将不会被分配。一个具有 2 个核心的执行器将创建。

          spark-shell --master spark://sparkmaster:7077 --total-executor-cores 3 --executor-cores 2 --executor-memory 2g

          所以 --total-executor-cores / --executor-cores = 将创建的执行器数量。

          【讨论】:

            猜你喜欢
            • 2017-05-29
            • 2017-12-12
            • 2015-09-30
            • 2016-06-08
            • 1970-01-01
            • 2019-08-11
            • 1970-01-01
            • 2015-11-24
            • 1970-01-01
            相关资源
            最近更新 更多