Kafka 目前在 Confluent Hub 上提供了上百种 Connector,比如 Elasticsearch Service Sink Connector, Amazon Sink Connector, HDFS Sink 等,用户可以使用这些 Connector 以 Kafka 为中心构建任意系统之间的数据管道。

什么是 Confluent?

Confluent 在 Kafka 的基础上增加很多扩展功能。包括:

  • Schema Registry
  • REST 代理
  • 非 Java 客户端
  • 很多打包好的 Kafka Connect 插件
  • 管理和监控 Kafka 的 GUI —— Confluent 控制中心

这些扩展功能有的包含在社区版本的 Confluent 中,有的只有企业版能用。

Confluent 企业版提供了 confluent 命令行工具管理各个组件。

在不安装 Confluent Platform 的情况下使用 Confluent Hub

Confluence Hub 客户端 作为完整 Confluence 平台的一部分本地安装/bin,并位于该目录中。如果您使用 Confluence Community 软件,则可以按照以下说明单独安装 Confluence Hub 客户端。

MacOS

切换 Confluence Hub 客户端的 Confluence 存储库。

brew tap confluentinc/homebrew-confluent-hub-client

安装 Confluence Hub 客户端。

brew install --cask confluent-hub-client

通过 confluent-hub 在终端中键入内容来验证您的安装(可选)

confluent-hub

你的输出应该是这样的:

usage: confluent-hub <command> [ <args> ]

Commands are:
    help      Display help information
    install   install a component from either Confluent Hub or from a local file

See 'confluent-hub help <command>' for more information on a specific command.
Linux

下载并安装 Confluence Hub tarball。

$ cd /usr/local/src && wget https://client.hub.confluent.io/confluent-hub-client-latest.tar.gz --no-check-certificate
$ tar -xzf confluent-hub-client-latest.tar.gz -C /usr

使用 which confluent-hub 找到 confluent-hub 命令

通过 confluent-hub 在终端中键入内容来验证您的安装(可选)

confluent-hub

你的输出应该是这样的:

usage: confluent-hub <command> [ <args> ]

Commands are:
    help      Display help information
    install   install a component from either Confluent Hub or from a local file

See 'confluent-hub help <command>' for more information on a specific command.

使用 Confluence Hub 客户端安装组件

在线安装

连接到互联网后,请按照以下说明安装 Kafka Connect JDBC 连接器。

使用以下 Confluence Hub 客户端命令将组件从 Confluence Hub 安装到本地 Confluence 平台安装中:

confluent-hub install <owner>/<component>:<version>
  • <owner> 是 Confluence Hub 上组件所有者的名称。
  • <component> 是 Confluence Hub 上组件的名称。
  • <version> 是 Confluence Hub 上组件的版本,或者是latest您想要安装最新版本组件时的文字。
使用体验

但是,当我上线安装 kafka-connect-elasticsearch 连接器时

confluent-hub install confluentinc/kafka-connect-elasticsearch:latest

我继续收到此错误消息:

Unable to detect Confluent Platform installation. Specify --component-dir and --worker-configs explicitly.

Error: Invalid options or arguments

解决方案:

显式指定 --component-dir 和 --worker-configs

需要显式的传递两个选项,Kafka Connect 的 plugin.path 参数设置插件存储目录 和connect-distributed.properties 配置文件路径

例如

confluent-hub install <name> \
   --component-dir /home/kafka/plugins \
   --worker-configs /usr/local/kafka_2.13-3.6.0/config/connect-distributed-prod.properties

此命令将下载并解压 连接器 zip 到 /home/kafka/plugins 并修改文件以在其属性 connect-distributed.properties 中包含该路径 plugin.path

confluent-hub install confluentinc/kafka-connect-elasticsearch:latest \
   --component-dir /home/kafka/plugins \
   --worker-configs /usr/local/kafka_2.13-3.6.0/config/connect-distributed-prod.properties
离线安装(使用 ZIP 文件)

如果处于离线状态,您可以通过从 Confluence Hub 下载 ZIP 文件来安装连接器。要安装连接器,请运行以下命令:

confluent-hub install <component>-<version>.zip
重新启动连接器容器

安装连接器后,必须重新启动连接器容器。如果您不重新启动连接器容器,则已安装的连接器磁贴将不会显示在Confluence Control Center的“连接”页面 上。

[root@kafka kafka]# systemctl restart kafka-connect.service

参考资料

https://zhuanlan.zhihu.com/p/660303784
https://docs.confluent.io/platform/current/connect/confluent-hub/client.html
https://stackoverflow.com/questions/56958382/use-confluent-hub-without-confluent-platform-installation

作者:Jeebiz  创建时间:2023-12-07 14:39
最后编辑:Jeebiz  更新时间:2024-09-23 10:03