当我使用flinks streaming 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配置目录已添加到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)
我可以使用带有awscli的core-site.xml中的凭据写入S3存储桶。
答案 0 :(得分:1)
我已经使用DataStream API写入S3,在我的例子中,core-site.xml实际上存在于具有相同配置的jar中。 你能不能试试这种方法。
如果S3 API无法从任何提供程序获取凭据,则会发生此错误,如以下链接所述
此处定义了其他方法来提供凭据:http://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/credentials.html