Spark 无法删除临时目录

问题描述 投票:0回答:2

我正在尝试使用下面提到的命令从 Windows 10 中的 cmd 提交 Spark 程序:

spark-submit --class abc.Main --master local[2] C:\Users\arpitbh\Desktop\AmdocsIDE\workspace\Line_Count_Spark\target\Line_Count_Spark-0.0.1-SNAPSHOT.jar

但是运行后我收到错误:

17/05/02 11:56:57 INFO ShutdownHookManager: Deleting directory C:\Users\arpitbh\AppData\Local\Temp\spark-03f14dbe-1802-40ca-906c-af8de0f462f9
17/05/02 11:56:57 ERROR ShutdownHookManager: Exception while deleting Spark temp dir: C:\Users\arpitbh\AppData\Local\Temp\spark-03f14dbe-1802-40ca-906c-af8de0f462f9
java.io.IOException: Failed to delete: C:\Users\arpitbh\AppData\Local\Temp\spark-03f14dbe-1802-40ca-906c-af8de0f462f9
        at org.apache.spark.util.Utils$.deleteRecursively(Utils.scala:1010)
        at org.apache.spark.util.ShutdownHookManager$$anonfun$1$$anonfun$apply$mcV$sp$3.apply(ShutdownHookManager.scala:65)
        at org.apache.spark.util.ShutdownHookManager$$anonfun$1$$anonfun$apply$mcV$sp$3.apply(ShutdownHookManager.scala:62)
        at scala.collection.IndexedSeqOptimized$class.foreach(IndexedSeqOptimized.scala:33)
        at scala.collection.mutable.ArrayOps$ofRef.foreach(ArrayOps.scala:186)
        at org.apache.spark.util.ShutdownHookManager$$anonfun$1.apply$mcV$sp(ShutdownHookManager.scala:62)
        at org.apache.spark.util.SparkShutdownHook.run(ShutdownHookManager.scala:216)
        at org.apache.spark.util.SparkShutdownHookManager$$anonfun$runAll$1$$anonfun$apply$mcV$sp$1.apply$mcV$sp(ShutdownHookManager.scala:188)
        at org.apache.spark.util.SparkShutdownHookManager$$anonfun$runAll$1$$anonfun$apply$mcV$sp$1.apply(ShutdownHookManager.scala:188)
        at org.apache.spark.util.SparkShutdownHookManager$$anonfun$runAll$1$$anonfun$apply$mcV$sp$1.apply(ShutdownHookManager.scala:188)
        at org.apache.spark.util.Utils$.logUncaughtExceptions(Utils.scala:1951)
        at org.apache.spark.util.SparkShutdownHookManager$$anonfun$runAll$1.apply$mcV$sp(ShutdownHookManager.scala:188)
        at org.apache.spark.util.SparkShutdownHookManager$$anonfun$runAll$1.apply(ShutdownHookManager.scala:188)
        at org.apache.spark.util.SparkShutdownHookManager$$anonfun$runAll$1.apply(ShutdownHookManager.scala:188)
        at scala.util.Try$.apply(Try.scala:192)
        at org.apache.spark.util.SparkShutdownHookManager.runAll(ShutdownHookManager.scala:188)
        at org.apache.spark.util.SparkShutdownHookManager$$anon$2.run(ShutdownHookManager.scala:178)
        at org.apache.hadoop.util.ShutdownHookManager$1.run(ShutdownHookManager.java:54)

我还检查了apache Spark的JIRA,这个缺陷已标记为已解决,但没有提到解决方案。请帮忙。

package abc;

import org.apache.spark.SparkConf;
import org.apache.spark.api.java.JavaRDD;
import org.apache.spark.api.java.JavaSparkContext;


public class Main {

    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub

        SparkConf conf =new SparkConf().setAppName("Line_Count").setMaster("local[2]");
        JavaSparkContext ctx= new JavaSparkContext(conf);

        JavaRDD<String> textLoadRDD = ctx.textFile("C:/spark/README.md");
        System.out.println(textLoadRDD.count());
        System.getProperty("java.io.tmpdir");

    }

}
java apache-spark bigdata
2个回答
0
投票

这可能是因为您实例化 SparkContext 时没有使用 SPARK_HOME 或 HUPA_HOME 来允许程序在 bin 目录中查找 winutils.exe。我发现当我从

SparkConf conf = new SparkConf();
JavaSparkContext sc = new JavaSparkContext(conf);

JavaSparkContext sc = new JavaSparkContext("local[*], "programname", 
System.getenv("SPARK_HOME"), System.getenv("JARS"));

错误消失了。


0
投票

我相信,您正在尝试在不设置用户变量 HADOOP_HOME 或 SPARK_LOCAL_DIRS 的情况下执行程序。 我有同样的问题,通过创建变量解决它,例如 HADOOP_HOME-> C:\Hadoop, SPARK_LOCAL_DIRS->C: mp\spark

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