java - 如何解决 S3 错误 : org. jets3t.service.S3ServiceException : S3 GET failed? Java

标签 java hadoop amazon-s3 parquet

我正在尝试使用 Apache Parquet Reader 在 S3 上获取和读取 parquet 文件,我的代码如下所示:

ParquetReader<GenericData.Record> reader = null;
Path internalPath = new Path("s3://S3AccessID:S3SecretKey@bucketName/tmp0.parquet");
try {
            InputFile inputFile = HadoopInputFile.fromPath(internalPath, new Configuration());
            reader = AvroParquetReader.<GenericData.Record>builder(inputFile).build();
            GenericData.Record record;
            while ((record = reader.read()) != null) {
                System.out.println(record);
            }
}

但是,当我构建并运行程序时,这是错误屏幕:
        at org.apache.hadoop.fs.s3.Jets3tFileSystemStore.get(Jets3tFileSystemStore.java:156)
        at org.apache.hadoop.fs.s3.Jets3tFileSystemStore.retrieveINode(Jets3tFileSystemStore.java:195)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:567)
        at org.apache.hadoop.io.retry.RetryInvocationHandler.invokeMethod(RetryInvocationHandler.java:85)
        at org.apache.hadoop.io.retry.RetryInvocationHandler.invoke(RetryInvocationHandler.java:62)
        at com.sun.proxy.$Proxy12.retrieveINode(Unknown Source)
        at org.apache.hadoop.fs.s3.S3FileSystem.getFileStatus(S3FileSystem.java:332)
        at org.apache.parquet.hadoop.util.HadoopInputFile.fromPath(HadoopInputFile.java:39)
        at read.read.readParquetFile(read.java:153)
        at read.read.main(read.java:80)
Caused by: org.jets3t.service.S3ServiceException: S3 GET failed for '/%2Ftmp0.parquet' XML Error Message: <?xml version="1.0" encoding="UTF-8"?><Error><Code>InvalidRequest</Code><Message>The authorization mechanism you have provided is not supported. Please use AWS4-HMAC-SHA256.</Message><RequestId>1A66095653EBAD50</RequestId><HostId>jNzbaMmKmszHiLvzA4NsqILRxF+qJFxJLTWvKVwqHoggB0MnYy1ESoajHaa/Ufs5RE8ghs31Jaw=</HostId>

Does anyone have any idea how to address this?

最佳答案

从错误消息来看,您的 S3 存储桶区域似乎使用 Signature Version 4 (v4) 签名协议(protocol),并且不支持旧版本 (v2)。

The authorization mechanism you have provided is not supported. Please use AWS4-HMAC-SHA256.



在这种情况下,您必须设置属性 fs.s3a.endpointcore-site.xml或在作业配置中。此属性的值可在 Amazon S3 Endpoints 下找到。 .

此外,
  • 使用hadoop的s3a客户端而不是 s3 .
  • 不要在 s3a URL 中嵌入 access_key 和 secret_access_key,而是使用这些属性 fs.s3a.access.keyfs.s3a.secret.key .可用于 S3 身份验证的完整属性列表可在 here 中找到。 .
  • 关于java - 如何解决 S3 错误 : org. jets3t.service.S3ServiceException : S3 GET failed? Java,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61160689/

    相关文章:

    java - 通用 Java SAML 2.0 token 使用者 API

    java - 如何读取损坏的符号链接(symbolic link)指向的路径?

    hadoop - Pig 的 UDF 错误 - 无法使用导入解决

    hadoop - HDFS 有文件但发生 java.io.FileNotFoundException

    amazon-web-services - Cloudformation 存储桶策略 - "Statement is missing required element"

    node.js - 301 PermanentRedirect 从getSignedURL得到的URL返回到putObject

    java - 将新字段添加到设备管理页面 (OpenGTS-v2.5.9)

    java - Android下载文件时出现"Unfortunately, ... has stopped"

    java - 如何在 Apache Spark 中使用 PathFilter?

    amazon-s3 - 亚马逊 S3 与 Dynamodb