spark-submit - 无法解析主网址

问题描述 投票:1回答:1

我在Windows 10机器上使用spark-submit执行spark job时遇到错误。命令是:

c:\workspaces\Spark2Demo>spark-submit --class retail_db.GetRevenuePerOrder  --master local .\target\scala-2.12\spark2demo_2.12-0.1.jar c:\workspaces\data\retail_db\orders\part-00000 c:\workspaces\output

我得到的错误是:

2019-03-12 19:09:33 ERROR SparkContext:91 - Error initializing SparkContext.
org.apache.spark.SparkException: Could not parse Master URL: 'c:\workspaces\data\retail_db\orders\part-00000'
        at org.apache.spark.SparkContext$.org$apache$spark$SparkContext$$createTaskScheduler(SparkContext.scala:2784)
        at org.apache.spark.SparkContext.<init>(SparkContext.scala:493)
        at retail_db.GetRevenuePerOrder$.main(GetRevenuePerOrder.scala:7)
        at retail_db.GetRevenuePerOrder.main(GetRevenuePerOrder.scala)

该文件存在且可访问。我能够在IDE中运行该程序。以下是原则:

package retail_db
import org.apache.spark.{SparkConf,SparkContext}

object GetRevenuePerOrder {
  def main(args:Array[String]):Unit = {
    val conf = new SparkConf().setMaster(args(0)).setAppName("GetRevenuePerOrder")
    val sc = new SparkContext(conf)
    sc.setLogLevel("DEBUG")
    println(args)
    val orderItems = sc.textFile(args(1))
    val revenuePerOrder = orderItems.map(oi => (oi.split(",")(1).toInt, oi.split(",")(4).toFloat)).reduceByKey(_ + _).map(oi => (oi._1 + "," + oi._2))
    revenuePerOrder.saveAsTextFile(args(2))
  }
}

请帮忙。

apache-spark
1个回答
1
投票

你是两次设置师父。第一次在spark-submit命令(--master local)中,您将其设置为本地,第二次在SparkConf中设置(新的SparkConf()。setMaster(args(0)))。正如spark configuration page中所提到的,“直接在SparkConf上设置的属性取最高优先级,然后标志传递给spark-submit或spark-shell,然后是spark-defaults.conf文件中的选项”,由spark-submit设置的本地主服务器,被SparkConf参数覆盖。请删除第二部分。

© www.soinside.com 2019 - 2024. All rights reserved.