我想在我的本地机器上运行一个 pyspark session ,我想使用我存储在 AWS s3 存储桶中的数据。到目前为止,我正在尝试做
import pyspark as ps
fp = "s3n://my-bucket/some/data/file.csv"
spark = ps.sql.SparkSession.builder.master("local[*]").getOrCreate()
df = spark.read.csv(fp, schema=SCHEMA, sep="\t")
df.show(10, False)
模式在别处正确定义的地方。但是,我收到了一些奇怪的警告和一个奇怪的错误:(请注意,第一部分只是一个警告,不会阻止代码运行,即使它明确指出 java/util.ServiceConfigurationError。 )
2018-04-27 15:04:59 WARN NativeCodeLoader:62 - Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
2018-04-27 15:05:01 WARN FileSystem:2639 - Cannot load filesystem
java.util.ServiceConfigurationError: org.apache.hadoop.fs.FileSystem: org.apache.hadoop.fs.s3a.S3AFileSystem Unable to get public no-arg constructor
Caused by: java.lang.NoClassDefFoundError: com/amazonaws/AmazonServiceException
Caused by: java.lang.ClassNotFoundException: com.amazonaws.AmazonServiceException
2018-04-27 15:05:02 WARN FileStreamSink:66 - Error while looking for metadata directory.
py4j.protocol.Py4JJavaError: An error occurred while calling o32.csv.
: org.apache.hadoop.fs.s3.S3Exception: org.jets3t.service.ServiceException: Request Error: java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty
Caused by: org.jets3t.service.ServiceException: Request Error: java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty
Caused by: javax.net.ssl.SSLException: java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty
Caused by: java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty
Caused by: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty
什么是信任 anchor ?我该如何解决这个问题?
有趣的是,如果我尝试使用 boto3 并下载相同的文件,我可以毫无问题地执行此操作,这让我认为这不是与权限相关的问题。但是,考虑到我的数据大小和数据到达的速率,将整个存储桶下载到我的机器上并不是一个可行的解决方案。
我已经使用 pycharm 在干净的虚拟环境中安装了 pyspark。我在 pyspark/jars 中添加了 jars aws-java-sdk-1.11.317.jar 和 hadoop-aws-2.7.3.jar > 文件夹和 created an hdfs-site.xml在 pyspark/conf 文件夹下使用我的 AWS 凭据。
请您参考如下方法:
如果您的问题是 https://bugs.launchpad.net/ubuntu/+source/ca-certificates-java/+bug/1739631 ,您可能想尝试 https://gist.github.com/mikaelhg/527204e746984cf9a33f7910bb8b4cb6 中的解决方法, 这是
/usr/bin/printf '\xfe\xed\xfe\xed\x00\x00\x00\x02\x00\x00\x00\x00\xe2\x68\x6e\x45\xfb\x43\xdf\xa4\xd9\x92\xdd\x41\xce\xb6\xb2\x1c\x63\x30\xd7\x92' > /etc/ssl/certs/java/cacerts
/var/lib/dpkg/info/ca-certificates-java.postinst configure
