如何在分布式模式下运行Kafka-connect-replicator?

时间:2019-07-22 07:05:37

标签: apache-kafka apache-kafka-connect

我想使用融合的复制器将数据从一个系统复制到另一个系统。我正在使用两个Ubuntu 18.04系统,其中一个充当源,另一个充当目标。

我尝试在分布式模式下运行kafka-connect-replicator,在其中更改了以下配置:

  1. 在confluent / etc / kafka / server.properties中,我做了以下更改
SOURCE
> advertised.listeners=PLAINTEXT://source.ip:9092
DESTINATION
> advertised.listeners=PLAINTEXT://destination.ip:9092

  1. 在confluent / etc / kafka-connect-replicator / replicator.connect.distributed.properties中,我进行了以下更改

 - group.id=connect-replicator

group.id is same on source and destination system

SOURCE

 - bootstrap.servers=destination.ip:9092, source.ip:9092

DESTINATION

 - bootstrap.servers=destination.ip:9092, source.ip:9092

  1. 在confluent / etc / kafka-connect-replicator / quickstart-replicator.properties中,我更改了以下配置

来源

name=replicator-source
connector.class=io.confluent.connect.replicator.ReplicatorSourceConnector
# source cluster connection info
src.kafka.bootstrap.servers=source.ip:9092
# Set to use direct connection to Zookeeper by Replicator on the source
src.zookeeper.connect=localhost:2181

# destination cluster connection info
dest.kafka.bootstrap.servers=destination.ip:9092
# Set to use direct connection to Zookeeper by Replicator on the destination
dest.zookeeper.connect=destination.ip:2181
# configure topics to replicate
topic.whitelist= test-topic
topic.rename.format=${topic}.replica

目的地

name=replicator-source
connector.class=io.confluent.connect.replicator.ReplicatorSourceConnector
# source cluster connection info
src.kafka.bootstrap.servers=source.ip:9092
# Set to use direct connection to Zookeeper by Replicator on the source
src.zookeeper.connect=source.ip:2181

# destination cluster connection info
dest.kafka.bootstrap.servers=destination.ip:9092
# Set to use direct connection to Zookeeper by Replicator on the destination
dest.zookeeper.connect=destination.ip:2181
# configure topics to replicate
topic.whitelist= test-topic
topic.rename.format=${topic}.replica

然后我在源系统中创建了主题,并使用以下命令启动了连接器

PATH_TO_CONFLUENT> sudo ./bin/connect-distributed ./etc/kafka-connect-replicator/replicator-connect-distributed.properties ./etc/kafka-connect-replicator/quickstart-replicator.properties

此后,我在源系统中的主题中生成数据,并尝试在主题名称为{topic} .replica的目标系统中使用,但是没有要使用的主题。

1 个答案:

答案 0 :(得分:0)

目前尚不清楚您遇到了什么错误,但有一些注意事项。

  1. connect-distributed仅使用一个属性文件,而不是两个。您通过HTTP将属性作为JSON发布到连接群集,而不在群集启动期间加载属性文件。快速入门文件旨在用于connect-standalone

JSON看起来像

{"name": "your-replicator-name", "config": {
  "src.kafka.bootstrap.servers": "...",
  ...
}
  1. ./etc/kafka/connect-distributed.properties应该是在分布式模式下运行任何Connect或Replicator群集的起点,尽管replicator-connect-distributed.properties

  2. 中可能有类似的配置
  3. bootstrap.servers仅应指向单个群集。源和目标将在src.kafka.bootstrap.serversdest.kafka.bootstrap.servers

  4. 中分开