【问题标题】:run spark machine learning example on yarn failed在纱线上运行火花机器学习示例失败
【发布时间】:2017-02-28 11:37:31
【问题描述】:

启动dfs、yarn和spark后,我在master主机的spark根目录下运行这些代码:

MASTER=yarn ./bin/run-example ml.LogisticRegressionExample \ data/mllib/sample_libsvm_data.txt

其实我是从 Spark 的 README 中得到这些代码的,这里是 GitHub 上关于 LogisticRegressionExample 的源代码:https://github.com/apache/spark/blob/master/examples/src/main/scala/org/apache/spark/examples/ml/LogisticRegressionExample.scala

然后出现错误:

Exception in thread "main" org.apache.spark.sql.AnalysisException: Path does not exist: hdfs://master:9000/user/root/data/mllib/sample_libsvm_data.txt;

首先,我不知道为什么是hdfs://master:9000/user/root,我确实将namenode的IP地址设置为hdfs://master:9000,但是spark为什么选择/user/root

然后,我在集群的每台主机上都创建了一个目录/user/root/data/mllib/sample_libsvm_data.txt,希望spark能找到这个文件。但同样的错误再次发生。请告诉我如何解决它。

【问题讨论】:

    标签: hadoop apache-spark hadoop-yarn


    【解决方案1】:

    Spark 正在寻找 HDFS 上的文件,而不是常规的 Linux 文件系统。您为数据提供的路径 (data/mllib/sample_libsvm_data.txt) 是相对路径。在 HDFS 中,假定相对路径从您的主目录开始。

    github 上的 LogRegExample.scala 假定本地执行,而不是纱线执行。如果要执行纱线执行,则需要将文件上传到 HDFS。

    【讨论】:

    • @JamCon。是的,它有效。我可以使用hdfs dfs -put 将数据文件放在HDFS 上,而不是run-example。当我使用spark-submit提交python脚本时,我使用--files上传我的数据文件,但是如何指定上传文件在HDFS上的路径?我提交的脚本的总运行时间是否包括上传时间?
    猜你喜欢
    • 1970-01-01
    • 2017-05-17
    • 1970-01-01
    • 1970-01-01
    • 2017-01-26
    • 2017-12-25
    • 2016-10-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多