mesos - 使用 mesos dcos cli 提交 Spark

标签 mesos mesosphere marathon dcos

我正在尝试使用 DCOS cli 在 mesos 上启动一个 spark streaming 作业。 我可以开始工作了。我的程序需要一个配置文件作为 cli 参数传递。如何使用 dcos spark run --submit-args 实现此目的?

我试过 --files http://server/path/to//file希望它能下载文件,但这没有用。驱动程序启动但失败,因为缺少配置文件。

我还尝试将 jar 和配置文件打包为 tar 并提交。我可以在 Mesos 日志中看到 tar 被提取和解压。在工作目录中可以看到配置文件和 jar 文件。但是作业因 ClassNotFoundException 而失败。我怀疑 spark-submit 的启动方式有问题。

dcos spark run --submit-args="--supervise --deploy-mode cluster --class package.name.classname http://file-server:8000/Streaming.tar.gz Streaming.conf"

关于如何进行的任何提示?另外,在哪个日志文件中可以看到DCOS使用的底层spark-submit命令?

最佳答案

这是您应该启动以使其工作的命令示例:

dcos spark run --submit-args='--conf spark.mesos.uris=https://s3-us-west-2.amazonaws.com/andrey-so-36323287/pi.conf --class JavaSparkPiConf https://s3-us-west-2.amazonaws.com/andrey-so-36323287/sparkPi_without_config_file.jar/mnt/mesos/sandbox/pi.conf'

在哪里

--conf spark.mesos.uris=... A comma-separated list of URIs to be downloaded to the sandbox when driver or executor is launched by Mesos. This applies to both coarse-grained and fine-grained mode.

/mnt/mesos/sandbox/pi.conf A path to the downloaded file which your main class receives as a 0th parameter (see the code snippet below). /mnt/mesos/sandbox/ is a standard path inside a container which is mapped to a corespondent mesos-task sandbox.

public final class JavaSparkPiConf {

  public static void main(String[] args) throws Exception {
    SparkConf sparkConf = new SparkConf().setAppName("JavaSparkPi");
    JavaSparkContext jsc = new JavaSparkContext(sparkConf);

    Scanner scanner = new Scanner(new FileInputStream(args[0]));
    int slices;
    if (scanner.hasNextInt()) {
      slices = scanner.nextInt();
    } else {
      slices = 2;
    }
    int n = 100000 * slices;
    List<Integer> l = new ArrayList<>(n);
    for (int i = 0; i < n; i++) {
      l.add(i);
    }

    JavaRDD<Integer> dataSet = jsc.parallelize(l, slices);

    int count = dataSet.map(new Function<Integer, Integer>() {
      @Override
      public Integer call(Integer integer) {
        double x = Math.random() * 2 - 1;
        double y = Math.random() * 2 - 1;
        return (x * x + y * y < 1) ? 1 : 0;
      }
    }).reduce(new Function2<Integer, Integer, Integer>() {
      @Override
      public Integer call(Integer integer, Integer integer2) {
        return integer + integer2;
      }
    });

    System.out.println("Pi is roughly " + 4.0 * count / n);

    jsc.stop();
  }
}

关于mesos - 使用 mesos dcos cli 提交 Spark,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36323287/

相关文章:

posix - "posix isolation"是什么?

mesos - mesos 仪表板上的“优惠”选项卡

mesos - 通过控制台提交作业到flink-standalone zookeeper-recovery-mode集群的方式是什么?

distributed - 如何阻止 mesos 向框架提供资源?

windows - Windows机器上Spark应用如何搭建集群环境?

rest - 如何使用Apache Marathon REST API扩展Docker实例?

hadoop - Stratio 设置 : connection refused error

apache-zookeeper - 如何从quorum中获取当前leader master的IP?

Mesos Slave 拒绝所有具有持久卷的 Marathon 作业;声称没有可用空间

docker - 使用Zookeeper来发现运行docker的mesos从属的服务