gpt4 book ai didi

amazon-s3 - 正确配置 Kafka Connect S3 Sink TimeBasedPartitioner

转载 作者:行者123 更新时间:2023-12-02 11:29:20 24 4
gpt4 key购买 nike

我正在尝试使用 Confluence S3 接收器的 TimeBasedPartitioner。这是我的配置:

{  
"name":"s3-sink",
"config":{
"connector.class":"io.confluent.connect.s3.S3SinkConnector",
"tasks.max":"1",
"file":"test.sink.txt",
"topics":"xxxxx",
"s3.region":"yyyyyy",
"s3.bucket.name":"zzzzzzz",
"s3.part.size":"5242880",
"flush.size":"1000",
"storage.class":"io.confluent.connect.s3.storage.S3Storage",
"format.class":"io.confluent.connect.s3.format.avro.AvroFormat",
"schema.generator.class":"io.confluent.connect.storage.hive.schema.DefaultSchemaGenerator",
"partitioner.class":"io.confluent.connect.storage.partitioner.TimeBasedPartitioner",
"timestamp.extractor":"Record",
"timestamp.field":"local_timestamp",
"path.format":"YYYY-MM-dd-HH",
"partition.duration.ms":"3600000",
"schema.compatibility":"NONE"
}

}

数据是二进制的,我使用 avro 方案。我想使用实际的记录字段“local_timestamp”,它是一个 UNIX 时间戳来对数据进行分区,比如每小时的文件。

我使用通常的 REST API 调用启动连接器

curl -X POST -H "Content-Type: application/json" --data @s3-config.json http://localhost:8083/connectors

不幸的是,数据没有按照我的意愿进行分区。我还尝试删除冲洗尺寸,因为这可能会干扰。但后来我得到了错误

{"error_code":400,"message":"Connector configuration is invalid and contains the following 1 error(s):\nMissing required configuration \"flush.size\" which has no default value.\nYou can also find the above list of errors at the endpoint `/{connectorType}/config/validate`"}%

知道如何正确设置 TimeBasedPartioner 吗?我找不到有效的例子。

此外,如何调试此类问题或进一步了解连接器实际在做什么?

非常感谢任何帮助或进一步的建议。

最佳答案

研究了TimeBasedPartitioner.java处的代码后和日志

confluent log connect tail -f

我意识到时区和区域设置都是强制性的,尽管 Confluent S3 Connector 中没有这样指定。文档。以下配置字段解决了问题,让我将正确分区的记录上传到 S3 存储桶:

"flush.size": "10000",
"storage.class": "io.confluent.connect.s3.storage.S3Storage",
"format.class": "io.confluent.connect.s3.format.avro.AvroFormat",
"schema.generator.class": "io.confluent.connect.storage.hive.schema.DefaultSchemaGenerator",
"partitioner.class": "io.confluent.connect.storage.partitioner.TimeBasedPartitioner",
"path.format": "'year'=YYYY/'month'=MM/'day'=dd/'hour'=HH",
"locale": "US",
"timezone": "UTC",
"partition.duration.ms": "3600000",
"timestamp.extractor": "RecordField",
"timestamp.field": "local_timestamp",

请注意两件事:首先,flush.size 的值也是必要的,文件最终会被分割成较小的 block ,但不能大于flush.size 指定的大小。其次,如上所示,更好地选择 path.format,以便生成正确的树结构。

我仍然不能 100% 确定记录字段 local_timestamp 是否真的用于对记录进行分区。

非常欢迎任何意见或改进。

关于amazon-s3 - 正确配置 Kafka Connect S3 Sink TimeBasedPartitioner,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48128620/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com