kafka connect 大概了解

kafka connect

Introduction

Kafka Connect is the component of Kafka that provides data integration between databases, key-value stores, search indexes, file systems, and Kafka brokers.

kafka connect 是一个框架,用来帮助集成其他系统的数据到kafka,或者将kafka 的数据吐到其他系统,例如数据库,Elasticsearch 之类的外部系统。

在kafka connect 里,有 kafka woker, kafka connectorkafka connect plugin的概念。

一个kafka worker 就是一个instance,类似一个pod 这种独立的实例。

kafka connector 就是用来搬运数据的连接器。有 source connector 和 sink connector.

Source 就是数据来源的connector,sink 就是吐出数据的 connector.

例如

Connector Type Name Purpose
Source JdbcSourceConnector Pull data from relational DBs
Sink ElasticsearchSinkConnector Push Kafka data to Elasticsearch
Source FileStreamSourceConnector Read lines from file into Kafka

connector 简略配置

json 复制代码
{
  "name": "my-jdbc-source",
  "connector.class": "io.confluent.connect.jdbc.JdbcSourceConnector",
  "tasks.max": "1",
  "connection.url": "jdbc:mysql://localhost:3306/mydb",
  "topic.prefix": "mysql-"
}

A Kafka Connect Plugin is the packaged code (JAR files) that implements one or more connectors.

It's usually installed by placing the plugin into Kafka Connect's plugin.path directory.

A plugin might include:

  • The connector logic

  • Converters (e.g., JSON, Avro)

  • Transformations (optional logic to modify data)

Think of a connector as a configuration, and a plugin as the actual implementation that makes it work.

实现结构

从部署的角度来看,kafka connect 是一个独立的service cluster。

下面的docker-compose.yml 配置可以看出 cp-kafka-connect 这个image 就可可以load 在 CONNECT_PLUGIN_PATH 配置目录下的 connect plugin 来实现不同的 connector 功能。

confluent-hub install --no-prompt debezium/debezium-connector-mysql:1.7.1 这个命令就是部署mysql 相关的source connector 到 CONNECT_PLUGIN_PATH 配置的目录usr/share/confluent-hub-components 下面。

yaml 复制代码
kafka-connect:
  image: confluentinc/cp-kafka-connect:7.1.0-1-ubi8
  environment:
    CONNECT_PLUGIN_PATH: /usr/share/java,/usr/share/confluent-hub-components

  command:
    - bash
    - -c
    - |
      confluent-hub install --no-prompt debezium/debezium-connector-mysql:1.7.1
      /etc/confluent/docker/run

然后再通过kafka connect 的REST API 就可以enable 这个connector 了。

相关推荐
风吹夏回5 天前
RabbitMQ 核心术语 + Python pika 方法完整讲解
分布式·python·rabbitmq
风吹夏回6 天前
RabbitMQ 三种模式入门:HelloWorld、WorkQueue、PubSub
分布式·rabbitmq·ruby
霸道流氓气质6 天前
分布式追踪与 RequestId 传播完全指南
分布式
cheems95276 天前
[RabbitMQ高级特性] 消息确认机制:从 Ready / Unacked 到 basicAck、basicReject、basicNack 的底层拆解
分布式·rabbitmq·ruby
whaledown6 天前
Kafka 与 Java 消息队列入门:用订单场景理解核心机制
java·kafka·消息队列·springboot
枫华落尽6 天前
【Hadoop01-完全分布式运行模式】
分布式
隔壁阿布都6 天前
ShedLock 分布式定时任务锁框架介绍
spring boot·分布式
文艺倾年6 天前
【强化学习】数学推导专题,20W字总结(十五)
人工智能·分布式·大模型·强化学习·vibecoding
ACP广源盛139246256736 天前
GSV9001S@ACP#1080P 级视频处理芯片,物理 AI 普及终端的高性价比选择
大数据·人工智能·分布式·嵌入式硬件·spark
guslegend6 天前
第1章:初始Kafka
分布式·kafka