问题描述
In [10]: inputFile = "file:///home/learning-spark/files/ham.txt"
In [11]: input = hiveCtx.read.json(inputFile)
19/01/23 17:12:51 WARN scheduler.TaskSetManager: Lost task 0.0 in stage 3.0 (TID 21, slave3, executor 3): java.io.FileNotFoundException: File file:/home/learning-spark/files/ham.txt does not exist
可以肯定那个文件件在本地是存在的,但是读取不到;
解决方法
- 若是指定文件路径为 “file://…”,则读取的是本地目录;
- 未指定默认为HDFS文件系统
如果程序中读取的是本地文件,那么,要在所有的节点都有这个数据文件,只在master中有这个数据文件时执行程序时一直报找不到文件
解决方式1:让每个Worker节点的相应位置都有要读取的数据文件。
解决方式2:直接将数据文件上传到hdfs,达到数据共享。
In [14]: inputFile = "file:///home/learning-spark/files/testweet.json"
In [15]: input = hiveCtx.read.json(inputFile)
[Stage 5:> (0 + 2) / 2]19/01/23 19:50:05 WARN spark.ExecutorAllocationManager: No stages are running, but numRunningTasks != 0