zoukankan      html  css  js  c++  java
  • 解决A master URL must be set in your configuration错误

    在运行spark的测试程序SparkPi时,点击运行,出现了如下错误:

    Exception in thread "main" org.apache.spark.SparkException: A master URL must be set in your configuration
    at org.apache.spark.SparkContext.<init>(SparkContext.scala:185)
    at SparkPi$.main(SparkPi.scala:12)
    at SparkPi.main(SparkPi.scala)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
    Using Spark's default log4j profile: org/apache/spark/log4j-defaults.properties

    从提示中可以看出找不到程序运行的master,此时需要配置环境变量。

    传递给spark的master url可以有如下几种:

    local 本地单线程
    local[K] 本地多线程(指定K个内核)
    local[*] 本地多线程(指定所有可用内核)
    spark://HOST:PORT 连接到指定的 Spark standalone cluster master,需要指定端口。
    mesos://HOST:PORT 连接到指定的 Mesos 集群,需要指定端口。
    yarn-client客户端模式 连接到 YARN 集群。需要配置 HADOOP_CONF_DIR。

    yarn-cluster集群模式 连接到 YARN 集群。需要配置 HADOOP_CONF_DIR。

    点击edit configuration,在左侧点击该项目。在右侧VM options中输入“-Dspark.master=local”,指示本程序本地单线程运行,再次运行即可。

    配置如图:




  • 相关阅读:
    Keil MDK5 硬件仿真之查看变量的值(内附变量值不随程序的运行而刷新的解决办法)
    15 Q点稳定的放大电路和基本共集放大电路
    13 H参数等效模型
    12 放大电路的分析方法
    文件处理
    基本数据类型及内置方法
    for循环及字符串操作
    while循环
    用户交互、运算符
    变量与基本数据类型
  • 原文地址:https://www.cnblogs.com/shenlanzifa/p/5288717.html
Copyright © 2011-2022 走看看