Kafka Connect之编译kafka-connect-elasticsearch-5.1.0连接器

环境:

Linux:Centos7

JDK:Java version "1.8.0_161"

maven:3.6.0

gradle:Gradle 4.10.3

开始编译:

前期准备:

因为kafka-connect-elasticsearch依赖parent项目(查看它的pom文件),需要下载common,还依赖kafka,直接编译无法找到jar包,所以又需要下载kafka的,如果已经有了,则不需要下载kafka,这里下载三个项目:

1. Kafka:

wget https://codeload.github.com/apache/kafka/zip/0.11.0

2.confluentinc/kafka-connect-elasticsearch
wget https://codeload.github.com/confluentinc/kafka-connect-elasticsearch/zip/5.1.0-post

3.confluentinc/common
wget https://codeload.github.com/confluentinc/common/zip/5.1.0-post

先编译kafka:

本来准备直接放windows上编译的,但是出现如下错误,有说网络大墙原因,有说其他的。索性放linux上吧

Kafka Connect之编译kafka-connect-elasticsearch-5.1.0连接器_第1张图片

以下为更改Centos7下编译:

下载源码:wget https://codeload.github.com/apache/kafka/zip/0.11.0

解压:unzip 0.11.0

修改kafka版本:[root@flu03 kafka-0.11.0]# vim gradle.properties
version=0.11.0.3   # 版本错了,后续无法下载连接器版本,这里版本一定要在maven repository中搜索下:connect,查看到connect中有带有kafka相同后缀的版本,或者直接在common中修改kafka版本,这里为保持一致,我都按照已有的不变原则来处理。

运行:[root@flu03 kafka-0.11.0]# gradle

Kafka Connect之编译kafka-connect-elasticsearch-5.1.0连接器_第2张图片

查看下编译好的版本是否是修改后的:
ll /opt/kafka-0.11.0/core/build/libs (我把源码都下载到了opt目录)

将kafka安装到本地库中: ./gradlew installAll

编译Common:

要获取到相应的版本信息,必须编译这个项目:

[root@flu03 common-5.1.0-post]# vim pom.xml
0.11.0.3
2.11

执行:
mvn -pl :common-config package
mvn install

编译kafka-connect-elasticsearch

直接运行:mvn install

最后日志。。。

[INFO] Copying files to /opt/kafka-connect-elasticsearch-5.1.0-post/target/kafka-connect-elasticsearch-5.1.0-package
[WARNING] Assembly file: /opt/kafka-connect-elasticsearch-5.1.0-post/target/kafka-connect-elasticsearch-5.1.0-package is not a regular file (it may be a directory). It cannot be attached to the project build for installation or deployment.
[INFO] 
[INFO] --- maven-jar-plugin:3.0.2:test-jar (default) @ kafka-connect-elasticsearch ---
[INFO] Building jar: /opt/kafka-connect-elasticsearch-5.1.0-post/target/kafka-connect-elasticsearch-5.1.0-tests.jar
[INFO] 
[INFO] --- maven-failsafe-plugin:2.21.0:integration-test (integration-test) @ kafka-connect-elasticsearch ---
[INFO] 
[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] 
[INFO] Results:
[INFO] 
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO] 
[INFO] 
[INFO] --- maven-failsafe-plugin:2.21.0:verify (verify) @ kafka-connect-elasticsearch ---
[INFO] 
[INFO] --- maven-install-plugin:2.5.2:install (default-install) @ kafka-connect-elasticsearch ---
[INFO] Installing /opt/kafka-connect-elasticsearch-5.1.0-post/target/components/kafka-connect-elasticsearch-5.1.0.jar to /root/.m2/repository/io/confluent/kafka-connect-elasticsearch/5.1.0/kafka-connect-elasticsearch-5.1.0.jar
[INFO] Installing /opt/kafka-connect-elasticsearch-5.1.0-post/pom.xml to /root/.m2/repository/io/confluent/kafka-connect-elasticsearch/5.1.0/kafka-connect-elasticsearch-5.1.0.pom
[INFO] Installing /opt/kafka-connect-elasticsearch-5.1.0-post/target/kafka-connect-elasticsearch-5.1.0-tests.jar to /root/.m2/repository/io/confluent/kafka-connect-elasticsearch/5.1.0/kafka-connect-elasticsearch-5.1.0-tests.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  05:04 min
[INFO] Finished at: 2019-01-18T11:31:05+08:00
[INFO] ------------------------------------------------------------------------

最后进入目录查看下:

ll /root/.m2/repository/io/confluent/kafka-connect-elasticsearch/5.1.0
Kafka Connect之编译kafka-connect-elasticsearch-5.1.0连接器_第3张图片

你可能感兴趣的:(后端开发)