【问题标题】:Flink S3 Write Fails Unable to load AWS credentials from any provider in the chainsFlink S3 写入失败无法从链中的任何提供商加载 AWS 凭证
【发布时间】:2018-03-23 17:03:47
【问题描述】:

当我使用 flinks 流 API 写入 S3 时:

// Set StreamExecutionEnvironment
final StreamExecutionEnvironment env = 
StreamExecutionEnvironment.getExecutionEnvironment();

// Set checkpoints in ms
env.setStreamTimeCharacteristic(TimeCharacteristic.EventTime);

// Add source (input stream)
DataStream<String> dataStream = StreamUtil.getDataStream(env, params);

// Sink to S3 Bucket
dataStream.writeAsText("s3a://test-flink/test.txt").setParallelism(1);

我收到以下错误:

Unable to load AWS credentials from any provider in the chain

我的配置是:

# flink --version
Version: 1.3.1, Commit ID: 1ca6e5b

Hadoop config 目录添加到 flink-conf.yaml

# cat flink/config/flink-conf.yaml | head -n1
fs.hdfs.hadoopconf: /root/hadoop-config

flink-conf.yaml 其余内容与发布版本一致。

以下内容已添加到 /root/hadoop-config/core-site.xml

# cat  /root/hadoop-config/core-site.xml
<configuration>
<property>
    <name>fs.s3a.impl</name>
    <value>org.apache.hadoop.fs.s3a.S3AFileSystem</value>
</property>

<property>
    <name>fs.s3a.buffer.dir</name>
    <value>/tmp</value>
</property>

<property>
    <name>fs.s3a.access.key</name>
    <value>MY_ACCESS_KEY</value>
</property>

<property>
    <name>fs.s3a.secret.key</name>
    <value>MY_SECRET_KEY</value>
</property>
</configuration>

JAR 的 aws-java-sdk-1.7.4.jar、hadoop-aws-2.7.4.jar、httpclient-4.2.5.jar、httpcore-4.2.5.jar 从哪里添加到 flink/lib/ http://apache.mirror.anlx.net/hadoop/common/hadoop-2.7.4/hadoop-2.7.4.tar.gz

# ls flink/lib/
aws-java-sdk-1.7.4.jar
flink-dist_2.11-1.3.1.jar
flink-python_2.11-1.3.1.jar
flink-shaded-hadoop2-uber-1.3.1.jar
hadoop-aws-2.7.4.jar
httpclient-4.2.5.jar
httpcore-4.2.5.jar
log4j-1.2.17.jar
slf4j-log4j12-1.7.7.jar

注意 aws-java-sdk-1.7.4.jar 是 1.7.4 而不是 1.7.2,因为它在文档 here

pom.xml 具有以下构建依赖项。

    <dependency>
        <groupId>org.apache.flink</groupId>
        <artifactId>flink-connector-filesystem_2.10</artifactId>
        <version>1.3.1</version>
    </dependency>

    <dependency>
        <groupId>org.apache.hadoop</groupId>
        <artifactId>hadoop-aws</artifactId>
        <version>2.7.2</version>
    </dependency>

我的参考是 (https://ci.apache.org/projects/flink/flink-docs-release-1.3/setup/aws.html#set-s3-filesystem)

我可以使用 core-site.xml 中的凭证和 awscli 写入 S3 存储桶。

【问题讨论】:

    标签: amazon-s3 apache-flink flink-streaming


    【解决方案1】:

    我已使用 DataStream API 写入 S3,在我的情况下,core-site.xml 实际上存在于具有相同配置的 jar 中。 你能试试这个方法吗?

    当 S3 API 无法从以下链接中描述的任何提供商处获取凭据时,会发生错误

    这里定义了其他方法来提供凭据:http://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/credentials.html

    【讨论】:

    • 感谢Vinay,在jar xf jar-file JAR 文件之后,然后find . -name "*.xml",我只能找到./core-default.xml,更新此文件并不能解决问题,我是否遗漏了什么?
    • core-site.xml 应该放在 jar 的根目录下还是放在哪里?
    • 这意味着您运行的节点配置不正确。请检查您正在运行 flink 作业的节点上是否有 .aws/credentials 文件。如果不存在,则必须运行 aws s3 configure 命令,如下所示docs.aws.amazon.com/cli/latest/reference/configure
    • 是的,core-site 应该保存在 src/main/resources 中,所以创建 jar 的时候会去根目录
    • 是的,/root/.aws/credentials/ 存在于运行 flink 作业的节点上,我可以使用该节点上的awscli 来读取/写入 s3。
    猜你喜欢
    • 2017-06-15
    • 2023-03-11
    • 1970-01-01
    • 1970-01-01
    • 2021-08-11
    • 2019-06-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多