我使用的是Spark 1.6版本的本地模式。以下是我的代码:
第一次尝试:
airline = sc.textFile("s3n://mortar-example-data/airline-data")
airline.take(2)第二次尝试:
airline = sc.textFile("s3n://myid:mykey@mortar-example-data/airline-data")
airline.take(2)上面的代码抛出了下面的错误:
Py4JJavaError: An error occurred while calling o17.partitions.
: java.io.IOException: No FileSystem for scheme: s3n
at org.apache.hadoop.fs.FileSystem.getFileSystemClass(FileSystem.java:2584)
at org.apache.hadoop.fs.FileSystem.createFileSystem(FileSystem.java:2591)
at org.apache.hadoop.fs.FileSystem.access$200(FileSystem.java:91)不确定此处缺少连接到S3的内容。如果有人能指给我看那就太好了
发布于 2016-09-14 03:13:44
@John
以下是我的解决方案
bucket = "your bucket"
# Prod App Key
prefix = "Your path to the file"
filename = "s3n://{}/{}".format(bucket, prefix)
sc._jsc.hadoopConfiguration().set("fs.s3n.awsAccessKeyId", "YourAccessKey")
sc._jsc.hadoopConfiguration().set("fs.s3n.awsSecretAccessKey", "YourSecret key")
rdd = sc.hadoopFile(filename,
'org.apache.hadoop.mapred.TextInputFormat',
'org.apache.hadoop.io.Text',
'org.apache.hadoop.io.LongWritable',
)
rdd.count()上面的代码对我来说很有效...祝好运。
https://stackoverflow.com/questions/35567237
复制相似问题