com.amazonaws.AmazonClientException:无法执行 HTTP 请求:不知道此类主机 (spark

编程入门 行业动态 更新时间:2024-10-27 16:37:08
本文介绍了com.amazonaws.AmazonClientException:无法执行 HTTP 请求:不知道此类主机 (spark-tunes.s3a.ap-south-1.amazonaws)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我正在尝试通过 pycharm 从本地模式下的 spark 读取存储在 S3 存储桶中的 json 文件.但我收到以下错误消息:

I am trying to read a json file stored in S3 bucket from spark in local mode via pycharm. But I'm getting the below error message:

"py4j.protocol.Py4JJavaError: 调用 o37.json 时发生错误.: com.amazonaws.AmazonClientException: 无法执行 HTTP 请求: 不知道这样的主机 (spark-tunes.s3a.ap-south-1.amazonaws)"

"py4j.protocol.Py4JJavaError: An error occurred while calling o37.json. : com.amazonaws.AmazonClientException: Unable to execute HTTP request: No such host is known (spark-tunes.s3a.ap-south-1.amazonaws)"

(spark-tunes 是我的 S3 存储桶名称).

(spark-tunes is my S3 bucket name).

下面是我执行的代码.请帮助我知道我是否遗漏了什么.

Below is the code I executed. Please help me to know if I'm missing something.

spark = SparkSession.builder.appName('DF Read').config('spark.master', 'local').getOrCreate()

spark._jsc.hadoopConfiguration().set("fs.s3a.access.key", "access_key")
spark._jsc.hadoopConfiguration().set("fs.s3a.secret.key", "secret_key")

spark._jsc.hadoopConfiguration().set("fs.s3a.endpoint", "s3a.ap-south-1.amazonaws")
spark._jsc.hadoopConfiguration().set("com.amazonaws.services.s3a.enableV4", "true")
spark._jsc.hadoopConfiguration().set("fs.s3a.impl", "org.apache.hadoop.fs.s3a.S3AFileSystem")

df = spark.read.json("s3a://bucket-name/folder_name/*.json")

df.show(5)

推荐答案

尝试将 fs.s3a.path.style.access 设置为 false,而不是为主机添加存储桶名称的前缀,aws s3 客户端将使用路径下的路径端点

try setting fs.s3a.path.style.access to false and instead of prefixing the bucket name to the host, the aws s3 client will use paths under the endpoint

另外:删除 fs.s3a.impl 行.这是在堆栈溢出示例中流传下来的迷信.不需要.真的.

also: drop the fs.s3a.impl line. That is superstition passed down across stack overflow examples. It's not needed. really.

这篇关于com.amazonaws.AmazonClientException:无法执行 HTTP 请求:不知道此类主机 (spark-tunes.s3a.ap-south-1.amazonaws)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-04-23 04:46:34,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1034906.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:此类   主机   AmazonClientException   amazonaws   spark

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!