如何将非 Confluent 连接器与 Apache Kafka Connect 集成
How to integrate non-Confluent connectors with Apache Kafka Connect
有一个要求,我们从 Kafka Stream 获取数据流,我们 objective 是将此数据推送到 SOLR。
我们做了一些阅读,但我们发现市场上有很多 Kafka Connect 解决方案,但问题是我们不知道哪个是最好的解决方案以及如何实现。
选项是:
- 使用 Solr 连接器与 Kafka 连接。
- 使用 Apache Storm,因为它直接提供与 Solr 集成的支持。
没有为上述选项提供太多文档或深入信息。
有好心人告诉我一下吗
我们如何在不使用 Confluent 的情况下使用 Solr 连接器并与 Kafka 流集成?
Solr-Kafka 连接器:https://github.com/MSurendra/kafka-connect-solr
此外,关于 Apache Storm,
Apache Storm 是否有可能接受 Kafka Stream 并将其推送到 Solr,尽管在将其推送到 Solr 之前我们需要对数据进行一些清理?
我在这里避免使用 Storm,因为问题主要是关于 Kafka Connect
CAVEAT - This Solr Connector in the question is using Kakfa 0.9.0.1 dependencies, therefore, it is very unlikely to work with the newest Kafka API's.
This connector is untested by me. Follow at your own risk
以下摘自 Confluent's documentation on using community connectors,并进行了一些强调和改编。换句话说,为不包含在 Confluent Platform 中的 Kafka Connects 编写。
1) 克隆连接器的 GitHub 存储库
$ git clone https://github.com/MSurendra/kafka-connect-solr
2) 使用 maven 构建 jar
切换到新克隆的 repo,并检查你想要的版本。 (This Solr connector has no releases like the Confluent ones)。
您通常会想要签出已发布的版本。
$ cd kafka-connect-solr; mvn package
从这里开始,见Installing Plugins
3) 找到连接器的超级 JAR 或插件目录
我们将 target
目录中生成的 Maven 输出复制到 Kafka Connect worker 插件路径中的目录之一(plugin.path
属性)。
例如,如果插件路径包含 /usr/local/share/kafka/plugins
目录,我们可以使用以下技术之一使连接器作为插件可用。
As mentioned in the Confluent docs,export CLASSPATH=<some path>/kafka-connect-solr-1.0.jar
选项会起作用,尽管 plugin.path
将是前进的方向(Kafka 1.0+)
你应该根据mvn package
的结果知道使用哪个选项
选项 1) 一个超级 JAR 文件
使用这个 Solr 连接器,我们得到一个名为 kafka-connect-solr-1.0.jar
.
的文件
我们将该文件复制到 /usr/local/share/kafka/plugins
目录中:
$ cp target/kafka-connect-solr-1.0.jar /usr/local/share/kafka/plugins/
选项 2) 依赖目录
(不适用于 Solr 连接器)
如果连接器的 JAR 被收集到构建目标目录的子目录中,我们可以将所有这些 JAR 复制到 /usr/local/share/kafka/plugins
中的插件目录中,例如
$ mkdir -p /usr/local/share/kafka/plugins/kafka-connect-solr
$ cp target/kafka-connect-solr-1.0.0/share/java/kafka-connect-solr/* /usr/local/share/kafka/plugins/kafka-connect-solr/
Note
Be sure to install the plugin on all of the machines where you’re running Kafka Connect distributed worker processes. It is important that every connector you use is available on all workers, since Kafka Connect will distribute the connector tasks to any of the worker
4) 运行 卡夫卡连接
如果您已正确设置 plugin.path
或 export CLASSPATH
,那么您可以使用 connect-standalone
或 connect-distributed
以及该 Connect 项目的适当配置文件。
关于,
we would need some sanitization of data before pushing it to Solr
您需要在 Kafka Connect 之前使用单独的进程(如 Kafka Streams、Storm 或其他进程)来执行此操作。将转换后的输出写入次要主题。或者编写自己的 Kafka Connect Transform 流程。 Kafka Connect has very limited transformations开箱即用。
还值得一提 - JSON seems to be the only supported Kafka message format for this Solr connector
有一个要求,我们从 Kafka Stream 获取数据流,我们 objective 是将此数据推送到 SOLR。
我们做了一些阅读,但我们发现市场上有很多 Kafka Connect 解决方案,但问题是我们不知道哪个是最好的解决方案以及如何实现。
选项是:
- 使用 Solr 连接器与 Kafka 连接。
- 使用 Apache Storm,因为它直接提供与 Solr 集成的支持。
没有为上述选项提供太多文档或深入信息。
有好心人告诉我一下吗
我们如何在不使用 Confluent 的情况下使用 Solr 连接器并与 Kafka 流集成?
Solr-Kafka 连接器:https://github.com/MSurendra/kafka-connect-solr
此外,关于 Apache Storm, Apache Storm 是否有可能接受 Kafka Stream 并将其推送到 Solr,尽管在将其推送到 Solr 之前我们需要对数据进行一些清理?
我在这里避免使用 Storm,因为问题主要是关于 Kafka Connect
CAVEAT - This Solr Connector in the question is using Kakfa 0.9.0.1 dependencies, therefore, it is very unlikely to work with the newest Kafka API's.
This connector is untested by me. Follow at your own risk
以下摘自 Confluent's documentation on using community connectors,并进行了一些强调和改编。换句话说,为不包含在 Confluent Platform 中的 Kafka Connects 编写。
1) 克隆连接器的 GitHub 存储库
$ git clone https://github.com/MSurendra/kafka-connect-solr
2) 使用 maven 构建 jar
切换到新克隆的 repo,并检查你想要的版本。 (This Solr connector has no releases like the Confluent ones)。 您通常会想要签出已发布的版本。
$ cd kafka-connect-solr; mvn package
从这里开始,见Installing Plugins
3) 找到连接器的超级 JAR 或插件目录
我们将 target
目录中生成的 Maven 输出复制到 Kafka Connect worker 插件路径中的目录之一(plugin.path
属性)。
例如,如果插件路径包含 /usr/local/share/kafka/plugins
目录,我们可以使用以下技术之一使连接器作为插件可用。
As mentioned in the Confluent docs,export CLASSPATH=<some path>/kafka-connect-solr-1.0.jar
选项会起作用,尽管 plugin.path
将是前进的方向(Kafka 1.0+)
你应该根据mvn package
选项 1) 一个超级 JAR 文件
使用这个 Solr 连接器,我们得到一个名为 kafka-connect-solr-1.0.jar
.
我们将该文件复制到 /usr/local/share/kafka/plugins
目录中:
$ cp target/kafka-connect-solr-1.0.jar /usr/local/share/kafka/plugins/
选项 2) 依赖目录
(不适用于 Solr 连接器)
如果连接器的 JAR 被收集到构建目标目录的子目录中,我们可以将所有这些 JAR 复制到 /usr/local/share/kafka/plugins
中的插件目录中,例如
$ mkdir -p /usr/local/share/kafka/plugins/kafka-connect-solr
$ cp target/kafka-connect-solr-1.0.0/share/java/kafka-connect-solr/* /usr/local/share/kafka/plugins/kafka-connect-solr/
Note
Be sure to install the plugin on all of the machines where you’re running Kafka Connect distributed worker processes. It is important that every connector you use is available on all workers, since Kafka Connect will distribute the connector tasks to any of the worker
4) 运行 卡夫卡连接
如果您已正确设置 plugin.path
或 export CLASSPATH
,那么您可以使用 connect-standalone
或 connect-distributed
以及该 Connect 项目的适当配置文件。
关于,
we would need some sanitization of data before pushing it to Solr
您需要在 Kafka Connect 之前使用单独的进程(如 Kafka Streams、Storm 或其他进程)来执行此操作。将转换后的输出写入次要主题。或者编写自己的 Kafka Connect Transform 流程。 Kafka Connect has very limited transformations开箱即用。
还值得一提 - JSON seems to be the only supported Kafka message format for this Solr connector