注意: 作者正在寻找在运行不涉及源代码更改的Spark示例时设置Spark Master的答案,而是仅在可能的情况下从命令行完成的选项.
让我们考虑BinaryClassification示例的run()方法:
def run(params: Params) {
val conf = new SparkConf().setAppName(s"BinaryClassification with $params")
val sc = new SparkContext(conf)
Run Code Online (Sandbox Code Playgroud)
请注意,SparkConf没有提供任何配置SparkMaster的方法.
从Intellij运行此程序时,使用以下参数:
--algorithm LR --regType L2 --regParam 1.0 data/mllib/sample_binary_classification_data.txt
Run Code Online (Sandbox Code Playgroud)
发生以下错误:
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:166)
at org.apache.spark.examples.mllib.BinaryClassification$.run(BinaryClassification.scala:105)
Run Code Online (Sandbox Code Playgroud)
我还尝试添加Spark Master网址(尽管代码似乎不支持它..)
spark://10.213.39.125:17088 --algorithm LR --regType L2 --regParam 1.0
data/mllib/sample_binary_classification_data.txt
Run Code Online (Sandbox Code Playgroud)
和
--algorithm LR --regType L2 --regParam 1.0 spark://10.213.39.125:17088
data/mllib/sample_binary_classification_data.txt
Run Code Online (Sandbox Code Playgroud)
两者都不适用于错误:
Error: Unknown argument 'data/mllib/sample_binary_classification_data.txt'
Run Code Online (Sandbox Code Playgroud)
这里是参考解析 - 它与SparkMaster没有任何关系:
val parser = …Run Code Online (Sandbox Code Playgroud)