복붙노트

[HADOOP] pyspark : 로컬 파일을 찾을 수 없습니다

HADOOP

pyspark : 로컬 파일을 찾을 수 없습니다

나는 다음과 같은 간단한 파이썬 코드가 있습니다 :

from __future__ import print_function

import sys
from operator import add

from pyspark import SparkContext


if __name__ == "__main__":
    print(len(sys.argv))
    if len(sys.argv) < 2:
        print("Usage: wordcount <file>", file=sys.stderr)
        exit(-1)
    sc = SparkContext(appName="PythonWordCount")
    lines = sc.textFile(sys.argv[2], 1)
    counts = lines.flatMap(lambda x: x.split(' ')).map(lambda x: (x, 1)).reduceByKey(add)
    output = counts.collect()
    for (word, count) in output:
        print("%s: %i" % (word, count))

    sc.stop()

그럼 난을 수행하여 로컬 클러스터에서 실행하려고 :

spark-submit --master spark://rws-lnx-sprk01:7077 /home/edamameQ/wordcount.py wordcount /home/edamameQ/wordTest.txt

wordTest.txt 확실히 볼 수 있습니다 :

edamameQ@spark-cluster:~$ ls
data    jars   myJob.txt  wordTest.txt  wordcount.py

하지만 오류가 계속 :

Driver stacktrace:
    at org.apache.spark.scheduler.DAGScheduler.org$apache$spark$scheduler$DAGScheduler$$failJobAndIndependentStages(DAGScheduler.scala:1283)
    at org.apache.spark.scheduler.DAGScheduler$$anonfun$abortStage$1.apply(DAGScheduler.scala:1271)
    at org.apache.spark.scheduler.DAGScheduler$$anonfun$abortStage$1.apply(DAGScheduler.scala:1270)
    at scala.collection.mutable.ResizableArray$class.foreach(ResizableArray.scala:59)
 :
 :
Caused by: java.io.FileNotFoundException: File file:/home/edamameQ/wordTest.txt does not exist
    at org.apache.hadoop.fs.RawLocalFileSystem.getFileStatus(RawLocalFileSystem.java:520)
    at org.apache.hadoop.fs.FilterFileSystem.getFileStatus(FilterFileSystem.java:398)
    at org.apache.hadoop.fs.ChecksumFileSystem$ChecksumFSInputChecker.<init>(ChecksumFileSystem.java:137)
    at org.apache.hadoop.fs.ChecksumFileSystem.open(ChecksumFileSystem.java:339)

같은 코드는 S3 위치에서 입력 파일과 AWS 작업을했다. 내가 로컬 클러스터에서 실행을 위해 조정해야 할 일이 있나요? 감사!

해결법

  1. ==============================

    1.당신이 읽고 싶은 파일의 모든 근로자에 ​​액세스 할 수 있습니다. 이 로컬 파일 인 경우 유일한 옵션은 작업자 기계 당 복사본을 유지하는 것입니다.

    당신이 읽고 싶은 파일의 모든 근로자에 ​​액세스 할 수 있습니다. 이 로컬 파일 인 경우 유일한 옵션은 작업자 기계 당 복사본을 유지하는 것입니다.

  2. from https://stackoverflow.com/questions/34051598/pyspark-couldnt-find-the-local-file by cc-by-sa and MIT license