Skip to Content
Kafka Connect
book

Kafka Connect

by Mickael Maison, Kate Stanley
May 2025
Intermediate to advanced
402 pages
5h 9m
Chinese
O'Reilly Media, Inc.
Content preview from Kafka Connect

第 8 章 配置 Kafka 连接 配置 Kafka Connect

本作品已使用人工智能进行翻译。欢迎您提供反馈和意见:translation-feedback@oreilly.com

在本书中,我们会提到可用于自定义 Kafka Connect 的配置设置。所有这些设置都记录在Apache Kafka 网站上,你可以在那里找到它们的名称、类型、默认值和说明。

在本章中,我们将介绍所有的配置设置,并提供更多的上下文,帮助你识别需要注意的关键设置。我们还将展示如何将其中一些配置组合起来,以实现更高级用例所需的行为。

我们首先介绍运行时,从启动运行时所需的最基本配置,到影响连接器行为的更具体设置。然后,我们将了解连接器的配置,同样从最基本的配置开始,然后涵盖客户端重载和错误处理等更高级的概念。最后,我们将介绍所有可用的配置,以确保生产用例中 Kafka Connect 集群的安全。

在本章中,我们同时提到了 "运行时配置 "和" Worker 配置"。由于 Worker 实际上只是运行时的一个实例,因此这些术语在某种程度上可以互换。不过,在泛泛地谈论配置如何影响 Kafka Connect 运行时时,我们会使用 "运行时配置",而在谈论用于启动 Worker 的特定配置时,我们会使用 "worker 配置"。

备注

由于我们建议在生产集群中使用分布式模式,因此我们没有特别指出独立模式中不使用的配置。一般来说,配置 Worker 之间连接的任何配置都不适用于独立模式。只有一项配置是独立模式独有的:offset.storage.file.filename 。该配置指定了独立运行时用于存储源任务偏移量的文件。

配置运行时

应了解的第一组配置是运行时启动所需的配置:

bootstrap.servers
Worker 所连接的 Kafka 集群的地址;该设置需要一个列表。你应该始终将其设置为多个代理,或者使用冗余负载平衡器的主机名,这样即使某个代理宕机,Kafka Connect 也能连接到 Kafka。
group.id
Kafka Connect工作者加入群集时使用的 ID。此值不得与此 Kafka 集群中的现有组(消费者或其他)相冲突,否则将导致错误,如InconsistentGroupProtocolException
key.convertervalue.converter
运行时为连接器提供的默认转换器。这些配置没有默认值,因此需要显式设置。最后一个转换器header.converter 默认设置为SimpleHeaderConverter 。我们在第 4 章中详细讨论了转换器的影响。无论您将它们设置为什么,请确保运行时已安装默认转换器和特定连接器使用的转换器。我们将在"生产配置 "中介绍连接器如何覆盖这些值来配置自己的转换器。

最后一组强制 设置是针对 Kafka Connect 内部主题的。每个 Kafka Connect 集群必须为其内部主题使用不同的名称。您必须使用这些配置指定三个主题的名称:

  • offset.storage.topic

  • config.storage.topic

  • status.storage.topic

您还可以通过配置以下设置来指定每个主题的复制因子:

  • offset.storage.replication.factor

  • config.storage.replication.factor

  • status.storage.replication.factor

默认情况下,复制因子都设置为3 ,这是确保耐久性的良好值。在使用单个代理的开发环境中,需要将所有三个主题的复制因子都更改为 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Kafka Connect

Kafka Connect

Mickael Maison, Kate Stanley

Publisher Resources

ISBN: 9798341658189