Flume无法访问s3来写入文件java.lang.IllegalArgumentException:URI s3中无效的主机名s3:// ACCESSKEY:SECRETKEY / @ bucket

时间:2019-05-28 07:45:32

标签: flume

Flume已安装在Amazon EC2(Amazon Linux AMI 2018.03.0.20190514 x86_64 HVM gp2)Flume版本:1.9

我尝试使用本地作为接收器,副本可以完美工作。但是,当我使用S3作为接收器时,我在URI问题中遇到了无效的主机名。 我仔细检查了访问密钥和秘密密钥,它们都是正确的。

我尝试使用s3n://无效

# example.conf: A single-node Flume configuration

# Name the components on this agent
a1.sources = r1
a1.sinks = k1
a1.channels = c1

a1.sources.r1.type = org.apache.flume.source.kafka.KafkaSource
a1.sources.r1.kafka.bootstrap.servers = localhost:9092
a1.sources.r1.kafka.topics = testflume
a1.sources.r1.kafka.consumer.group.id = flumeconsumer


a1.sinks.k1.type = hdfs
a1.sinks.k1.hdfs.path = s3://AWSACCESSKEY:AWSSECRETKEY@bucket/path
a1.sinks.k1.hdfs.fileType = DataStream
a1.sinks.k1.hdfs.filePrefix = event
a1.sinks.k1.hdfs.rollInterval = 10


# Use a channel which buffers events in memory
a1.channels.c1.type = memory
a1.channels.c1.capacity = 1000
a1.channels.c1.transactionCapacity = 1000

# Bind the source and sink to the channel
a1.sources.r1.channels = c1
a1.sinks.k1.channel = c1

错误

[ERROR - org.apache.flume.sink.hdfs.HDFSEventSink.process(HDFSEventSink.java:459)] process failed
java.lang.IllegalArgumentException: Invalid hostname in URI s3://AWSACCESSKEY:AWSSECRETKEY@bucket/path/event.1558997927667.tmp

我希望水槽能够在S3中成功进行身份验证并写入文件

1 个答案:

答案 0 :(得分:0)

您可以尝试使用s3a://吗? 但是,将角色分配给EC2实例并为该角色授予S3权限是一种好习惯,而不是提供AWS Access和密钥。设置好之后,您可以将路径设置为s3a://bucket_name/path/../